AW_Onpulse - Version 1.0.2

Version Notes

Dashboard

The dashboard displays the latest sales data as well as gives a fast look at yesterday’s sales;
orders with max/min/ average values;
the number of registered users and online visitors.

Sales

Attractive bar chart showing sales statistics for the past 15 days.

Orders

The latest orders are sorted by date and include order ID, client name, status information, and other purchase details.
Tap on email or phone number to contact your customer.

Clients

The list of customers that contains personal information and purchase activity.

Download this release

Release Info

Developer AW_Core_Team
Extension AW_Onpulse
Version 1.0.2
Comparing to
See all releases


Version 1.0.2

Files changed (47) hide show
  1. app/code/local/AW/All/Block/Jsinit.php +227 -0
  2. app/code/local/AW/All/Block/Notification/Window.php +62 -0
  3. app/code/local/AW/All/Block/System/Config/Form/Fieldset/Awall/Extensions.php +194 -0
  4. app/code/local/AW/All/Block/System/Config/Form/Fieldset/Awall/Store.php +33 -0
  5. app/code/local/AW/All/Helper/Config.php +31 -0
  6. app/code/local/AW/All/Helper/Data.php +24 -0
  7. app/code/local/AW/All/Helper/Versions.php +94 -0
  8. app/code/local/AW/All/Model/Feed.php +91 -0
  9. app/code/local/AW/All/Model/Feed/Abstract.php +64 -0
  10. app/code/local/AW/All/Model/Feed/Extensions.php +122 -0
  11. app/code/local/AW/All/Model/Feed/Updates.php +129 -0
  12. app/code/local/AW/All/Model/Source/Updates/Type.php +80 -0
  13. app/code/local/AW/All/etc/adminhtml.xml +49 -0
  14. app/code/local/AW/All/etc/config.xml +122 -0
  15. app/code/local/AW/All/etc/system.xml +84 -0
  16. app/code/local/AW/Onpulse/Block/System/Config/Form/Fieldset/Onpulse/Settings.php +12 -0
  17. app/code/local/AW/Onpulse/Helper/Data.php +247 -0
  18. app/code/local/AW/Onpulse/Helper/Data.php.orig +242 -0
  19. app/code/local/AW/Onpulse/Model/Aggregator.php +9 -0
  20. app/code/local/AW/Onpulse/Model/Aggregator/Component.php +6 -0
  21. app/code/local/AW/Onpulse/Model/Aggregator/Components/Customer.php +38 -0
  22. app/code/local/AW/Onpulse/Model/Aggregator/Components/Order.php +19 -0
  23. app/code/local/AW/Onpulse/Model/Aggregator/Components/Statistics.php +169 -0
  24. app/code/local/AW/Onpulse/Model/Credentials.php +73 -0
  25. app/code/local/AW/Onpulse/etc/config.xml +118 -0
  26. app/code/local/AW/Onpulse/etc/system.xml +39 -0
  27. app/design/adminhtml/default/default/layout/aw_all.xml +17 -0
  28. app/design/adminhtml/default/default/layout/aw_onpulse.xml +12 -0
  29. app/design/adminhtml/default/default/template/aw_all/jsinit.phtml +32 -0
  30. app/design/adminhtml/default/default/template/aw_all/notification/window.phtml +74 -0
  31. app/design/adminhtml/default/default/template/aw_all/notification/window/first-run.phtml +65 -0
  32. app/design/adminhtml/default/default/template/aw_onpulse/settings.phtml +119 -0
  33. app/etc/modules/AW_All.xml +9 -0
  34. app/etc/modules/AW_Onpulse.xml +9 -0
  35. app/locale/en_US/AW_Onpulse.csv +9 -0
  36. js/aw_all/aw_all.js +11 -0
  37. package.xml +38 -0
  38. skin/adminhtml/default/default/aw_all/css/window.css +94 -0
  39. skin/adminhtml/default/default/aw_all/images/bad.gif +0 -0
  40. skin/adminhtml/default/default/aw_all/images/delete.jpg +0 -0
  41. skin/adminhtml/default/default/aw_all/images/info.gif +0 -0
  42. skin/adminhtml/default/default/aw_all/images/ok.gif +0 -0
  43. skin/adminhtml/default/default/aw_all/images/readme.png +0 -0
  44. skin/adminhtml/default/default/aw_all/images/store.png +0 -0
  45. skin/adminhtml/default/default/aw_all/images/update.gif +0 -0
  46. skin/adminhtml/default/default/aw_all/images/window/arrow.gif +0 -0
  47. skin/adminhtml/default/default/aw_all/images/window/btn-close.gif +0 -0
app/code/local/AW/All/Block/Jsinit.php ADDED
@@ -0,0 +1,227 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * aheadWorks Co.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://ecommerce.aheadworks.com/LICENSE-M1.txt
11
+ *
12
+ * @category AW
13
+ * @package AW_All
14
+ * @copyright Copyright (c) 2009-2010 aheadWorks Co. (http://www.aheadworks.com)
15
+ * @license http://ecommerce.aheadworks.com/LICENSE-M1.txt
16
+ */
17
+ class AW_All_Block_Jsinit extends Mage_Adminhtml_Block_Template
18
+ {
19
+
20
+
21
+ protected $_platform = -1;
22
+ protected $_extensions_cache = array();
23
+ protected $_extensions;
24
+
25
+ protected $_section = '';
26
+ protected $_store_data = null;
27
+
28
+ /**
29
+ * Include JS in head if section is moneybookers
30
+ */
31
+ protected function _prepareLayout()
32
+ {
33
+ $this->_section = $this->getAction()->getRequest()->getParam('section', false);
34
+ if ($this->_section == 'awall') {
35
+ $this->getLayout()
36
+ ->getBlock('head')
37
+ ->addJs('aw_all/aw_all.js');
38
+ $this->setData('extensions', $this->_initExtensions());
39
+ } elseif ($this->_section == 'awstore') {
40
+ // AW extensions store
41
+ $this->getLayout()
42
+ ->getBlock('head')
43
+ ->addJs('aw_all/aw_all.js');
44
+ $this->setData('store_data', $this->_getStoreData());
45
+ }
46
+ parent::_prepareLayout();
47
+ }
48
+
49
+ /**
50
+ * Print init JS script into body
51
+ * @return string
52
+ */
53
+ protected function _toHtml()
54
+ {
55
+ if ($this->_section == 'awall' || $this->_section == 'awstore') {
56
+ return parent::_toHtml();
57
+ } else {
58
+ return '';
59
+ }
60
+ }
61
+
62
+ protected function _initExtensions()
63
+ {
64
+
65
+ $extensions = array();
66
+
67
+ $modules = array_keys((array)Mage::getConfig()->getNode('modules')->children());
68
+ sort($modules);
69
+
70
+ foreach ($modules as $moduleName) {
71
+ if (strstr($moduleName, 'AW_') === false) {
72
+ continue;
73
+ }
74
+
75
+ if ($moduleName == 'AW_Core' || $moduleName == 'AW_All') {
76
+ continue;
77
+ }
78
+ // Detect extension platform
79
+ try {
80
+ if ($platform = Mage::getConfig()->getNode("modules/$moduleName/platform")) {
81
+ $platform = strtolower($platform);
82
+ $ignore_platform = false;
83
+ } else {
84
+ throw new Exception();
85
+ }
86
+ } catch (Exception $e) {
87
+ $platform = "ce";
88
+ $ignore_platform = true;
89
+ }
90
+ $platform = AW_All_Helper_Versions::convertPlatform($platform);
91
+
92
+ // Detect installed version
93
+ $ver = (Mage::getConfig()->getModuleConfig($moduleName)->version);
94
+ $isPlatformValid = $platform >= $this->getPlatform();
95
+ $feedInfo = $this->getExtensionInfo($moduleName);
96
+
97
+ $upgradeAvailable = ($this->_convertVersion($feedInfo->getLatestVersion()) - $this->_convertVersion($ver)) > 0;
98
+
99
+ $extensions[] = new Varien_Object(array(
100
+ 'version' => $ver,
101
+ 'name' => $moduleName,
102
+ 'is_platform_valid' => $isPlatformValid,
103
+ 'platform' => $platform,
104
+ 'feed_info' => $feedInfo,
105
+ 'upgrade_available' => $upgradeAvailable
106
+ ));
107
+ }
108
+ return $extensions;
109
+ }
110
+
111
+ /**
112
+ * Convert version to comparable integer
113
+ * @param $v
114
+ * @return int
115
+ */
116
+ protected function _convertVersion($v)
117
+ {
118
+ $digits = @explode(".", $v);
119
+ $version = 0;
120
+ if (is_array($digits)) {
121
+ foreach ($digits as $k => $v) {
122
+ $version += ($v * pow(10, max(0, (3 - $k))));
123
+ }
124
+ }
125
+ return $version;
126
+ }
127
+
128
+
129
+ /**
130
+ * Get extension info from cached feed
131
+ * @param $moduleName
132
+ * @return bool|Varien_Object
133
+ */
134
+ public function getExtensionInfo($moduleName)
135
+ {
136
+ if (!sizeof($this->_extensions_cache)) {
137
+ if ($displayNames = Mage::app()->loadCache('aw_all_extensions_feed')) {
138
+ $this->_extensions_cache = @unserialize($displayNames);
139
+ }
140
+ }
141
+ if (array_key_exists($moduleName, $this->_extensions_cache)) {
142
+ $data = array(
143
+ 'url' => @$this->_extensions_cache[$moduleName]['url'],
144
+ 'display_name' => @$this->_extensions_cache[$moduleName]['display_name'],
145
+ 'latest_version' => @$this->_extensions_cache[$moduleName]['version']
146
+ );
147
+ return new Varien_Object($data);
148
+ }
149
+ return new Varien_Object();
150
+ }
151
+
152
+ /**
153
+ * Return icon for installed extension
154
+ * @param $Extension
155
+ * @return Varien_Object
156
+ */
157
+ public function getIcon($Extension)
158
+ {
159
+ if ($Extension->getUpgradeAvailable()) {
160
+ $icon = 'aw_all/images/update.gif';
161
+ $title = "Update available";
162
+ } elseif (!$Extension->getIsPlatformValid()) {
163
+ $icon = 'aw_all/images/bad.gif';
164
+ $title = "Wrong Extension Platform";
165
+ } else {
166
+ $icon = 'aw_all/images/ok.gif';
167
+ $title = "Installed and up to date";
168
+ }
169
+ return new Varien_Object(array('title' => $title, 'source' => $this->getSkinUrl($icon)));
170
+ }
171
+
172
+ /**
173
+ * Fetch store data and return as Varien Object
174
+ * @return Varien_Object
175
+ */
176
+ protected function _getStoreData()
177
+ {
178
+ if (!is_null($this->_store_data))
179
+ return $this->_store_data;
180
+ $storeData = array();
181
+ $connection = $this->_getStoreConnection();
182
+ $storeResponse = $connection->read();
183
+
184
+ if ($storeResponse !== false) {
185
+ $storeResponse = preg_split('/^\r?$/m', $storeResponse, 2);
186
+ $storeResponse = trim($storeResponse[1]);
187
+ Mage::app()->saveCache($storeResponse, AW_All_Helper_Config::STORE_RESPONSE_CACHE_KEY);
188
+ }
189
+ else {
190
+ $storeResponse = Mage::app()->loadCache(AW_All_Helper_Config::STORE_RESPONSE_CACHE_KEY);
191
+ if (!$storeResponse) {
192
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Sorry, but Extensions Store is not available now. Please try again in a few minutes.'));
193
+ }
194
+ }
195
+
196
+ $connection->close();
197
+ $this->_store_data = new Varien_Object(array('text_response' => $storeResponse));
198
+ return $this->_store_data;
199
+ }
200
+
201
+ /**
202
+ * Returns URL to store
203
+ * @return Varien_Http_Adapter_Curl
204
+ */
205
+ protected function _getStoreConnection()
206
+ {
207
+ $params = array(
208
+
209
+ );
210
+ $url = array();
211
+ foreach ($params as $k => $v) {
212
+ $url[] = urlencode($k) . "=" . urlencode($v);
213
+ }
214
+ $url = rtrim(AW_All_Helper_Config::STORE_URL) . (sizeof($url) ? ("?" . implode("&", $url)) : "");
215
+
216
+ $curl = new Varien_Http_Adapter_Curl();
217
+ $curl->setConfig(array(
218
+ 'timeout' => 5
219
+ ));
220
+ $curl->write(Zend_Http_Client::GET, $url, '1.0');
221
+
222
+ return $curl;
223
+ }
224
+
225
+
226
+ }
227
+
app/code/local/AW/All/Block/Notification/Window.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * aheadWorks Co.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://ecommerce.aheadworks.com/LICENSE-M1.txt
11
+ *
12
+ * @category AW
13
+ * @package AW_All
14
+ * @copyright Copyright (c) 2009-2010 aheadWorks Co. (http://www.aheadworks.com)
15
+ * @license http://ecommerce.aheadworks.com/LICENSE-M1.txt
16
+ */
17
+
18
+ class AW_All_Block_Notification_Window extends Mage_Adminhtml_Block_Notification_Window
19
+ {
20
+ protected function _construct()
21
+ {
22
+ parent::_construct();
23
+
24
+ if (!Mage::getStoreConfig('awall/install/run')) {
25
+ $c = Mage::getModel('core/config_data');
26
+ $c
27
+ ->setScope('default')
28
+ ->setPath('awall/install/run')
29
+ ->setValue(time())
30
+ ->save();
31
+ $this->setHeaderText($this->__("aheadWorks Notifications Setup"));
32
+ $this->setIsFirstRun(1);
33
+ $this->setIsHtml(1);
34
+
35
+ }
36
+ }
37
+
38
+ protected function _toHtml()
39
+ {
40
+ if ($this->getIsHtml()) {
41
+ $this->setTemplate('aw_all/notification/window.phtml');
42
+ }
43
+ return parent::_toHtml();
44
+ }
45
+
46
+ public function presetFirstSetup()
47
+ {
48
+
49
+ }
50
+
51
+ public function getNoticeMessageText()
52
+ {
53
+ if ($this->getIsFirstRun()) {
54
+ $child = $this->getLayout()->createBlock('core/template')->setTemplate('aw_all/notification/window/first-run.phtml')->toHtml();
55
+ return $child;
56
+ } else {
57
+ return $this->getData('notice_message_text');
58
+ }
59
+ }
60
+
61
+
62
+ }
app/code/local/AW/All/Block/System/Config/Form/Fieldset/Awall/Extensions.php ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * aheadWorks Co.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://ecommerce.aheadworks.com/LICENSE-M1.txt
11
+ *
12
+ * @category AW
13
+ * @package AW_All
14
+ * @copyright Copyright (c) 2009-2010 aheadWorks Co. (http://www.aheadworks.com)
15
+ * @license http://ecommerce.aheadworks.com/LICENSE-M1.txt
16
+ */
17
+
18
+
19
+ class AW_All_Block_System_Config_Form_Fieldset_Awall_Extensions extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
20
+ {
21
+
22
+ protected $_dummyElement;
23
+ protected $_fieldRenderer;
24
+ protected $_values;
25
+
26
+ public function render(Varien_Data_Form_Element_Abstract $element)
27
+ {
28
+ $html = $this->_getHeaderHtml($element);
29
+ /*$modules = array_keys((array)Mage::getConfig()->getNode('modules')->children());
30
+ sort($modules);
31
+
32
+ foreach ($modules as $moduleName) {
33
+ if (strstr($moduleName,'AW_') === false) {
34
+ continue;
35
+ }
36
+
37
+ if($moduleName == 'AW_Core' || $moduleName == 'AW_All'){
38
+ continue;
39
+ }
40
+
41
+ $html.= $this->_getFieldHtml($element, $moduleName);
42
+ }*/
43
+ $html .= $this->_getFooterHtml($element);
44
+
45
+ return $html;
46
+ }
47
+
48
+ /**
49
+ * @deprecated
50
+ * @return
51
+ */
52
+ protected function _getDummyElement()
53
+ {
54
+ if (empty($this->_dummyElement)) {
55
+ $this->_dummyElement = new Varien_Object(array('show_in_default' => 1, 'show_in_website' => 1));
56
+ }
57
+ return $this->_dummyElement;
58
+ }
59
+
60
+ /**
61
+ * @deprecated
62
+ * @return
63
+ */
64
+ protected function _getFieldRenderer()
65
+ {
66
+ if (empty($this->_fieldRenderer)) {
67
+ $this->_fieldRenderer = Mage::getBlockSingleton('adminhtml/system_config_form_field');
68
+ }
69
+ return $this->_fieldRenderer;
70
+ }
71
+
72
+ /**
73
+ * @deprecated
74
+ * @throws Exception
75
+ * @param $fieldset
76
+ * @param $moduleName
77
+ * @return string
78
+ */
79
+ protected function _getFieldHtml($fieldset, $moduleName)
80
+ {
81
+
82
+
83
+ $configData = $this->getConfigData();
84
+
85
+ try {
86
+ if ($platform = Mage::getConfig()->getNode("modules/$moduleName/platform")) {
87
+ $platform = strtolower($platform);
88
+ $ignore_platform = false;
89
+ } else {
90
+ throw new Exception();
91
+ }
92
+ } catch (Exception $e) {
93
+ $platform = "ce";
94
+ $ignore_platform = true;
95
+ }
96
+
97
+
98
+ $path = 'advanced/modules_disable_output/' . $moduleName; //TODO: move as property of form
99
+ $data = isset($configData[$path]) ? $configData[$path] : array();
100
+
101
+ $e = $this->_getDummyElement();
102
+
103
+ $moduleKey = substr($moduleName, strpos($moduleName, '_') + 1);
104
+ $ver = (Mage::getConfig()->getModuleConfig($moduleName)->version);
105
+ $id = $moduleName;
106
+
107
+ $warning = "";
108
+ if (!$ignore_platform) {
109
+ $magentoVersion = $this->_convertVersion(Mage::getVersion());
110
+
111
+ if ($magentoVersion >= $this->_convertVersion(AW_All_Helper_Config::ENTERPRISE_VERSION)) {
112
+ // EE
113
+ if ($platform == 'ce' || $platform == 'pe') {
114
+ $warning = $this->__("This extension can't be run under Magento Enterprise platform. You need Enterprise version of the extension.");
115
+ }
116
+
117
+ } elseif ($magentoVersion >= $this->_convertVersion(AW_All_Helper_Config::PROFESSIONAL_EDITION)) {
118
+ // PE
119
+ if ($platform == 'ce') {
120
+ $warning = $this->__("This extension can't be run under Magento Professional platform. You need Professional version of the extension.");
121
+ }
122
+ } else {
123
+ // CE
124
+ }
125
+ }
126
+
127
+
128
+ $hasUpdate = false;
129
+ if ($displayNames = Mage::app()->loadCache('aw_all_extensions_feed')) {
130
+ if ($displayNames = unserialize($displayNames)) {
131
+ if (isset($displayNames[$moduleName])) {
132
+ $url = @$displayNames[$moduleName]['url'];
133
+ $name = @$displayNames[$moduleName]['display_name'];
134
+ $version = @$displayNames[$moduleName]['version'];
135
+
136
+ $moduleName = '<a href="' . $url . '" target="_blank" title="' . $name . '">' . $name . "</a>";
137
+
138
+ if ($warning) {
139
+ $update = '<a target="_blank"><img src="' . $this->getSkinUrl('aw_all/images/bad.gif') . '" title="' . $this->__("Wrong Extension Platform") . '"/></a>';
140
+ $moduleName = "$update $moduleName";
141
+ } else {
142
+
143
+ if ($this->_convertVersion($ver) < $this->_convertVersion($version)) {
144
+ $update = '<a href="' . $url . '" target="_blank"><img src="' . $this->getSkinUrl('aw_all/images/update.gif') . '" title="' . $this->__("Update available") . '"/></a>';
145
+ $hasUpdate = 1;
146
+ $moduleName = "$update $moduleName";
147
+ }
148
+ }
149
+ }
150
+ }
151
+ }
152
+
153
+ if (!$hasUpdate && !$warning) {
154
+ $update = '<a target="_blank"><img src="' . $this->getSkinUrl('aw_all/images/ok.gif') . '" title="' . $this->__("Installed") . '"/></a>';
155
+ $moduleName = "$update $moduleName";
156
+ } elseif ($warning && (!@$displayNames || !@$name)) {
157
+ $update = '<a target="_blank"><img src="' . $this->getSkinUrl('aw_all/images/bad.gif') . '" title="' . $this->__("Wrong Extension Platform") . '"/></a>';
158
+ $moduleName = "$update $moduleName";
159
+ }
160
+
161
+
162
+ if ($ver) {
163
+ $field = $fieldset->addField($id, 'label',
164
+ array(
165
+ 'name' => 'ssssss',
166
+ 'label' => $moduleName,
167
+ 'value' => $warning ? $warning : $ver,
168
+
169
+ ))->setRenderer($this->_getFieldRenderer());
170
+ return $field->toHtml();
171
+ }
172
+ return '';
173
+
174
+ }
175
+
176
+
177
+ /**
178
+ * @deprecated
179
+ * @param $v
180
+ * @return int
181
+ */
182
+ protected function _convertVersion($v)
183
+ {
184
+ $digits = @explode(".", $v);
185
+ $version = 0;
186
+ if (is_array($digits)) {
187
+ foreach ($digits as $k => $v) {
188
+ $version += ($v * pow(10, max(0, (3 - $k))));
189
+ }
190
+
191
+ }
192
+ return $version;
193
+ }
194
+ }
app/code/local/AW/All/Block/System/Config/Form/Fieldset/Awall/Store.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * aheadWorks Co.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://ecommerce.aheadworks.com/LICENSE-M1.txt
11
+ *
12
+ * @category AW
13
+ * @package AW_All
14
+ * @copyright Copyright (c) 2009-2010 aheadWorks Co. (http://www.aheadworks.com)
15
+ * @license http://ecommerce.aheadworks.com/LICENSE-M1.txt
16
+ */
17
+
18
+
19
+ class AW_All_Block_System_Config_Form_Fieldset_Awall_Store extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
20
+ {
21
+
22
+ protected $_dummyElement;
23
+ protected $_fieldRenderer;
24
+ protected $_values;
25
+
26
+ public function render(Varien_Data_Form_Element_Abstract $element)
27
+ {
28
+ return '<div id="' . $element->getId() . '"></div>';
29
+ return $html;
30
+ }
31
+
32
+
33
+ }
app/code/local/AW/All/Helper/Config.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * aheadWorks Co.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://ecommerce.aheadworks.com/LICENSE-M1.txt
11
+ *
12
+ * @category AW
13
+ * @package AW_All
14
+ * @copyright Copyright (c) 2009-2010 aheadWorks Co. (http://www.aheadworks.com)
15
+ * @license http://ecommerce.aheadworks.com/LICENSE-M1.txt
16
+ */
17
+
18
+ class AW_All_Helper_Config extends Mage_Core_Helper_Abstract
19
+ {
20
+ /** Extensions feed path */
21
+ const EXTENSIONS_FEED_URL = 'http://media.aheadworks.com/feeds/extensions.xml';
22
+ /** Updates Feed path */
23
+ const UPDATES_FEED_URL = 'http://media.aheadworks.com/feeds/updates.xml';
24
+ /** Estore URL */
25
+ const STORE_URL = 'http://ecommerce.aheadworks.com/estore/';
26
+
27
+ /** EStore response cache key*/
28
+ const STORE_RESPONSE_CACHE_KEY = 'aw_all_store_response_cache_key';
29
+
30
+
31
+ }
app/code/local/AW/All/Helper/Data.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * aheadWorks Co.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://ecommerce.aheadworks.com/LICENSE-M1.txt
11
+ *
12
+ * @category AW
13
+ * @package AW_All
14
+ * @copyright Copyright (c) 2009-2010 aheadWorks Co. (http://www.aheadworks.com)
15
+ * @license http://ecommerce.aheadworks.com/LICENSE-M1.txt
16
+ */
17
+
18
+ class AW_All_Helper_Data extends Mage_Core_Helper_Abstract
19
+ {
20
+
21
+
22
+ }
23
+
24
+
app/code/local/AW/All/Helper/Versions.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * aheadWorks Co.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://ecommerce.aheadworks.com/LICENSE-M1.txt
11
+ *
12
+ * @category AW
13
+ * @package AW_All
14
+ * @copyright Copyright (c) 2009-2010 aheadWorks Co. (http://www.aheadworks.com)
15
+ * @license http://ecommerce.aheadworks.com/LICENSE-M1.txt
16
+ */
17
+
18
+ class AW_All_Helper_Versions extends Mage_Core_Helper_Abstract
19
+ {
20
+
21
+ const EE_PLATFORM = 100;
22
+ const PE_PLATFORM = 10;
23
+ const CE_PLATFORM = 0;
24
+
25
+ const ENTERPRISE_DETECT_COMPANY = 'Enterprise';
26
+ const ENTERPRISE_DETECT_EXTENSION = 'Enterprise';
27
+ const ENTERPRISE_DESIGN_NAME = "enterprise";
28
+ const PROFESSIONAL_DESIGN_NAME = "pro";
29
+
30
+ protected static $_platform = -1;
31
+
32
+ /**
33
+ * Checks which edition is used
34
+ * @return int
35
+ */
36
+ public static function getPlatform()
37
+ {
38
+ if (self::$_platform == -1) {
39
+ $pathToClaim = BP . DS . "app" . DS . "etc" . DS . "modules" . DS . self::ENTERPRISE_DETECT_COMPANY . "_" . self::ENTERPRISE_DETECT_EXTENSION . ".xml";
40
+ $pathToEEConfig = BP . DS . "app" . DS . "code" . DS . "core" . DS . self::ENTERPRISE_DETECT_COMPANY . DS . self::ENTERPRISE_DETECT_EXTENSION . DS . "etc" . DS . "config.xml";
41
+ $isCommunity = !file_exists($pathToClaim) || !file_exists($pathToEEConfig);
42
+ if ($isCommunity) {
43
+ self::$_platform = self::CE_PLATFORM;
44
+ } else {
45
+ $_xml = @simplexml_load_file($pathToEEConfig,'SimpleXMLElement', LIBXML_NOCDATA);
46
+ if(!$_xml===FALSE) {
47
+ $package = (string)$_xml->default->design->package->name;
48
+ $theme = (string)$_xml->install->design->theme->default;
49
+ $skin = (string)$_xml->stores->admin->design->theme->skin;
50
+ $isProffessional = ($package == self::PROFESSIONAL_DESIGN_NAME) && ($theme == self::PROFESSIONAL_DESIGN_NAME) && ($skin == self::PROFESSIONAL_DESIGN_NAME);
51
+ if ($isProffessional) {
52
+ self::$_platform = self::PE_PLATFORM;
53
+ return self::$_platform;
54
+ }
55
+ }
56
+ self::$_platform = self::EE_PLATFORM;
57
+ }
58
+ }
59
+ return self::$_platform;
60
+ }
61
+
62
+ /**
63
+ * Convert platform from string to int and backwards
64
+ * @static
65
+ * @param $platformCode
66
+ * @return int|string
67
+ */
68
+ public static function convertPlatform($platformCode)
69
+ {
70
+ if (is_numeric($platformCode)) {
71
+ // Convert predefined to letters code
72
+ $platform = ($platformCode == self::EE_PLATFORM ? 'ee' : ($platformCode == self::PE_PLATFORM ? 'pe'
73
+ : 'ce'));
74
+ } elseif (is_string($platformCode)) {
75
+ $platformCode = strtolower($platformCode);
76
+ $platform = ($platformCode == 'ee' ? self::EE_PLATFORM : ($platformCode == 'pe' ? self::PE_PLATFORM
77
+ : self::CE_PLATFORM));
78
+ }else{$platform = self::CE_PLATFORM;}
79
+ return $platform;
80
+ }
81
+
82
+ public static function convertVersion($v)
83
+ {
84
+ $digits = @explode(".", $v);
85
+ $version = 0;
86
+ if (is_array($digits)) {
87
+ foreach ($digits as $k => $v) {
88
+ $version += ($v * pow(10, max(0, (3 - $k))));
89
+ }
90
+
91
+ }
92
+ return $version;
93
+ }
94
+ }
app/code/local/AW/All/Model/Feed.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * aheadWorks Co.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://ecommerce.aheadworks.com/LICENSE-M1.txt
11
+ *
12
+ * @category AW
13
+ * @package AW_All
14
+ * @copyright Copyright (c) 2009-2010 aheadWorks Co. (http://www.aheadworks.com)
15
+ * @license http://ecommerce.aheadworks.com/LICENSE-M1.txt
16
+ */
17
+
18
+ class AW_All_Model_Feed extends Mage_AdminNotification_Model_Feed
19
+ {
20
+ const XML_USE_HTTPS_PATH = 'awall/feed/use_https';
21
+ const XML_FEED_URL_PATH = 'awall/feed/url';
22
+ const XML_FREQUENCY_PATH = 'awall/feed/check_frequency';
23
+ const XML_FREQUENCY_ENABLE = 'awall/feed/enabled';
24
+ const XML_LAST_UPDATE_PATH = 'awall/feed/last_update';
25
+
26
+
27
+ public static function check()
28
+ {
29
+ if (!Mage::getStoreConfig(self::XML_FREQUENCY_ENABLE)) {
30
+ return;
31
+ }
32
+ return Mage::getModel('awall/feed')->checkUpdate();
33
+ }
34
+
35
+ public function getFrequency()
36
+ {
37
+ return Mage::getStoreConfig(self::XML_FREQUENCY_PATH) * 3600;
38
+ }
39
+
40
+ public function getLastUpdate()
41
+ {
42
+ //return 100;
43
+ return Mage::app()->loadCache('awall_notifications_lastcheck');
44
+ }
45
+
46
+ public function setLastUpdate()
47
+ {
48
+ Mage::app()->saveCache(time(), 'awall_notifications_lastcheck');
49
+ return $this;
50
+ }
51
+
52
+ public function getFeedUrl()
53
+ {
54
+ if (is_null($this->_feedUrl)) {
55
+ $this->_feedUrl = (Mage::getStoreConfigFlag(self::XML_USE_HTTPS_PATH) ? 'https://' : 'http://')
56
+ . Mage::getStoreConfig(self::XML_FEED_URL_PATH);
57
+ }
58
+ return $this->_feedUrl;
59
+ }
60
+
61
+ public function checkUpdate()
62
+ {
63
+ if (($this->getFrequency() + $this->getLastUpdate()) > time()) {
64
+ return $this;
65
+ }
66
+
67
+ $feedData = array();
68
+
69
+ $feedXml = $this->getFeedData();
70
+
71
+ if ($feedXml && $feedXml->channel && $feedXml->channel->item) {
72
+ foreach ($feedXml->channel->item as $item) {
73
+ $feedData[] = array(
74
+ 'severity' => (int)$item->severity ? (int)$item->severity : 3,
75
+ 'date_added' => $this->getDate((string)$item->pubDate),
76
+ 'title' => (string)$item->title,
77
+ 'description' => (string)$item->description,
78
+ 'url' => (string)$item->link,
79
+ );
80
+ }
81
+ if ($feedData) {
82
+ Mage::getModel('adminnotification/inbox')->parse(array_reverse($feedData));
83
+ }
84
+
85
+ }
86
+ $this->setLastUpdate();
87
+
88
+ return $this;
89
+ }
90
+
91
+ }
app/code/local/AW/All/Model/Feed/Abstract.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * aheadWorks Co.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://ecommerce.aheadworks.com/LICENSE-M1.txt
11
+ *
12
+ * @category AW
13
+ * @package AW_All
14
+ * @copyright Copyright (c) 2009-2010 aheadWorks Co. (http://www.aheadworks.com)
15
+ * @license http://ecommerce.aheadworks.com/LICENSE-M1.txt
16
+ */
17
+
18
+ class AW_All_Model_Feed_Abstract extends Mage_Core_Model_Abstract
19
+ {
20
+
21
+ /**
22
+ * Retrieve feed data as XML element
23
+ *
24
+ * @return SimpleXMLElement
25
+ */
26
+ public function getFeedData()
27
+ {
28
+ $curl = new Varien_Http_Adapter_Curl();
29
+ $curl->setConfig(array(
30
+ 'timeout' => 1
31
+ ));
32
+ $curl->write(Zend_Http_Client::GET, $this->getFeedUrl(), '1.0');
33
+ $data = $curl->read();
34
+ if ($data === false) {
35
+ return false;
36
+ }
37
+ $data = preg_split('/^\r?$/m', $data, 2);
38
+ $data = trim($data[1]);
39
+ $curl->close();
40
+
41
+ try {
42
+ $xml = new SimpleXMLElement($data);
43
+ }
44
+ catch (Exception $e) {
45
+ return false;
46
+ }
47
+
48
+ return $xml;
49
+ }
50
+
51
+
52
+ /**
53
+ * Retrieve DB date from RSS date
54
+ *
55
+ * @param string $rssDate
56
+ * @return string YYYY-MM-DD YY:HH:SS
57
+ */
58
+ public function getDate($rssDate)
59
+ {
60
+ return gmdate('Y-m-d H:i:s', strtotime($rssDate));
61
+ }
62
+
63
+
64
+ }
app/code/local/AW/All/Model/Feed/Extensions.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * aheadWorks Co.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://ecommerce.aheadworks.com/LICENSE-M1.txt
11
+ *
12
+ * @category AW
13
+ * @package AW_All
14
+ * @copyright Copyright (c) 2009-2010 aheadWorks Co. (http://www.aheadworks.com)
15
+ * @license http://ecommerce.aheadworks.com/LICENSE-M1.txt
16
+ */
17
+
18
+ class AW_All_Model_Feed_Extensions extends AW_All_Model_Feed_Abstract
19
+ {
20
+
21
+ /**
22
+ * Retrieve feed url
23
+ *
24
+ * @return string
25
+ */
26
+ public function getFeedUrl()
27
+ {
28
+ return AW_All_Helper_Config::EXTENSIONS_FEED_URL;
29
+ }
30
+
31
+
32
+ /**
33
+ * Checks feed
34
+ * @return
35
+ */
36
+ public function check()
37
+ {
38
+ if (!(Mage::app()->loadCache('aw_all_extensions_feed')) || (time() - Mage::app()->loadCache('aw_all_extensions_feed_lastcheck')) > Mage::getStoreConfig('awall/feed/check_frequency')) {
39
+ $this->refresh();
40
+ }
41
+ }
42
+
43
+ public function refresh()
44
+ {
45
+ $exts = array();
46
+ try {
47
+ $Node = $this->getFeedData();
48
+ if (!$Node) return false;
49
+ foreach ($Node->children() as $ext) {
50
+ $exts[(string)$ext->name] = array(
51
+ 'display_name' => (string)$ext->display_name,
52
+ 'version' => (string)$ext->version,
53
+ 'url' => (string)$ext->url
54
+ );
55
+ }
56
+
57
+ Mage::app()->saveCache(serialize($exts), 'aw_all_extensions_feed');
58
+ Mage::app()->saveCache(time(), 'aw_all_extensions_feed_lastcheck');
59
+ return true;
60
+ } catch (Exception $E) {
61
+ return false;
62
+ }
63
+ }
64
+
65
+ public function checkExtensions()
66
+ {
67
+ $modules = array_keys((array)Mage::getConfig()->getNode('modules')->children());
68
+ sort($modules);
69
+
70
+ $magentoPlatform = AW_All_Helper_Versions::getPlatform();
71
+ foreach ($modules as $extensionName) {
72
+ if (strstr($extensionName, 'AW_') === false) {
73
+ continue;
74
+ }
75
+ if ($extensionName == 'AW_Core' || $extensionName == 'AW_All') {
76
+ continue;
77
+ }
78
+ if ($platformNode = $this->getExtensionPlatform($extensionName)) {
79
+ $extensionPlatform = AW_All_Helper_Versions::convertPlatform($platformNode);
80
+ if ($extensionPlatform < $magentoPlatform) {
81
+ $this->disableExtensionOutput($extensionName);
82
+ }
83
+ }
84
+ }
85
+ return $this;
86
+ }
87
+
88
+ public function getExtensionPlatform($extensionName)
89
+ {
90
+ try {
91
+ if ($platform = Mage::getConfig()->getNode("modules/$extensionName/platform")) {
92
+ $platform = strtolower($platform);
93
+ return $platform;
94
+ } else {
95
+ throw new Exception();
96
+ }
97
+ } catch (Exception $e) {
98
+ return false;
99
+ }
100
+ }
101
+
102
+
103
+ public function disableExtensionOutput($extensionName)
104
+ {
105
+ $coll = Mage::getModel('core/config_data')->getCollection();
106
+ $coll->getSelect()->where("path='advanced/modules_disable_output/$extensionName'");
107
+ $i = 0;
108
+ foreach ($coll as $cd) {
109
+ $i++;
110
+ $cd->setValue(1)->save();
111
+ }
112
+ if ($i == 0) {
113
+ Mage::getModel('core/config_data')
114
+ ->setPath("advanced/modules_disable_output/$extensionName")
115
+ ->setValue(1)
116
+ ->save();
117
+ }
118
+ return $this;
119
+ }
120
+
121
+
122
+ }
app/code/local/AW/All/Model/Feed/Updates.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * aheadWorks Co.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://ecommerce.aheadworks.com/LICENSE-M1.txt
11
+ *
12
+ * @category AW
13
+ * @package AW_All
14
+ * @copyright Copyright (c) 2009-2010 aheadWorks Co. (http://www.aheadworks.com)
15
+ * @license http://ecommerce.aheadworks.com/LICENSE-M1.txt
16
+ */
17
+
18
+ class AW_All_Model_Feed_Updates extends AW_All_Model_Feed_Abstract
19
+ {
20
+
21
+ /**
22
+ * Retrieve feed url
23
+ *
24
+ * @return string
25
+ */
26
+ public function getFeedUrl()
27
+ {
28
+ return AW_All_Helper_Config::UPDATES_FEED_URL;
29
+ }
30
+
31
+ /**
32
+ * Checks feed
33
+ * @return
34
+ */
35
+ public function check()
36
+ {
37
+ if ((time() - Mage::app()->loadCache('aw_all_updates_feed_lastcheck')) > Mage::getStoreConfig('awall/feed/check_frequency')) {
38
+ $this->refresh();
39
+ }
40
+ }
41
+
42
+ public function refresh()
43
+ {
44
+ $feedData = array();
45
+
46
+ try {
47
+
48
+ $Node = $this->getFeedData();
49
+ if (!$Node) return false;
50
+ foreach ($Node->children() as $item) {
51
+
52
+ if ($this->isInteresting($item)) {
53
+ $date = strtotime((string)$item->date);
54
+ if (!Mage::getStoreConfig('awall/install/run') || (Mage::getStoreConfig('awall/install/run') < $date)) {
55
+ $feedData[] = array(
56
+ 'severity' => 3,
57
+ 'date_added' => $this->getDate((string)$item->date),
58
+ 'title' => (string)$item->title,
59
+ 'description' => (string)$item->content,
60
+ 'url' => (string)$item->url,
61
+ );
62
+ }
63
+ }
64
+ }
65
+
66
+ $adminnotificationModel = Mage::getModel('adminnotification/inbox');
67
+ if ($feedData && is_object($adminnotificationModel)) {
68
+ $adminnotificationModel->parse(($feedData));
69
+ }
70
+
71
+ Mage::app()->saveCache(time(), 'aw_all_updates_feed_lastcheck');
72
+ return true;
73
+ } catch (Exception $E) {
74
+ return false;
75
+ }
76
+ }
77
+
78
+
79
+ public function getInterests()
80
+ {
81
+ if (!$this->getData('interests')) {
82
+ $types = @explode(',', Mage::getStoreConfig('awall/feed/interests'));
83
+ $this->setData('interests', $types);
84
+ }
85
+ return $this->getData('interests');
86
+ }
87
+
88
+ /**
89
+ *
90
+ * @return
91
+ */
92
+ public function isInteresting($item)
93
+ {
94
+ $interests = $this->getInterests();
95
+
96
+ $types = @explode(",", (string)$item->type);
97
+ $exts = @explode(",", (string)$item->extensions);
98
+
99
+ $isInterestedInSelfUpgrades = array_search(AW_All_Model_Source_Updates_Type::TYPE_INSTALLED_UPDATE, $types);
100
+
101
+ foreach ($types as $type) {
102
+
103
+ if (array_search($type, $interests) !== false) {
104
+ return true;
105
+ }
106
+ if (($type == AW_All_Model_Source_Updates_Type::TYPE_UPDATE_RELEASE) && $isInterestedInSelfUpgrades) {
107
+ foreach ($exts as $ext) {
108
+ if ($this->isExtensionInstalled($ext)) {
109
+ return true;
110
+ }
111
+ }
112
+ }
113
+ }
114
+ return false;
115
+ }
116
+
117
+ public function isExtensionInstalled($code)
118
+ {
119
+ $modules = array_keys((array)Mage::getConfig()->getNode('modules')->children());
120
+
121
+ foreach ($modules as $moduleName) {
122
+ if ($moduleName == $code) {
123
+ return true;
124
+ }
125
+ }
126
+ return false;
127
+ }
128
+
129
+ }
app/code/local/AW/All/Model/Source/Updates/Type.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * aheadWorks Co.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://ecommerce.aheadworks.com/LICENSE-M1.txt
11
+ *
12
+ * @category AW
13
+ * @package AW_All
14
+ * @version 1.0
15
+ * @copyright Copyright (c) 2009-2010 aheadWorks Co. (http://www.aheadworks.com)
16
+ * @license http://ecommerce.aheadworks.com/LICENSE-M1.txt
17
+ */
18
+
19
+ class AW_All_Model_Source_Updates_Type extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
20
+ {
21
+
22
+ const TYPE_PROMO = 'PROMO';
23
+ const TYPE_NEW_RELEASE = 'NEW_RELEASE';
24
+ const TYPE_UPDATE_RELEASE = 'UPDATE_RELEASE';
25
+ const TYPE_INFO = 'INFO';
26
+ const TYPE_INSTALLED_UPDATE = 'INSTALLED_UPDATE';
27
+
28
+
29
+ public function toOptionArray()
30
+ {
31
+ return array(
32
+ array('value' => self::TYPE_INSTALLED_UPDATE, 'label' => Mage::helper('awall')->__('My extensions updates')),
33
+ array('value' => self::TYPE_UPDATE_RELEASE, 'label' => Mage::helper('awall')->__('All extensions updates')),
34
+ array('value' => self::TYPE_NEW_RELEASE, 'label' => Mage::helper('awall')->__('New Releases')),
35
+ array('value' => self::TYPE_PROMO, 'label' => Mage::helper('awall')->__('Promotions/Discounts')),
36
+ array('value' => self::TYPE_INFO, 'label' => Mage::helper('awall')->__('Other information'))
37
+ );
38
+ }
39
+
40
+ /**
41
+ * Retrive all attribute options
42
+ *
43
+ * @return array
44
+ */
45
+ public function getAllOptions()
46
+ {
47
+ return $this->toOptionArray();
48
+ }
49
+
50
+
51
+ /**
52
+ * Returns label for value
53
+ * @param string $value
54
+ * @return string
55
+ */
56
+ public function getLabel($value)
57
+ {
58
+ $options = $this->toOptionArray();
59
+ foreach ($options as $v) {
60
+ if ($v['value'] == $value) {
61
+ return $v['label'];
62
+ }
63
+ }
64
+ return '';
65
+ }
66
+
67
+ /**
68
+ * Returns array ready for use by grid
69
+ * @return array
70
+ */
71
+ public function getGridOptions()
72
+ {
73
+ $items = $this->getAllOptions();
74
+ $out = array();
75
+ foreach ($items as $item) {
76
+ $out[$item['value']] = $item['label'];
77
+ }
78
+ return $out;
79
+ }
80
+ }
app/code/local/AW/All/etc/adminhtml.xml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <layout>
4
+ <updates>
5
+ <awall module="AW_All">
6
+ <file>aw_all.xml</file>
7
+ </awall>
8
+ </updates>
9
+ </layout>
10
+
11
+ <acl>
12
+ <resources>
13
+ <all>
14
+ <title>Allow Everything</title>
15
+ </all>
16
+ <admin>
17
+ <children>
18
+ <system>
19
+ <children>
20
+ <config>
21
+ <children>
22
+ <awall>
23
+ <title>aheadWorks - All</title>
24
+ </awall>
25
+ </children>
26
+ </config>
27
+ </children>
28
+ </system>
29
+ </children>
30
+ </admin>
31
+ </resources>
32
+ </acl>
33
+ <events>
34
+ <controller_action_predispatch>
35
+ <observers>
36
+ <awall_exts>
37
+ <type>singleton</type>
38
+ <class>awall/feed_extensions</class>
39
+ <method>check</method>
40
+ </awall_exts>
41
+ <awall_upds>
42
+ <type>singleton</type>
43
+ <class>awall/feed_updates</class>
44
+ <method>check</method>
45
+ </awall_upds>
46
+ </observers>
47
+ </controller_action_predispatch>
48
+ </events>
49
+ </config>
app/code/local/AW/All/etc/config.xml ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+
4
+ <config>
5
+ <modules>
6
+ <AW_All>
7
+ <version>2.2.1</version>
8
+ </AW_All>
9
+ </modules>
10
+
11
+ <global>
12
+ <blocks>
13
+ <awall>
14
+ <class>AW_All_Block</class>
15
+ </awall>
16
+ <adminhtml>
17
+ <rewrite>
18
+ <notification_window>AW_All_Block_Notification_Window</notification_window>
19
+ </rewrite>
20
+ </adminhtml>
21
+ </blocks>
22
+ <resources>
23
+ <awall_setup>
24
+ <setup>
25
+ <module>AW_All</module>
26
+ </setup>
27
+ <connection>
28
+ <use>core_setup</use>
29
+ </connection>
30
+ </awall_setup>
31
+ <awall_write>
32
+ <connection>
33
+ <use>core_write</use>
34
+ </connection>
35
+ </awall_write>
36
+ <awall_read>
37
+ <connection>
38
+ <use>core_read</use>
39
+ </connection>
40
+ </awall_read>
41
+ </resources>
42
+ <models>
43
+ <awall>
44
+ <class>AW_All_Model</class>
45
+ </awall>
46
+ </models>
47
+
48
+ <helpers>
49
+ <awall>
50
+ <class>AW_All_Helper</class>
51
+ </awall>
52
+ </helpers>
53
+ </global>
54
+
55
+ <adminhtml>
56
+ <layout>
57
+ <updates>
58
+ <awall module="AW_All">
59
+ <file>aw_all.xml</file>
60
+ </awall>
61
+ </updates>
62
+ </layout>
63
+
64
+ <acl>
65
+ <resources>
66
+ <all>
67
+ <title>Allow Everything</title>
68
+ </all>
69
+ <admin>
70
+ <children>
71
+ <system>
72
+ <children>
73
+ <config>
74
+ <children>
75
+ <awall>
76
+ <title>aheadWorks - All</title>
77
+ </awall>
78
+ <awstore>
79
+ <title>aheadWorks - Extensions Store</title>
80
+ </awstore>
81
+ </children>
82
+ </config>
83
+ </children>
84
+ </system>
85
+ </children>
86
+ </admin>
87
+ </resources>
88
+ </acl>
89
+ <events>
90
+ <controller_action_predispatch>
91
+ <observers>
92
+ <awall_exts>
93
+ <type>singleton</type>
94
+ <class>awall/feed_extensions</class>
95
+ <method>check</method>
96
+ </awall_exts>
97
+ <awall_check>
98
+ <type>singleton</type>
99
+ <class>awall/feed_extensions</class>
100
+ <method>checkExtensions</method>
101
+ </awall_check>
102
+ <awall_upds>
103
+ <type>singleton</type>
104
+ <class>awall/feed_updates</class>
105
+ <method>check</method>
106
+ </awall_upds>
107
+ </observers>
108
+ </controller_action_predispatch>
109
+ </events>
110
+ </adminhtml>
111
+ <default>
112
+ <awall>
113
+ <feed>
114
+ <url>ecommerce.aheadworks.com/blog/feed/?tag=feed&amp;community=1</url>
115
+ <use_https>0</use_https>
116
+ <check_frequency>86400</check_frequency>
117
+ <enabled>1</enabled>
118
+ <interests>INFO,PROMO,UPDATE_RELEASE,NEW_RELEASE,INSTALLED_UPDATE</interests>
119
+ </feed>
120
+ </awall>
121
+ </default>
122
+ </config>
app/code/local/AW/All/etc/system.xml ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <awall translate="label" module="awall">
5
+ <label>aheadWorks Extensions</label>
6
+ <sort_order>300</sort_order>
7
+ </awall>
8
+ </tabs>
9
+ <sections>
10
+ <awall translate="label" module="awall">
11
+ <label>Info</label>
12
+ <tab>awall</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>99999</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
+ <extensions translate="label">
20
+ <label>Installed aheadWorks Extensions</label>
21
+ <frontend_type>text</frontend_type>
22
+ <frontend_model>awall/system_config_form_fieldset_awall_extensions</frontend_model>
23
+ <sort_order>2</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ </extensions>
28
+ <feed>
29
+ <label>Notifications</label>
30
+ <frontend_type>text</frontend_type>
31
+ <sort_order>60</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ <fields>
36
+ <!--enabled translate="label">
37
+ <label>Enable </label>
38
+ <comment>Will check for aheadWorks extensions updates</comment>
39
+ <frontend_type>select</frontend_type>
40
+ <sort_order>90</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ <source_model>adminhtml/system_config_source_yesno</source_model>
45
+ </enabled-->
46
+ <interests translate="label">
47
+ <label>I'd like to be informed by aheadWorks about:</label>
48
+ <comment></comment>
49
+ <frontend_type>multiselect</frontend_type>
50
+ <sort_order>100</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
+ <can_be_empty>1</can_be_empty>
55
+ <source_model>awall/source_updates_type</source_model>
56
+ </interests>
57
+
58
+ </fields>
59
+ </feed>
60
+ </groups>
61
+ </awall>
62
+ <awstore>
63
+ <label>Store</label>
64
+ <tab>awall</tab>
65
+ <class>awall-section</class>
66
+ <frontend_type>text</frontend_type>
67
+ <sort_order>9999</sort_order>
68
+ <show_in_default>1</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>1</show_in_store>
71
+ <groups>
72
+ <extensions translate="label">
73
+ <label>aheadWorks Extensions Store</label>
74
+ <frontend_type>text</frontend_type>
75
+ <frontend_model>awall/system_config_form_fieldset_awall_store</frontend_model>
76
+ <sort_order>2</sort_order>
77
+ <show_in_default>1</show_in_default>
78
+ <show_in_website>1</show_in_website>
79
+ <show_in_store>1</show_in_store>
80
+ </extensions>
81
+ </groups>
82
+ </awstore>
83
+ </sections>
84
+ </config>
app/code/local/AW/Onpulse/Block/System/Config/Form/Fieldset/Onpulse/Settings.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AW_Onpulse_Block_System_Config_Form_Fieldset_Onpulse_Settings extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
4
+ {
5
+ public function render(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+ $html = $this->_getHeaderHtml($element);
8
+ $html .=$this->setTemplate('aw_onpulse/settings.phtml')->_toHtml();
9
+ $html .= $this->_getFooterHtml($element);
10
+ return $html;
11
+ }
12
+ }
app/code/local/AW/Onpulse/Helper/Data.php ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AW_Onpulse_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ const RECENT_ORDERS_COUNT = 5;
6
+ const PRECISION = 2;
7
+
8
+ public $dateTimeFormat = null;
9
+
10
+ public function getPriceFormat($data)
11
+ {
12
+ $data = number_format($data, self::PRECISION, '.', '');
13
+ return $data;
14
+ }
15
+
16
+ private $_countries = array();
17
+
18
+ private function _getItemOptions($item)
19
+ {
20
+ $result = array();
21
+ if ($options = $item->getProductOptions()) {
22
+ if (isset($options['options'])) {
23
+ $result = array_merge($result, $options['options']);
24
+ }
25
+ if (isset($options['additional_options'])) {
26
+ $result = array_merge($result, $options['additional_options']);
27
+ }
28
+ if (isset($options['attributes_info'])) {
29
+ $result = array_merge($result, $options['attributes_info']);
30
+ }
31
+ }
32
+ return $result;
33
+ }
34
+
35
+ private function _getAddresInfoArray($customer, $addresType = 'billing')
36
+ {
37
+
38
+ if ($customer->getData("default_{$addresType}")) {
39
+
40
+ //Prevent Notice if can't find country name by code
41
+ $country = $customer->getData("{$addresType}_country_id");
42
+ if (isset($this->_countries[$customer->getData("{$addresType}_country_id")])) {
43
+ $country = $this->_countries[$customer->getData("{$addresType}_country_id")];
44
+ }
45
+ return array(
46
+ 'first_name' => $customer->getData("{$addresType}_firstname"),
47
+ 'last_name' => $customer->getData("{$addresType}_lastname"),
48
+ 'postcode' => $customer->getData("{$addresType}_postcode"),
49
+ 'city' => $customer->getData("{$addresType}_city"),
50
+ 'street' => $customer->getData("{$addresType}_street"),
51
+ 'telephone' => $this->escapeHtml($customer->getData("{$addresType}_telephone")),
52
+ 'region' => $customer->getData("{$addresType}_region"),
53
+ 'country' => $country,
54
+ );
55
+ }
56
+ return array();
57
+ }
58
+
59
+ private function _getAddresInfoFromOrderToArray($order)
60
+ {
61
+ //Prevent Notice if can't find country name by code
62
+ $country = $order->getData("country_id");
63
+ if (isset($this->_countries[$order->getData("country_id")])) {
64
+ $country = $this->_countries[$order->getData("country_id")];
65
+ }
66
+ return array(
67
+ 'first_name' => $order->getData("firstname"),
68
+ 'last_name' => $order->getData("lastname"),
69
+ 'postcode' => $order->getData("postcode"),
70
+ 'city' => $order->getData("city"),
71
+ 'street' => $order->getData("street"),
72
+ 'telephone' => $this->escapeHtml($order->getData("telephone")),
73
+ 'region' => $order->getData("region"),
74
+ 'country' => $country,
75
+ );
76
+ }
77
+
78
+ private function _getCustomersRecentOrders($customer)
79
+ {
80
+ /** @var $orderCollection Mage_Sales_Model_Resource_Order_Collection */
81
+ $orderCollection = Mage::getModel('sales/order')->getCollection();
82
+ $orderCollection->addAddressFields()
83
+ ->addAttributeToFilter('customer_id', array('eq' => $customer->getId()))
84
+ ->addAttributeToSelect('*')
85
+ ->addOrder('entity_id', 'DESC')
86
+ ->setPageSize(self::RECENT_ORDERS_COUNT);
87
+ return $orderCollection;
88
+ }
89
+
90
+ private function _getProductsArrayFromOrder($order)
91
+ {
92
+ $products = array();
93
+
94
+ foreach ($order->getItemsCollection() as $item) {
95
+ $product = array();
96
+ if ($item->getParentItem()) continue;
97
+ if ($_options = $this->_getItemOptions($item)) {
98
+ foreach ($_options as $_option) {
99
+ $product['options'][$_option['label']] = $_option['value'];
100
+ }
101
+ }
102
+ $product['name'] = $this->escapeHtml($item->getName());
103
+ $product['price'] = $this->getPriceFormat($item->getBaseRowTotal());
104
+ $product['qty'] = round($item->getQtyOrdered(), self::PRECISION);
105
+ $products[] = $product;
106
+
107
+ }
108
+ return $products;
109
+ }
110
+
111
+ public function processOutput($data)
112
+ {
113
+ $this->dateTimeFormat = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
114
+ //var_dump($this->dateTimeFormat);die;
115
+ $clients = $data->getData('clients');
116
+ $orders = $data->getData('orders');
117
+ $dashboard = $data->getData('dashboard');
118
+ $processedClients = array();
119
+ $processedDashboardClients = array();
120
+ $processedOrders = array();
121
+ foreach (Mage::helper('directory')->getCountryCollection() as $country) {
122
+ $this->_countries[$country->getId()] = $country->getName();
123
+ }
124
+
125
+ if ($clients->getSize())
126
+ foreach ($clients as $customer) {
127
+ $processedClients[] = $this->processCustomerToArray($customer, true);
128
+
129
+ }
130
+
131
+ if($orders->getSize())
132
+ foreach($orders as $order) {
133
+ $processedOrders[] = $this->processOrderToArray($order);
134
+ }
135
+ //var_dump($processedOrders);
136
+ //die;
137
+
138
+ $processedDashboardClientsToday = array();
139
+ $processedDashboardClientsYesterday = array();
140
+ if ($dashboard['customers']['today_customers']['registered']->getSize()) {
141
+ foreach ($dashboard['customers']['today_customers']['registered'] as $customer) {
142
+ $processedDashboardClientsToday[] = $this->processCustomerToArray($customer, true);
143
+ }
144
+ }
145
+
146
+ if ($dashboard['customers']['yesterday_customers']['registered']->getSize()) {
147
+ foreach ($dashboard['customers']['yesterday_customers']['registered'] as $customer) {
148
+ $processedDashboardClientsYesterday[] = $this->processCustomerToArray($customer, true);
149
+ }
150
+ }
151
+ $dashboard['customers']['today_customers']['registered'] = count($processedDashboardClientsToday);
152
+ $dashboard['customers']['yesterday_customers']['registered'] = count($processedDashboardClientsYesterday);
153
+
154
+ return array(
155
+ 'connector_version' => (string)Mage::getConfig()->getNode()->modules->AW_Onpulse->version,
156
+ 'clients' => $processedClients,
157
+ 'orders' => $processedOrders,
158
+ 'dashboard' => $dashboard,
159
+ 'storename' => strip_tags(Mage::getStoreConfig('general/store_information/name')),
160
+ 'curSymbol' => Mage::app()->getLocale()->currency(Mage::app()->getStore()->getBaseCurrencyCode())->getSymbol(),
161
+ );
162
+ }
163
+
164
+
165
+ public function processOrderToArray($order)
166
+ {
167
+
168
+ $customer = '';
169
+ if ($order->getCustomerId()) {
170
+ $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
171
+ if ($customer)
172
+ $customer = $this->processCustomerToArray($customer);
173
+ }
174
+ if(!$order->getGiftCardsAmount()) {
175
+ $order->setGiftCardsAmount(0);
176
+ }
177
+
178
+ $orderInfo = array(
179
+ 'increment_id' => $order->getIncrementId(),
180
+ 'creation_date' => $order->getCreatedAtFormated($this->dateTimeFormat)->toString($this->dateTimeFormat),
181
+ 'customer_firstname' => $this->escapeHtml($order->getCustomerFirstname()),
182
+ 'customer_lastname' => $this->escapeHtml($order->getCustomerLastname()),
183
+ 'customer_email' => $order->getCustomerEmail(),
184
+ 'status_code' => $order->getStatus(),
185
+ 'status' => htmlspecialchars($order->getStatusLabel()),
186
+ 'subtotal' => $this->getPriceFormat($order->getBaseSubtotal()),
187
+ 'discount' => $this->getPriceFormat($order->getBaseDiscountAmount()),
188
+ 'grand_total' => $this->getPriceFormat($order->getBaseGrandTotal()),
189
+ 'shipping_amount' => $this->getPriceFormat($order->getBaseShippingAmount()),
190
+ 'tax' => $this->getPriceFormat($order->getBaseTaxAmount()),
191
+ 'gift_cards_amount' => $this->getPriceFormat($order->getGiftCardsAmount()),
192
+ 'currency' => Mage::app()->getLocale()->currency(Mage::app()->getStore()->getBaseCurrencyCode())->getSymbol(),
193
+
194
+ //-----------------------------------------------------
195
+ 'items' => $this->_getProductsArrayFromOrder($order),
196
+ 'customer' => $customer,
197
+ 'billing' => $this->_getAddresInfoFromOrderToArray($order->getBillingAddress()),
198
+ );
199
+
200
+ if (!$order->getIsVirtual()) {
201
+ $orderInfo['shipping'] = $this->_getAddresInfoFromOrderToArray($order->getShippingAddress());
202
+ }
203
+
204
+ return $orderInfo;
205
+ }
206
+
207
+
208
+ public function processCustomerToArray($customer, $additional = false)
209
+ {
210
+ $client = array();
211
+
212
+ $client['id'] = $customer->getId();
213
+ $client['first_name'] = $this->escapeHtml($customer->getFirstname());
214
+ $client['last_name'] = $this->escapeHtml($customer->getLastname());
215
+ $client['email'] = $customer->getEmail();
216
+ //$client['date_registered'] = $customer->getCreatedAt();
217
+ $client['date_registered'] = Mage::app()->getLocale()->date($customer->getCreatedAt())->toString($this->dateTimeFormat);
218
+
219
+ $client['country'] = '';
220
+ if ($customer->getData('billing_country_id')) {
221
+ $client['country'] = $this->_countries[$customer->getData('billing_country_id')];
222
+ }
223
+
224
+ $client['phone'] = '';
225
+ if ($customer->getData('billing_telephone')) {
226
+ $client['phone'] = $this->escapeHtml($customer->getData('billing_telephone'));
227
+ }
228
+
229
+ if ($additional) {
230
+ // Format billing address data
231
+ $client['billing'] = $this->_getAddresInfoArray($customer, 'billing');
232
+
233
+ // Format shipping address data
234
+ $client['shipping'] = $this->_getAddresInfoArray($customer, 'shipping');
235
+
236
+ $orders = $this->_getCustomersRecentOrders($customer);
237
+ $customerOrders = array();
238
+ if ($orders->getSize()) {
239
+ foreach ($orders as $order) {
240
+ $customerOrders[] = $this->processOrderToArray($order);
241
+ }
242
+ }
243
+ $client['orders'] = $customerOrders;
244
+ }
245
+ return $client;
246
+ }
247
+ }
app/code/local/AW/Onpulse/Helper/Data.php.orig ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AW_Onpulse_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ const RECENT_ORDERS_COUNT = 5;
6
+ const PRECISION = 2;
7
+
8
+ public $dateTimeFormat = null;
9
+
10
+ public function getPriceFormat($data){
11
+ $data = number_format($data, self::PRECISION,'.','');
12
+ return $data;
13
+ }
14
+
15
+ private $_countries = array();
16
+
17
+ private function _getItemOptions($item)
18
+ {
19
+ $result = array();
20
+ if ($options = $item->getProductOptions()) {
21
+ if (isset($options['options'])) {
22
+ $result = array_merge($result, $options['options']);
23
+ }
24
+ if (isset($options['additional_options'])) {
25
+ $result = array_merge($result, $options['additional_options']);
26
+ }
27
+ if (isset($options['attributes_info'])) {
28
+ $result = array_merge($result, $options['attributes_info']);
29
+ }
30
+ }
31
+ return $result;
32
+ }
33
+
34
+ private function _getAddresInfoArray($customer, $addresType = 'billing')
35
+ {
36
+
37
+ if ($customer->getData("default_{$addresType}")) {
38
+
39
+ //Prevent Notice if can't find country name by code
40
+ $country = $customer->getData("{$addresType}_country_id");
41
+ if(isset($this->_countries[$customer->getData("{$addresType}_country_id")])) {
42
+ $country = $this->_countries[$customer->getData("{$addresType}_country_id")];
43
+ }
44
+ return array(
45
+ 'first_name' => $customer->getData("{$addresType}_firstname"),
46
+ 'last_name' => $customer->getData("{$addresType}_lastname"),
47
+ 'postcode' => $customer->getData("{$addresType}_postcode"),
48
+ 'city' => $customer->getData("{$addresType}_city"),
49
+ 'street' => $customer->getData("{$addresType}_street"),
50
+ 'telephone' => $this->escapeHtml($customer->getData("{$addresType}_telephone")),
51
+ 'region' => $customer->getData("{$addresType}_region"),
52
+ 'country' => $country,
53
+ );
54
+ }
55
+ return array();
56
+ }
57
+
58
+ private function _getAddresInfoFromOrderToArray($order)
59
+ {
60
+ //Prevent Notice if can't find country name by code
61
+ $country = $order->getData("country_id");
62
+ if(isset($this->_countries[$order->getData("country_id")])) {
63
+ $country = $this->_countries[$order->getData("country_id")];
64
+ }
65
+ return array(
66
+ 'first_name' => $order->getData("firstname"),
67
+ 'last_name' => $order->getData("lastname"),
68
+ 'postcode' => $order->getData("postcode"),
69
+ 'city' => $order->getData("city"),
70
+ 'street' => $order->getData("street"),
71
+ 'telephone' => $this->escapeHtml($order->getData("telephone")),
72
+ 'region' => $order->getData("region"),
73
+ 'country' => $country,
74
+ );
75
+ }
76
+
77
+ private function _getCustomersRecentOrders($customer)
78
+ {
79
+ /** @var $orderCollection Mage_Sales_Model_Resource_Order_Collection */
80
+ $orderCollection = Mage::getModel('sales/order')->getCollection();
81
+ $orderCollection->addAddressFields()
82
+ ->addAttributeToFilter('customer_id', array('eq' => $customer->getId()))
83
+ ->addAttributeToSelect('*')
84
+ ->addOrder('entity_id', 'DESC')
85
+ ->setPageSize(self::RECENT_ORDERS_COUNT);
86
+ return $orderCollection;
87
+ }
88
+
89
+ private function _getProductsArrayFromOrder($order)
90
+ {
91
+ $products = array();
92
+
93
+ foreach($order->getItemsCollection() as $item) {
94
+ $product = array();
95
+ if ($item->getParentItem()) continue;
96
+ if($_options = $this->_getItemOptions($item)) {
97
+ foreach ($_options as $_option) {
98
+ $product['options'][$_option['label']] = $_option['value'];
99
+ }
100
+ }
101
+ $product['name'] = $this->escapeHtml($item->getName());
102
+ $product['price'] = $this->getPriceFormat($item->getBaseRowTotal());
103
+ $product['qty'] = round($item->getQtyOrdered(), self::PRECISION);
104
+ $products[] = $product;
105
+
106
+ }
107
+ return $products;
108
+ }
109
+
110
+ public function processOutput($data)
111
+ {
112
+ $this->dateTimeFormat = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
113
+ //var_dump($this->dateTimeFormat);die;
114
+ $clients = $data->getData('clients');
115
+ $orders = $data->getData('orders');
116
+ $dashboard = $data->getData('dashboard');
117
+ $processedClients = array();
118
+ $processedDashboardClients = array();
119
+ $processedOrders = array();
120
+ foreach (Mage::helper('directory')->getCountryCollection() as $country) {
121
+ $this->_countries[$country->getId()] = $country->getName();
122
+ }
123
+
124
+ if($clients->getSize())
125
+ foreach ($clients as $customer) {
126
+ $processedClients[] = $this->processCustomerToArray($customer, true);
127
+
128
+ }
129
+
130
+ if($orders->getSize())
131
+ foreach($orders as $order) {
132
+ $processedOrders[] = $this->processOrderToArray($order);
133
+ }
134
+ var_dump($processedOrders);
135
+ die;
136
+ if($dashboard['customers']['today_customers']['registered']->getSize()) {
137
+ foreach($dashboard['customers']['today_customers']['registered'] as $customer) {
138
+ $processedDashboardClientsToday[] = $this->processCustomerToArray($customer,true);
139
+ }
140
+ }
141
+
142
+ if($dashboard['customers']['yesterday_customers']['registered']->getSize()) {
143
+ foreach($dashboard['customers']['yesterday_customers']['registered'] as $customer) {
144
+ $processedDashboardClientsYesterday[] = $this->processCustomerToArray($customer,true);
145
+ }
146
+ }
147
+ $dashboard['customers']['today_customers']['registered'] = count($processedDashboardClientsToday);
148
+ $dashboard['customers']['yesterday_customers']['registered'] = count($processedDashboardClientsYesterday);
149
+
150
+ return array(
151
+ 'connector_version' => (string) Mage::getConfig()->getNode()->modules->AW_Onpulse->version,
152
+ 'clients' => $processedClients,
153
+ 'orders' => $processedOrders,
154
+ 'dashboard' => $dashboard,
155
+ 'storename' => strip_tags(Mage::getStoreConfig('general/store_information/name')),
156
+ 'curSymbol' => Mage::app()->getLocale()->currency(Mage::app()->getStore()->getBaseCurrencyCode())->getSymbol(),
157
+ );
158
+ }
159
+
160
+
161
+
162
+ public function processOrderToArray($order)
163
+ {
164
+
165
+ $customer = '';
166
+ if($order->getCustomerId()) {
167
+ $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
168
+ if($customer)
169
+ $customer = $this->processCustomerToArray($customer);
170
+ }
171
+
172
+ $orderInfo = array(
173
+ 'increment_id' => $order->getIncrementId(),
174
+ //'creation_date' => $order->getCreatedAt(),
175
+ 'creation_date' => $order->getCreatedAtFormated($this->dateTimeFormat)->toString($this->dateTimeFormat),
176
+ 'customer_firstname' => $this->escapeHtml($order->getCustomerFirstname()),
177
+ 'customer_lastname' => $this->escapeHtml($order->getCustomerLastname()),
178
+ 'customer_email' => $order->getCustomerEmail(),
179
+ 'status_code' => $order->getStatus(),
180
+ 'status' => htmlspecialchars($order->getStatusLabel()),
181
+ 'subtotal' => $this->getPriceFormat($order->getBaseSubtotal()),
182
+ 'discount' => $this->getPriceFormat($order->getBaseDiscountAmount()),
183
+ 'grand_total' => $this->getPriceFormat($order->getBaseGrandTotal()),
184
+ 'shipping_amount' => $this->getPriceFormat($order->getBaseShippingAmount()),
185
+ 'tax' => $this->getPriceFormat($order->getBaseTaxAmount()),
186
+ 'currency' => Mage::app()->getLocale()->currency(Mage::app()->getStore()->getBaseCurrencyCode())->getSymbol(),
187
+
188
+ //-----------------------------------------------------
189
+ 'items' => $this->_getProductsArrayFromOrder($order),
190
+ 'customer' => $customer,
191
+ 'billing' => $this->_getAddresInfoFromOrderToArray($order->getBillingAddress()),
192
+ );
193
+
194
+ if(!$order->getIsVirtual()) {
195
+ $orderInfo['shipping'] = $this->_getAddresInfoFromOrderToArray($order->getShippingAddress());
196
+ }
197
+
198
+ return $orderInfo;
199
+ }
200
+
201
+
202
+
203
+ public function processCustomerToArray($customer,$additional = false)
204
+ {
205
+ $client = array();
206
+
207
+ $client['id'] = $customer->getId();
208
+ $client['first_name'] = $this->escapeHtml($customer->getFirstname());
209
+ $client['last_name'] = $this->escapeHtml($customer->getLastname());
210
+ $client['email'] = $customer->getEmail();
211
+ //$client['date_registered'] = $customer->getCreatedAt();
212
+ $client['date_registered'] = Mage::app()->getLocale()->date($customer->getCreatedAt())->toString($this->dateTimeFormat);
213
+
214
+ $client['country'] = '';
215
+ if ($customer->getData('billing_country_id')) {
216
+ $client['country'] = $this->_countries[$customer->getData('billing_country_id')];
217
+ }
218
+
219
+ $client['phone'] = '';
220
+ if ($customer->getData('billing_telephone')) {
221
+ $client['phone'] = $this->escapeHtml($customer->getData('billing_telephone'));
222
+ }
223
+
224
+ if($additional) {
225
+ // Format billing address data
226
+ $client['billing'] = $this->_getAddresInfoArray($customer, 'billing');
227
+
228
+ // Format shipping address data
229
+ $client['shipping'] = $this->_getAddresInfoArray($customer, 'shipping');
230
+
231
+ $orders = $this->_getCustomersRecentOrders($customer);
232
+ $customerOrders = array();
233
+ if($orders->getSize()) {
234
+ foreach($orders as $order) {
235
+ $customerOrders[] = $this->processOrderToArray($order);
236
+ }
237
+ }
238
+ $client['orders'] = $customerOrders;
239
+ }
240
+ return $client;
241
+ }
242
+ }
app/code/local/AW/Onpulse/Model/Aggregator.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AW_Onpulse_Model_Aggregator extends Mage_Core_Model_Abstract
4
+ {
5
+ public function Aggregate() {
6
+ Mage::dispatchEvent('onpulse_aggregate_data',array('aggregator'=>$this));
7
+ return $this;
8
+ }
9
+ }
app/code/local/AW/Onpulse/Model/Aggregator/Component.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class AW_Onpulse_Model_Aggregator_Component extends Mage_Core_Model_Abstract
4
+ {
5
+ public function pushData($event){}
6
+ }
app/code/local/AW/Onpulse/Model/Aggregator/Components/Customer.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AW_Onpulse_Model_Aggregator_Components_Customer extends AW_Onpulse_Model_Aggregator_Component
4
+ {
5
+ const COUNT_CUSTOMERS = 5;
6
+
7
+ public function pushData($event = null)
8
+ {
9
+
10
+ /** @var $customerCollection Mage_Customer_Model_Resource_Customer_Collection */
11
+ $customerCollection = Mage::getModel('customer/customer')->getCollection()
12
+ ->setPageSize(self::COUNT_CUSTOMERS)
13
+ ->addNameToSelect()
14
+ ->addAttributeToSelect('email')
15
+ ->addAttributeToSelect('created_at')
16
+ ->joinAttribute('billing_firstname', 'customer_address/firstname', 'default_billing', null, 'left')
17
+ ->joinAttribute('billing_lastname', 'customer_address/lastname', 'default_billing', null, 'left')
18
+ ->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
19
+ ->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
20
+ ->joinAttribute('billing_street', 'customer_address/street', 'default_billing', null, 'left')
21
+ ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
22
+ ->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
23
+ ->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left')
24
+ ->joinAttribute('shipping_firstname', 'customer_address/firstname', 'default_shipping', null, 'left')
25
+ ->joinAttribute('shipping_lastname', 'customer_address/lastname', 'default_shipping', null, 'left')
26
+ ->joinAttribute('shipping_postcode', 'customer_address/postcode', 'default_shipping', null, 'left')
27
+ ->joinAttribute('shipping_city', 'customer_address/city', 'default_shipping', null, 'left')
28
+ ->joinAttribute('shipping_street', 'customer_address/street', 'default_shipping', null, 'left')
29
+ ->joinAttribute('shipping_telephone', 'customer_address/telephone', 'default_shipping', null, 'left')
30
+ ->joinAttribute('shipping_region', 'customer_address/region', 'default_shipping', null, 'left')
31
+ ->joinAttribute('shipping_country_id', 'customer_address/country_id', 'default_shipping', null, 'left');
32
+ $customerCollection->getSelect()->order('entity_id DESC');
33
+
34
+ $aggregator = $event->getEvent()->getAggregator();
35
+
36
+ $aggregator->setData('clients', $customerCollection->load());
37
+ }
38
+ }
app/code/local/AW/Onpulse/Model/Aggregator/Components/Order.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AW_Onpulse_Model_Aggregator_Components_Order extends AW_Onpulse_Model_Aggregator_Component
4
+ {
5
+ const COUNT_CUSTOMERS = 5;
6
+
7
+ public function pushData($event = null){
8
+ /** @var $customerCollection Mage_Sales_Model_Resource_Order_Collection */
9
+ $orderCollection = Mage::getModel('sales/order')->getCollection()
10
+ ->addAddressFields()
11
+ ->addAttributeToSelect('*')
12
+ ->addOrder('entity_id','DESC')
13
+ ->setPageSize(self::COUNT_CUSTOMERS);
14
+
15
+ $aggregator = $event->getEvent()->getAggregator();
16
+
17
+ $aggregator->setData('orders', $orderCollection->load());
18
+ }
19
+ }
app/code/local/AW/Onpulse/Model/Aggregator/Components/Statistics.php ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AW_Onpulse_Model_Aggregator_Components_Statistics extends AW_Onpulse_Model_Aggregator_Component
4
+ {
5
+ const COUNT_CUSTOMERS = 5;
6
+ const MYSQL_DATE_FORMAT = 'Y-m-d';
7
+
8
+ private function _getCurrentDate()
9
+ {
10
+ $now = Mage::app()->getLocale()->date();
11
+ $dateObj = Mage::app()->getLocale()->date(null, null, Mage::app()->getLocale()->getDefaultLocale(), false);
12
+
13
+ //set default timezone for store (admin)
14
+ $dateObj->setTimezone(Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE));
15
+
16
+ //set begining of day
17
+ $dateObj->setHour(00);
18
+ $dateObj->setMinute(00);
19
+ $dateObj->setSecond(00);
20
+
21
+ //set date with applying timezone of store
22
+ $dateObj->set($now, Zend_Date::DATE_SHORT, Mage::app()->getLocale()->getDefaultLocale());
23
+
24
+ //convert store date to default date in UTC timezone without DST
25
+ $dateObj->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE);
26
+
27
+ return $dateObj;
28
+ }
29
+ public function pushData($event = null)
30
+ {
31
+ $aggregator = $event->getEvent()->getAggregator();
32
+ $dashboard = array();
33
+ $today = $this->_getCurrentDate();
34
+ $dashboard['sales'] = $this->_getSales($today);
35
+ $today = $this->_getCurrentDate();
36
+ $dashboard['orders'] = $this->_getOrders($today);
37
+ $today = $this->_getCurrentDate();
38
+ $dashboard['customers'] = $this->_getCustomers($today);
39
+ $aggregator->setData('dashboard',$dashboard);
40
+ }
41
+
42
+ private function _getByers($date) {
43
+ /** @var $todayRegistered Mage_Customer_Model_Resource_Customer_Collection */
44
+ $todayRegistered = Mage::getModel('customer/customer')->getCollection();
45
+ $todayRegistered->addAttributeToFilter('created_at', array('from' => $date->toString(Varien_Date::DATETIME_INTERNAL_FORMAT)));
46
+ $todayRegistered->addAttributeToSelect('*');
47
+
48
+ /* @var $collection Mage_Reports_Model_Mysql4_Order_Collection */
49
+ //$collection = Mage::getResourceModel('reports/order_collection');
50
+ $customerArray = array();
51
+ $todayOrders = Mage::getModel('sales/order')->getCollection();
52
+ $todayOrders->addAttributeToFilter('created_at', array('from' => $date->toString(Varien_Date::DATETIME_INTERNAL_FORMAT)));
53
+ foreach ($todayOrders as $order) {
54
+ //$order->getCustomerId();
55
+ if ($order->getCustomerId()){
56
+ $customerArray[] = $order->getCustomerId();
57
+ }
58
+ }
59
+ $customerArray = array_unique($customerArray);
60
+ $buyers = count($customerArray);
61
+ return array(
62
+ 'buyers'=>$buyers,
63
+ 'registered'=>$todayRegistered,
64
+ );
65
+ }
66
+
67
+ private function _getCustomers($date)
68
+ {
69
+
70
+ //collect online visitors
71
+ $online = Mage::getModel('log/visitor_online')
72
+ ->prepare()
73
+ ->getCollection()->getSize();
74
+ $todayCustomers = null;
75
+ $yesterdayCustomers = null;
76
+ $todayCustomers = $this->_getByers($date);
77
+ $yesterdayCustomers = $this->_getByers($date->addDay(-1));
78
+ //var_dump($yesterdayCustomers);
79
+ /*$collection
80
+ ->groupByCustomer()
81
+ ->addAttributeToFilter('created_at', array('gteq' => $date->toString(Varien_Date::DATE_INTERNAL_FORMAT)))
82
+ ->addOrdersCount()
83
+ ->joinCustomerName();
84
+ $buyers = 0;
85
+ foreach ($collection as $item) {
86
+ $buyers++;
87
+ }*/
88
+ return array('online_visistors' => $online, 'today_customers' => $todayCustomers, 'yesterday_customers' => $yesterdayCustomers);
89
+ }
90
+
91
+ private function _getOrders($date)
92
+ {
93
+
94
+ //collect yesterday orders count
95
+
96
+ /** @var $yesterdayOrders Mage_Sales_Model_Resource_Order_Collection */
97
+ $yesterdayOrders = Mage::getResourceModel('sales/order_collection');
98
+ // echo 'request'.$yesterdayOrders->getSelect().'<br>';die;
99
+ $yesterdayOrders->addAttributeToFilter('created_at', array(
100
+ 'from' => $date->addDay(-1)->toString(Varien_Date::DATETIME_INTERNAL_FORMAT),
101
+ 'to'=>$date->addDay(1)->toString(Varien_Date::DATETIME_INTERNAL_FORMAT)
102
+ ))->addAttributeToSelect('*')
103
+ ->addAttributeToFilter('state', array('eq' => Mage_Sales_Model_Order::STATE_COMPLETE));
104
+
105
+
106
+ //collect today orders count
107
+
108
+ /** @var $yesterdayOrders Mage_Sales_Model_Resource_Order_Collection */
109
+ $todayOrders = Mage::getResourceModel('sales/order_collection');
110
+ $todayOrders->addAttributeToFilter('created_at', array('from' => $date->toString(Varien_Date::DATETIME_INTERNAL_FORMAT)))
111
+ ->addAttributeToSelect('*')
112
+ ->addAttributeToFilter('state', array('eq' => Mage_Sales_Model_Order::STATE_COMPLETE));
113
+
114
+ //collect max, min, average orders
115
+ $order = array();
116
+ if ($todayOrders->getSize()) {
117
+ $order['max'] = 0;
118
+ $order['min'] = 999999999999999;
119
+ $order['average'] = 0;
120
+ $ordersSum = 0;
121
+
122
+ foreach ($todayOrders as $item) {
123
+
124
+ if ($item->getBaseGrandTotal() > $order['max']) {
125
+ $order['max'] = Mage::helper('awonpulse')->getPriceFormat($item->getBaseGrandTotal());
126
+ }
127
+
128
+ if ($item->getBaseGrandTotal() < $order['min']) {
129
+ $order['min'] = Mage::helper('awonpulse')->getPriceFormat($item->getBaseGrandTotal());
130
+ }
131
+
132
+ $ordersSum += Mage::helper('awonpulse')->getPriceFormat($item->getBaseGrandTotal());
133
+
134
+ }
135
+ $order['average'] = Mage::helper('awonpulse')->getPriceFormat($ordersSum / $todayOrders->getSize());
136
+ } else {
137
+ $order['max'] = 0;
138
+ $order['min'] = 0;
139
+ $order['average'] = 0;
140
+ }
141
+
142
+ return array('yesterday_orders' => $yesterdayOrders->getSize(), 'today_orders' => $todayOrders->getSize(), 'orders_totals' => $order);
143
+ }
144
+
145
+ private function _getSales($date)
146
+ {
147
+
148
+ $date->addDay(1);
149
+ $revenue = array();
150
+ for($i=0;$i<15;$i++){
151
+
152
+ /** @var $yesterdayOrders Mage_Sales_Model_Resource_Order_Collection */
153
+ $orders = Mage::getModel('sales/order')->getCollection();
154
+ $orders->addAttributeToFilter('created_at', array('from' => $date->addDay(-1)->toString(Varien_Date::DATETIME_INTERNAL_FORMAT),'to'=>$date->addDay(1)->toString(Varien_Date::DATETIME_INTERNAL_FORMAT)))
155
+ ->addAttributeToSelect('*')
156
+ ->addAttributeToFilter('state', array('eq' => Mage_Sales_Model_Order::STATE_COMPLETE));
157
+ $date->addDay(-1);
158
+ $revenue[$i]['revenue']=0;
159
+ $revenue[$i]['date']=$date->toString(Varien_Date::DATE_INTERNAL_FORMAT);
160
+ foreach($orders as $order){
161
+ $revenue[$i]['revenue']+=$order->getBaseGrandTotal();
162
+
163
+
164
+ }
165
+ }
166
+ return array('revenue'=>$revenue);
167
+
168
+ }
169
+ }
app/code/local/AW/Onpulse/Model/Credentials.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AW_Onpulse_Model_Credentials extends Mage_Core_Model_Abstract
4
+ {
5
+ private $key = null;
6
+ private $hash = null;
7
+ private $qrhash = null;
8
+
9
+ private function _readConfig()
10
+ {
11
+ if(!$this->qrhash) {
12
+ //Read configuration
13
+ if ((Mage::getStoreConfig('awonpulse/general/credurlkey'))&&(Mage::getStoreConfig('awonpulse/general/credhash'))) {
14
+ $this->hash = Mage::getStoreConfig('awonpulse/general/credhash');
15
+ $this->key = Mage::getStoreConfig('awonpulse/general/credurlkey');
16
+ $this->qrhash = md5($this->key.$this->hash);
17
+ return true;
18
+ }
19
+ } else {
20
+ return true;
21
+ }
22
+ }
23
+
24
+ public function checkAuthorization()
25
+ {
26
+ if (Mage::getStoreConfig('advanced/modules_disable_output/AW_Onpulse')) {
27
+ $result = array(
28
+ 'result'=>false,
29
+ 'error'=>4,
30
+ 'message'=>'Connector disabled'
31
+ );
32
+ die('['.serialize($result).']');
33
+ }
34
+ $qrcode = null;
35
+ $data = Mage::app()->getFrontController();
36
+ $qrcode = mb_substr($data->getRequest()->getOriginalPathInfo(),-32);
37
+ if(!preg_match('/[a-z0-9]{32}/',$qrcode)) return;
38
+ //Check request
39
+ //if QRcode authorization
40
+ if($qrcode) {
41
+ if($this->_readConfig()){
42
+ if($qrcode != $this->qrhash) {
43
+ $result = array(
44
+ 'result'=>false,
45
+ 'error'=>1,
46
+ 'message'=>'Incorrect credentials'
47
+ );
48
+ die('['.serialize($result).']');
49
+ }
50
+ } else {
51
+ $result = array(
52
+ 'result'=>false,
53
+ 'error'=>1,
54
+ 'message'=>'Incorrect module configuration'
55
+ );
56
+ die('['.serialize($result).']');
57
+ }
58
+ } else {
59
+ $result = array(
60
+ 'result'=>false,
61
+ 'error'=>1,
62
+ 'message'=>'Incorrect authorization data'
63
+ );
64
+ die('['.serialize($result).']');
65
+ }
66
+
67
+ $aggregator = Mage::getSingleton('awonpulse/aggregator')->Aggregate();
68
+ $output = Mage::helper('awonpulse')->processOutput($aggregator);
69
+ echo serialize($output);
70
+ die;
71
+ }
72
+
73
+ }
app/code/local/AW/Onpulse/etc/config.xml ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <AW_Onpulse>
5
+ <version>1.0.2</version>
6
+ </AW_Onpulse>
7
+ </modules>
8
+ <global>
9
+ <blocks>
10
+ <awonpulse>
11
+ <class>AW_Onpulse_Block</class>
12
+ </awonpulse>
13
+ </blocks>
14
+ <resources>
15
+ <awonpulse_setup>
16
+ <setup>
17
+ <module>AW_Onpulse</module>
18
+ </setup>
19
+ <connection>
20
+ <use>core_setup</use>
21
+ </connection>
22
+ </awonpulse_setup>
23
+ <awonpulse_write>
24
+ <connection>
25
+ <use>core_write</use>
26
+ </connection>
27
+ </awonpulse_write>
28
+ <awonpulse_read>
29
+ <connection>
30
+ <use>core_read</use>
31
+ </connection>
32
+ </awonpulse_read>
33
+ </resources>
34
+ <models>
35
+ <awonpulse>
36
+ <class>AW_Onpulse_Model</class>
37
+ </awonpulse>
38
+ </models>
39
+ <helpers>
40
+ <awonpulse>
41
+ <class>AW_Onpulse_Helper</class>
42
+ </awonpulse>
43
+ </helpers>
44
+ <events>
45
+ <controller_action_predispatch_cms_index_noRoute>
46
+ <observers>
47
+ <onpulse_authorization>
48
+ <type>singleton</type>
49
+ <class>awonpulse/credentials</class>
50
+ <method>checkAuthorization</method>
51
+ </onpulse_authorization>
52
+ </observers>
53
+ </controller_action_predispatch_cms_index_noRoute>
54
+ <onpulse_aggregate_data>
55
+ <observers>
56
+ <onpulse_aggregator_component_customer>
57
+ <type>singleton</type>
58
+ <class>awonpulse/aggregator_components_customer</class>
59
+ <method>pushData</method>
60
+ </onpulse_aggregator_component_customer>
61
+ <onpulse_aggregator_component_order>
62
+ <type>singleton</type>
63
+ <class>awonpulse/aggregator_components_order</class>
64
+ <method>pushData</method>
65
+ </onpulse_aggregator_component_order>
66
+ <onpulse_aggregator_component_statistics>
67
+ <type>singleton</type>
68
+ <class>awonpulse/aggregator_components_statistics</class>
69
+ <method>pushData</method>
70
+ </onpulse_aggregator_component_statistics>
71
+ </observers>
72
+ </onpulse_aggregate_data>
73
+ </events>
74
+ </global>
75
+ <adminhtml>
76
+ <translate>
77
+ <modules>
78
+ <AW_Onpulse>
79
+ <files>
80
+ <default>AW_Onpulse.csv</default>
81
+ </files>
82
+ </AW_Onpulse>
83
+ </modules>
84
+ </translate>
85
+ <layout>
86
+ <updates>
87
+ <awonpulse module="AW_Onpulse">
88
+ <file>aw_onpulse.xml</file>
89
+ </awonpulse>
90
+ </updates>
91
+ </layout>
92
+ <acl>
93
+ <resources>
94
+ <all>
95
+ <title>Allow Everything</title>
96
+ </all>
97
+ <admin>
98
+ <children>
99
+ <system>
100
+ <children>
101
+ <config>
102
+ <children>
103
+ <awonpulse>
104
+ <title>aheadWorks - Onpulse</title>
105
+ </awonpulse>
106
+ </children>
107
+ </config>
108
+ </children>
109
+ </system>
110
+ </children>
111
+ </admin>
112
+ </resources>
113
+ </acl>
114
+ </adminhtml>
115
+ <default>
116
+
117
+ </default>
118
+ </config>
app/code/local/AW/Onpulse/etc/system.xml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <awonpulse translate="label" module="awonpulse">
5
+ <label>Onpulse</label>
6
+ <tab>awall</tab>
7
+ <frontend_type>text</frontend_type>
8
+ <sort_order>99</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>1</show_in_store>
12
+ <groups>
13
+ <general translate="label">
14
+ <label>General</label>
15
+ <frontend_type>text</frontend_type>
16
+ <frontend_model>awonpulse/system_config_form_fieldset_onpulse_settings</frontend_model>
17
+ <sort_order>2</sort_order>
18
+ <show_in_default>1</show_in_default>
19
+ <show_in_website>1</show_in_website>
20
+ <show_in_store>1</show_in_store>
21
+ <fields>
22
+ <credurlkey>
23
+ <frontend_type>text</frontend_type>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ </credurlkey>
28
+ <credhash>
29
+ <frontend_type>text</frontend_type>
30
+ <show_in_default>1</show_in_default>
31
+ <show_in_website>1</show_in_website>
32
+ <show_in_store>1</show_in_store>
33
+ </credhash>
34
+ </fields>
35
+ </general>
36
+ </groups>
37
+ </awonpulse>
38
+ </sections>
39
+ </config>
app/design/adminhtml/default/default/layout/aw_all.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <default>
4
+ <reference name="head">
5
+ <action method="addCss">
6
+ <name>aw_all/css/window.css</name>
7
+ </action>
8
+
9
+ </reference>
10
+ </default>
11
+ <adminhtml_system_config_edit>
12
+ <reference name="content">
13
+ <block type="awall/jsinit" name="aw_all_jsinit" template="aw_all/jsinit.phtml"></block>
14
+ </reference>
15
+ </adminhtml_system_config_edit>
16
+
17
+ </layout>
app/design/adminhtml/default/default/layout/aw_onpulse.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <default>
4
+
5
+ </default>
6
+ <adminhtml_system_config_edit>
7
+ <reference name="content">
8
+ <!--<block type="awonpulse/system_config_form_fieldset_onpulse_settings" name="aw_onpulse_settings" template="aw_onpulse/settings.phtml"></block>-->
9
+ </reference>
10
+ </adminhtml_system_config_edit>
11
+
12
+ </layout>
app/design/adminhtml/default/default/template/aw_all/jsinit.phtml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ($this->_section == 'awall'): ?>
2
+ <div id="awall_extensions_table">
3
+ <table class="form-list">
4
+ <tbody>
5
+ <?php foreach ($this->getExtensions() as $Extension): ?>
6
+ <tr>
7
+ <td><img src="<?php echo $this->getIcon($Extension)->getSource()?>"
8
+ alt="<?php echo $this->getIcon($Extension)->getTitle()?>"/></td>
9
+ <td><a href="<?php echo $Extension->getFeedInfo()->getUrl()?>"
10
+ onclick="this.target = '_blank'"><?php echo $Extension->getFeedInfo()->getDisplayName()?></a></td>
11
+ <td><?php echo $Extension->getVersion()?></td>
12
+ <td>
13
+ <a href="http://doc.aheadworks.com/magento-extensions/<?php echo $Extension->getName()?>-<?php echo $Extension->getVersion()?>/readme.html"
14
+ onclick="this.target = '_blank'"><img
15
+ src="<?php echo $this->getSkinUrl('aw_all/images/readme.png')?>"/></a></td>
16
+ </tr>
17
+ <?php endforeach; ?>
18
+ </tbody>
19
+ </table>
20
+ </div>
21
+ <?php endif; ?>
22
+ <?php if ($this->_section == 'awstore'): ?>
23
+ <div id="awall_store_response">
24
+
25
+ <?php echo $this->_getStoreData()->getTextResponse()?>
26
+ </div>
27
+ <?php endif; ?>
28
+
29
+
30
+ <script type="text/javascript">
31
+ _section = '<?php echo $this->_section?>';
32
+ </script>
app/design/adminhtml/default/default/template/aw_all/notification/window.phtml ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * aheadWorks Co.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://ecommerce.aheadworks.com/LICENSE-M1.txt
11
+ *
12
+ * @category AW
13
+ * @package AW_All
14
+ * @copyright Copyright (c) 2009-2010 aheadWorks Co. (http://www.aheadworks.com)
15
+ * @license http://ecommerce.aheadworks.com/LICENSE-M1.txt
16
+ */
17
+ ?>
18
+ <div id="message-popup-window-mask" style="display:none;"></div>
19
+
20
+ <div style="position:relative;margin-left:-390px;">
21
+ <div id="aw_notif" class="notification" style="display:none;">
22
+ <div class="head">
23
+ <h3><?php echo $this->getHeaderText();?></h3>
24
+ <button type="button" class="close" onclick="closeMessagePopupWindow()">
25
+ <span><?php echo $this->getCloseText(); ?></span></button>
26
+ </div>
27
+ <div class="content">
28
+ <?php echo $this->getNoticeMessageText(); ?>
29
+ </div>
30
+ </div>
31
+ </div>
32
+ <script>
33
+ function showAwNotificator() {
34
+ openMessagePopupWindow();
35
+ Effect.Appear('aw_notif', { duration: 1.0 });
36
+ }
37
+ Event.observe(window, 'load', showAwNotificator);
38
+
39
+
40
+ function openMessagePopupWindow() {
41
+ var height = $('html-body').getHeight();
42
+ $('message-popup-window-mask').setStyle({'height':height + 'px'});
43
+ toggleSelectsUnderBlock($('message-popup-window-mask'), false);
44
+ Element.show('message-popup-window-mask');
45
+ }
46
+
47
+ function closeMessagePopupWindow() {
48
+ toggleSelectsUnderBlock($('message-popup-window-mask'), true);
49
+ Effect.Fade('aw_notif', { duration: 0.5 });
50
+ Element.hide('message-popup-window-mask');
51
+ }
52
+
53
+
54
+ function saveCloseMessagePopupWindow() {
55
+ $('aw-save-button-content').innerHTML = '<?php echo $this->__("Saving, please wait...")?>';
56
+ $('aw-save-button').addClassName('disabled');
57
+ $('aw_firstrun').request({
58
+ onComplete: function() {
59
+ toggleSelectsUnderBlock($('message-popup-window-mask'), true);
60
+ Effect.Fade('aw_notif', { duration: 0.5 });
61
+ Element.hide('message-popup-window-mask');
62
+ }
63
+ })
64
+
65
+ }
66
+
67
+ </script>
68
+
69
+
70
+ <?php /*
71
+
72
+
73
+ */
74
+ ?>
app/design/adminhtml/default/default/template/aw_all/notification/window/first-run.phtml ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * aheadWorks Co.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://ecommerce.aheadworks.com/LICENSE-M1.txt
11
+ *
12
+ * @category AW
13
+ * @package AW_All
14
+ * @copyright Copyright (c) 2009-2010 aheadWorks Co. (http://www.aheadworks.com)
15
+ * @license http://ecommerce.aheadworks.com/LICENSE-M1.txt
16
+ */
17
+ ?>
18
+ <form method="post" action="<?php echo $this->getUrl('adminhtml/system_config/save', array('section' => 'awall'))?>"
19
+ id="aw_firstrun">
20
+ <table class="form-list" cellspacing="0">
21
+ <colgroup class="label"/>
22
+ <colgroup class="value"/>
23
+ <tbody>
24
+
25
+ <tr>
26
+ <td class="label">
27
+ <label for="interests"><?php echo $this->__('I wish to be informed about')?>:</label>
28
+ </td>
29
+ <td class="value">
30
+
31
+ <input type="hidden" value="" name="groups[feed][fields][interests][value]">
32
+ <select name="groups[feed][fields][interests][value][]" style="width:214px" size="6" multiple="multiple"
33
+ id="interests" class="select multiselect">
34
+ <?php foreach (Mage::getModel('awall/source_updates_type')->getGridOptions() as $k => $v): ?>
35
+ <option selected="selected" value="<?php echo $k?>"><?php echo $this->__($v)?></option>
36
+ <?php endforeach;?>
37
+ </select><br/>
38
+ <a href="#"
39
+ onclick="$$('#interests option').each(function(el){el.selected=1});return false;"><?php echo $this->__("Select all")?></a>
40
+ /
41
+ <a href="#"
42
+ onclick="$('interests').selectedIndex = -1;return false;"><?php echo $this->__("Deselect all")?></a>
43
+ </td>
44
+ </tr>
45
+ <tr>
46
+ <td class="label"></td>
47
+ <td class="value">
48
+ <button id="aw-save-button" class="scalable save" style="" onclick="saveCloseMessagePopupWindow()"
49
+ type="button">
50
+ <span id="aw-save-button-content"> <?php echo $this->__('Save &amp; Close')?></span>
51
+ </button>
52
+ </td>
53
+ </tr>
54
+ <tr>
55
+ <td colspan="2" align="right">
56
+ <div style="width:365px">
57
+ <small><?php echo $this->__("This message appears only once. At any time you can change these preferences
58
+ from System > Configuration > aheadWorks extensions > Info. <br/><a href=\"%s\">Visit it now</a>",
59
+ Mage::getModel('adminhtml/url')->getUrl('adminhtml/system_config/edit', array('section' => 'awall')))?></small>
60
+ </div>
61
+ </td>
62
+ </tr>
63
+ </tbody>
64
+ </table>
65
+ </form>
app/design/adminhtml/default/default/template/aw_onpulse/settings.phtml ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $directLoginLink = null;
3
+ if ((Mage::getStoreConfig('awonpulse/general/credurlkey')) && (Mage::getStoreConfig('awonpulse/general/credhash'))) {
4
+ $credurlkey = Mage::getStoreConfig('awonpulse/general/credurlkey');
5
+ $credhash = Mage::getStoreConfig('awonpulse/general/credhash');
6
+ $qrsrc = 'http://chart.apis.google.com/chart?chs=250x250&cht=qr&chld=1/1&choe=utf-8&chl=';
7
+ $backUrl = Mage::app()->getDefaultStoreView()->getBaseUrl() . md5($credurlkey . $credhash);
8
+ $qrsrc .= 'http://m.onpulse.info/?qrhash=' . base64_encode($backUrl);
9
+ $directLoginLink = 'http://m.onpulse.info/?qrhash=' . base64_encode($backUrl);
10
+ } else {
11
+ $credurlkey = '';
12
+ $credhash = '';
13
+ $qrsrc = null;
14
+ }
15
+ ?>
16
+
17
+ <table class="form-list">
18
+ <tbody>
19
+ <form method="post">
20
+ <tr>
21
+ <td class="label">
22
+ <label><?php echo Mage::helper('awonpulse')->__('URL') ?></label>
23
+ </td>
24
+ <td class="value">
25
+ <input class="input-text" style="width: 600px;" onclick="this.select()" type="text" readonly="readonly"
26
+ name="groups[general][fields][credurlkey][value]" id="urlkey"
27
+ value="<?php echo Mage::app()->getDefaultStoreView()->getBaseUrl() . $credurlkey;?>">
28
+
29
+ <p class="note">
30
+ <span><?php echo Mage::helper('awonpulse')->__('Your login name to access OnPulse service') ?></span>
31
+ </p>
32
+ </td>
33
+ </tr>
34
+ <tr>
35
+ <td class="label">
36
+ <label><?php echo Mage::helper('awonpulse')->__('Key') ?></label>
37
+ </td>
38
+ <td class="value">
39
+ <input class="input-text" style="width: 600px;" type="text" onclick="this.select()" readonly="readonly"
40
+ name="groups[general][fields][credhash][value]" id="hash" value="<?php echo $credhash;?>">
41
+ </td>
42
+ </tr>
43
+ <?php if ($directLoginLink) : ?>
44
+ <tr>
45
+ <td class="label">
46
+ <label><?php echo Mage::helper('awonpulse')->__('Direct login URL') ?></label>
47
+ </td>
48
+ <td style="padding-left: 6px; ">
49
+ <a href="<?php echo $directLoginLink;?>" style="display: block; width: 600px; padding-top: 5px;"
50
+ target="_blank"><?php echo substr($directLoginLink, 0, 80) . '...'; ?></a>
51
+ </td>
52
+ </tr>
53
+ <?php endif; ?>
54
+ <?php if ($qrsrc) : ?>
55
+ <tr>
56
+ <td class="label">
57
+ <label><?php echo Mage::helper('awonpulse')->__('Direct login QR') ?></label>
58
+ </td>
59
+ <td>
60
+ <br/>&nbsp;&nbsp;<img src="<?php echo $qrsrc; ?>">
61
+ </td>
62
+ </tr>
63
+ <?php endif; ?>
64
+ <tr>
65
+ <td>
66
+ </td>
67
+ <td style="padding-left: 6px; padding-top: 10px;">
68
+ <button onclick="generate(this);"><?php echo Mage::helper('awonpulse')->__('Create new login credentials') ?></button>
69
+ <p class="note">
70
+ <span><?php echo Mage::helper('awonpulse')->__('Each time you reset credentials OnPulse generates new URL, key, direct login and QR code') ?></span>
71
+ </p>
72
+ </td>
73
+ </tr>
74
+ </form>
75
+ </tbody>
76
+ </table>
77
+
78
+
79
+ <script type="text/javascript">
80
+ var flagSubmit = false;
81
+ function generate() {
82
+ if (!flagSubmit) {
83
+ key = mkPass(8);
84
+ hash = mkPass(8);
85
+ document.getElementById('urlkey').value = key;
86
+ document.getElementById('hash').value = hash;
87
+ flagSubmit = true;
88
+ }
89
+ }
90
+
91
+ function mtRand(min, max) {
92
+ var range = max - min + 1;
93
+ var n = Math.floor(Math.random() * range) + min;
94
+ return n;
95
+ }
96
+
97
+ function mkPass(len) {
98
+ var len = 8;
99
+ var pass = '';
100
+ var rnd = 0;
101
+ var c = '';
102
+ for (i = 0; i < len; i++) {
103
+ rnd = mtRand(0, 1); // Латиница или цифры
104
+ if (rnd == 0) {
105
+ c = String.fromCharCode(mtRand(48, 57));
106
+ }
107
+ if (rnd == 1) {
108
+ c = String.fromCharCode(mtRand(97, 122));
109
+ }
110
+ pass += c;
111
+ }
112
+ return pass;
113
+ }
114
+
115
+ document.getElementsByClassName('form-buttons')[0].style.display = 'none';
116
+ document.getElementsByClassName('form-buttons')[1].style.display = 'none';
117
+
118
+
119
+ </script>
app/etc/modules/AW_All.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <AW_All>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </AW_All>
8
+ </modules>
9
+ </config>
app/etc/modules/AW_Onpulse.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <AW_Onpulse>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </AW_Onpulse>
8
+ </modules>
9
+ </config>
app/locale/en_US/AW_Onpulse.csv ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ "Hash","Hash"
2
+ "Url key","Url key"
3
+ 'URL','URL'
4
+ 'Your login name to access OnPulse service','Your login name to access OnPulse service'
5
+ 'Key','Key'
6
+ 'Direct login URL','Direct login URL'
7
+ 'Direct login QR','Direct login QR'
8
+ 'Create new login credentials','Create new login credentials'
9
+ 'Each time you reset credentials OnPulse generates new URL, key, direct login and QR code','Each time you reset credentials OnPulse generates new URL, key, direct login and QR code'
js/aw_all/aw_all.js ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ function initAwall(){
2
+ if(_section == 'awall'){
3
+ $('awall_extensions').update($('awall_extensions_table').innerHTML)
4
+ }
5
+ if(_section == 'awstore'){
6
+ $('awstore_extensions').update($('awall_store_response').innerHTML)
7
+ }
8
+ }
9
+ Event.observe(window, 'load', function() {
10
+ initAwall();
11
+ });
package.xml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>AW_Onpulse</name>
4
+ <version>1.0.2</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://onpulse.info/TOS.pdf">EULA</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Mobile administration for Magento</summary>
10
+ <description>OnPulse provides you with an access to your sales statistics, the latest orders, and the clients list through any iOS or Android powered mobile device.&#xD;
11
+ </description>
12
+ <notes> Dashboard&#xD;
13
+ &#xD;
14
+ The dashboard displays the latest sales data as well as gives a fast look at yesterday&#x2019;s sales;&#xD;
15
+ orders with max/min/ average values;&#xD;
16
+ the number of registered users and online visitors.&#xD;
17
+ &#xD;
18
+ Sales&#xD;
19
+ &#xD;
20
+ Attractive bar chart showing sales statistics for the past 15 days.&#xD;
21
+ &#xD;
22
+ Orders&#xD;
23
+ &#xD;
24
+ The latest orders are sorted by date and include order ID, client name, status information, and other purchase details.&#xD;
25
+ Tap on email or phone number to contact your customer.&#xD;
26
+ &#xD;
27
+ Clients&#xD;
28
+ &#xD;
29
+ The list of customers that contains personal information and purchase activity.&#xD;
30
+ &#xD;
31
+ </notes>
32
+ <authors><author><name>AW_Core_Team</name><user>aheadworks</user><email>no-reply@aheadworks.com</email></author></authors>
33
+ <date>2013-02-21</date>
34
+ <time>06:55:31</time>
35
+ <contents><target name="magelocal"><dir name="AW"><dir name="Onpulse"><dir name="Block"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Fieldset"><dir name="Onpulse"><file name="Settings.php" hash="6ba04d380ea7140b42c54f00a0acc452"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="9e18cf2dd18b58c00d8d945470c57054"/><file name="Data.php.orig" hash="b022898682ac190dec591c1bacf5c32f"/></dir><dir name="Model"><dir name="Aggregator"><file name="Component.php" hash="47a0a36eaca33135f61c1e422008dd95"/><dir name="Components"><file name="Customer.php" hash="52df2d3be2d6196ee957b2e2c0d92cb2"/><file name="Order.php" hash="905a436620ff34860e1132f3377466a8"/><file name="Statistics.php" hash="afacedfd9791b1e5269951ade6f031d9"/></dir></dir><file name="Aggregator.php" hash="fcb4342d583403a99ca7bc245115854f"/><file name="Credentials.php" hash="a23575f1507b1b79b3f688e7020af5c6"/></dir><dir name="etc"><file name="config.xml" hash="ee6c54508a498f5991d62c45fc144b82"/><file name="system.xml" hash="0a793ace64e8c5eed6a829a280d9c244"/></dir></dir><dir name="All"><dir name="Block"><file name="Jsinit.php" hash="2c4f7995f12128676353f3400ca2323d"/><dir name="Notification"><file name="Window.php" hash="c036a2d67d14ad780be19b18f3039ddf"/></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Fieldset"><dir name="Awall"><file name="Extensions.php" hash="2daab2d11499b06f55db21d17673f830"/><file name="Store.php" hash="f79986ed3ea85f9c82f0408784784691"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Config.php" hash="08c8ce64a72e17fdaded07bb481e1b84"/><file name="Data.php" hash="d5c25ae1427b94663ed85ba5af50c5cd"/><file name="Versions.php" hash="cad84ef6ab19bfc4882abd181b94a61d"/></dir><dir name="Model"><dir name="Feed"><file name="Abstract.php" hash="9e4176fa37419492b35f38e346570a15"/><file name="Extensions.php" hash="09a440225ba3ba913d65c13b0ead939e"/><file name="Updates.php" hash="6f6bf9b18c589160cd712a8c77505db1"/></dir><file name="Feed.php" hash="649bc890b0089dbfc4d5d543752397eb"/><dir name="Source"><dir name="Updates"><file name="Type.php" hash="888c9ba1443415e52a7b8ee899f1c624"/></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="35194b308565bedb01461b1b5a453589"/><file name="config.xml" hash="66e966899278037980837bff496f8605"/><file name="system.xml" hash="dc65c6a5469fb03482663e00c7a5d044"/></dir></dir></dir></target><target name="mage"><dir name="app"><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="aw_all.xml" hash="2f45307d61db1f1437489b761f0d80e3"/></dir><dir name="template"><dir name="aw_all"><file name="jsinit.phtml" hash="4791b4c4b577aa02f9cc08387f2889ac"/><dir><dir name="notification"><dir name="window"><file name="first-run.phtml" hash="7f1922658c950b8c97405110783ad173"/></dir><file name="window.phtml" hash="0cda3135865cd9dbb427e72355259eaf"/></dir></dir></dir><dir name="aw_onpulse"><file name="settings.phtml" hash="f528e96b676e5a527fb786dd9345aac3"/></dir></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="AW_All.xml" hash="71ed195abb2bb9e07e3ab8691a80f3e6"/><file name="AW_Onpulse.xml" hash="de39a5ffebb31ee697fbaf56bb1bfb8a"/></dir></dir><dir name="locale"><dir name="en_US"><file name="AW_Onpulse.csv" hash="c8a9db33aa8349174fef636c95ac7063"/></dir></dir></dir><dir name="js"><dir name="aw_all"><file name="aw_all.js" hash="1d05048fe6c683b10f9643e411841c70"/></dir></dir><dir name="skin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="aw_all"><dir><dir name="css"><file name="window.css" hash="883499f1a1a11c7dd2a95749de6bad73"/></dir><dir name="images"><file name="bad.gif" hash="b8379f1ba7ab552ca46b9d5fd0452345"/><file name="delete.jpg" hash="6bb134dbca5cbde8e9873b4eb8f8faa8"/><file name="info.gif" hash="421f023bf6a8a17b9c0347ab851f167f"/><file name="ok.gif" hash="a38bc2ee6e116e39c6e2e3013ee50f5e"/><file name="readme.png" hash="e18d543aceba4fef55b0052477dbf5a1"/><file name="store.png" hash="f2f0a8667df423a2b4eb763f4657c363"/><file name="update.gif" hash="8342e11f7739fcfa25134707f0536ed6"/><dir name="window"><file name="arrow.gif" hash="9d5ea1a89fda9e986ba5b235caae8620"/><file name="btn-close.gif" hash="18b1c56f62eba1f3537b392797f9c4ff"/></dir></dir></dir></dir></dir></dir></dir></dir><dir><dir name="app"><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="aw_onpulse.xml" hash="5036d3b89b9a204c9420f40f3983d987"/></dir></dir></dir></dir></dir></dir></dir></target></contents>
36
+ <compatible/>
37
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
38
+ </package>
skin/adminhtml/default/default/aw_all/css/window.css ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #aw_notif {
2
+ z-index: 100000000;
3
+ position: absolute;
4
+ top: 300px;
5
+ padding: 0px;
6
+ left: 50%;
7
+ border: 4px solid #f3bf8f;
8
+ border-top-width: 0px;
9
+ margin: auto;
10
+ background: #fdf4eb;
11
+ }
12
+
13
+ #aw_notif .head h3 {
14
+ margin-left: 12px;
15
+ font-size: 1.1em;
16
+ margin-bottom: 0px;
17
+ margin-top: 0.2em;
18
+ font-weight: bold;
19
+ float: left;
20
+ }
21
+
22
+ #aw_notif .head {
23
+ background: #f3bf8f;
24
+ height: 23px;
25
+
26
+ }
27
+
28
+ #aw_notif .content {
29
+ padding: 20px;
30
+ background: url(../images/info.gif) no-repeat 20px 30px;
31
+
32
+ }
33
+
34
+ #aw_notif .head .close {
35
+ display: block;
36
+ float: right;
37
+ background: url(../images/window/btn-close.gif) no-repeat top left;
38
+ padding-left: 28px;
39
+ height: 19px;
40
+ margin-top: 2px;
41
+ font-size: 11px;
42
+ font-weight: normal;
43
+ }
44
+
45
+ #aw_notif .value label {
46
+
47
+ }
48
+
49
+ #awall_extensions a img {
50
+ vertical-align: middle;
51
+ margin-right: 3px;
52
+ }
53
+
54
+ #aw_notif .form-list td.label label {
55
+ width: 130px;
56
+ margin-left: 45px;
57
+ text-align: right;
58
+
59
+ }
60
+
61
+ .adminhtml-system-config-edit #awall_extensions .label label {
62
+ width: auto;
63
+ white-space: nowrap;
64
+ }
65
+
66
+ #awall_extensions_table, #awall_store_response {
67
+ display: none;
68
+ }
69
+
70
+ .adminhtml-system-config-edit #awall_extensions table td {
71
+ padding: 0px 3px;
72
+ }
73
+
74
+ ul.tabs a.awall-section span, ul.tabs a.awall-section:hover span {
75
+ background: url("../images/store.png") no-repeat scroll 0 0 transparent;
76
+ height: 0;
77
+ overflow: hidden;
78
+ padding: 21px 0 0;
79
+ width: 192px;
80
+ }
81
+
82
+ ul.tabs a.awall-section, ul.tabs a.awall-section:hover {
83
+ background: url("../../images/tabs_span_bg.gif") repeat-x scroll 0 100% transparent;
84
+ border-bottom: medium none;
85
+ padding: 0.5em 0.5em 0.28em 1.5em;
86
+ }
87
+
88
+ ul.tabs a.awall-section:hover {
89
+ background-color: #d8e6e6;
90
+ }
91
+
92
+ ul.tabs a.awall-section.active, ul.tabs a.awall-section.active:hover {
93
+ background-color: #FFFFFF;
94
+ }
skin/adminhtml/default/default/aw_all/images/bad.gif ADDED
Binary file
skin/adminhtml/default/default/aw_all/images/delete.jpg ADDED
Binary file
skin/adminhtml/default/default/aw_all/images/info.gif ADDED
Binary file
skin/adminhtml/default/default/aw_all/images/ok.gif ADDED
Binary file
skin/adminhtml/default/default/aw_all/images/readme.png ADDED
Binary file
skin/adminhtml/default/default/aw_all/images/store.png ADDED
Binary file
skin/adminhtml/default/default/aw_all/images/update.gif ADDED
Binary file
skin/adminhtml/default/default/aw_all/images/window/arrow.gif ADDED
Binary file
skin/adminhtml/default/default/aw_all/images/window/btn-close.gif ADDED
Binary file