desktop_notification - Version 0.1.0

Version Notes

new release

Download this release

Release Info

Developer Biztech
Extension desktop_notification
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (30) hide show
  1. DesktopNotificaion.pdf +0 -0
  2. app/code/local/Biztech/All/Helper/Data.php +6 -0
  3. app/code/local/Biztech/All/Model/All.php +10 -0
  4. app/code/local/Biztech/All/Model/Mysql4/All.php +10 -0
  5. app/code/local/Biztech/All/Model/Mysql4/All/Collection.php +10 -0
  6. app/code/local/Biztech/All/Model/Source/Updates/Type.php +50 -0
  7. app/code/local/Biztech/All/Model/Status.php +15 -0
  8. app/code/local/Biztech/All/Model/Update.php +93 -0
  9. app/code/local/Biztech/All/etc/config.xml +120 -0
  10. app/code/local/Biztech/All/etc/system.xml +46 -0
  11. app/code/local/Biztech/Desktopnotification/Block/Adminhtml/Desktopnotification.php +12 -0
  12. app/code/local/Biztech/Desktopnotification/Block/Adminhtml/Page/Footer.php +55 -0
  13. app/code/local/Biztech/Desktopnotification/Block/Desktopnotification.php +17 -0
  14. app/code/local/Biztech/Desktopnotification/Helper/Data.php +5 -0
  15. app/code/local/Biztech/Desktopnotification/Model/Desktopnotification.php +10 -0
  16. app/code/local/Biztech/Desktopnotification/Model/Mysql4/Desktopnotification.php +10 -0
  17. app/code/local/Biztech/Desktopnotification/Model/Mysql4/Desktopnotification/Collection.php +10 -0
  18. app/code/local/Biztech/Desktopnotification/Model/Notificationicon.php +92 -0
  19. app/code/local/Biztech/Desktopnotification/Model/Observer.php +28 -0
  20. app/code/local/Biztech/Desktopnotification/Model/Status.php +15 -0
  21. app/code/local/Biztech/Desktopnotification/controllers/Adminhtml/DesktopnotificationController.php +53 -0
  22. app/code/local/Biztech/Desktopnotification/controllers/IndexController.php +5 -0
  23. app/code/local/Biztech/Desktopnotification/etc/config.xml +135 -0
  24. app/code/local/Biztech/Desktopnotification/etc/system.xml +75 -0
  25. app/code/local/Biztech/Desktopnotification/sql/desktopnotification_setup/mysql4-install-0.1.0.php +21 -0
  26. app/design/adminhtml/default/default/template/desktopnotification/footer.phtml +118 -0
  27. app/design/adminhtml/default/default/template/desktopnotification/ordernotification.phtml +75 -0
  28. app/etc/modules/Biztech_All.xml +52 -0
  29. app/etc/modules/Biztech_Desktopnotification.xml +9 -0
  30. package.xml +18 -0
DesktopNotificaion.pdf ADDED
Binary file
app/code/local/Biztech/All/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Biztech_All_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/local/Biztech/All/Model/All.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Biztech_All_Model_All extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('all/all');
9
+ }
10
+ }
app/code/local/Biztech/All/Model/Mysql4/All.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Biztech_All_Model_Mysql4_All extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the all_id refers to the key field in your database table.
8
+ $this->_init('all/all', 'all_id');
9
+ }
10
+ }
app/code/local/Biztech/All/Model/Mysql4/All/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Biztech_All_Model_Mysql4_All_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('all/all');
9
+ }
10
+ }
app/code/local/Biztech/All/Model/Source/Updates/Type.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+
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
+ */
11
+
12
+ class Biztech_All_Model_Source_Updates_Type extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
13
+ {
14
+ const TYPE_UPDATE_RELEASE = 'UPDATE_RELEASE';
15
+ const TYPE_INSTALLED_UPDATE = 'INSTALLED_UPDATE';
16
+ public function toOptionArray()
17
+ {
18
+ return array(
19
+ array('value' => self::TYPE_INSTALLED_UPDATE, 'label' => Mage::helper('all')->__('My extensions updates')),
20
+ array('value' => self::TYPE_UPDATE_RELEASE, 'label' => Mage::helper('all')->__('All extensions updates')),
21
+ );
22
+ }
23
+
24
+ public function getAllOptions()
25
+ {
26
+ return $this->toOptionArray();
27
+ }
28
+
29
+
30
+ public function getLabel($value)
31
+ {
32
+ $options = $this->toOptionArray();
33
+ foreach ($options as $v) {
34
+ if ($v['value'] == $value) {
35
+ return $v['label'];
36
+ }
37
+ }
38
+ return '';
39
+ }
40
+
41
+ public function getGridOptions()
42
+ {
43
+ $items = $this->getAllOptions();
44
+ $out = array();
45
+ foreach ($items as $item) {
46
+ $out[$item['value']] = $item['label'];
47
+ }
48
+ return $out;
49
+ }
50
+ }
app/code/local/Biztech/All/Model/Status.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Biztech_All_Model_Status extends Varien_Object
4
+ {
5
+ const STATUS_ENABLED = 1;
6
+ const STATUS_DISABLED = 2;
7
+
8
+ static public function getOptionArray()
9
+ {
10
+ return array(
11
+ self::STATUS_ENABLED => Mage::helper('all')->__('Enabled'),
12
+ self::STATUS_DISABLED => Mage::helper('all')->__('Disabled')
13
+ );
14
+ }
15
+ }
app/code/local/Biztech/All/Model/Update.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Biztech_All_Model_Update extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ const UPDATE_NOTIFICATION_FEED_URL = 'http://store.biztechconsultancy.com/rss/catalog/new/store_id/1/';
7
+ public function getInterests()
8
+ {
9
+ $types = @explode(',', Mage::getStoreConfig('all/all_general/interests'));
10
+ return $types;
11
+ }
12
+ public function isExtensionInstalled($code)
13
+ {
14
+
15
+ $modules = array_keys((array)Mage::getConfig()->getNode('modules')->children());
16
+ foreach ($modules as $moduleName) {
17
+ if ($moduleName == $code) {
18
+ return true;
19
+ }
20
+ }
21
+ return false;
22
+ }
23
+
24
+ public function check()
25
+ {
26
+ if ((time() - Mage::app()->loadCache('biztech_all_updates_feed_lastcheck')) > Mage::getStoreConfig('all/all_general/check_frequency')) {
27
+ $this->refresh();
28
+ }
29
+ }
30
+
31
+ public function refresh()
32
+ {
33
+ $types = array();
34
+ $feedData = array();
35
+ $extensio_module = array();
36
+ try{
37
+ $xml = false;
38
+ $limit_context = stream_context_create(array('http'=>array('timeout' => 5)));
39
+ $xml = file_get_contents(self::UPDATE_NOTIFICATION_FEED_URL,true,$limit_context);
40
+ $xml = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);//LIBXML_NOCDATA LIBXML_NOWARNING
41
+
42
+ if($xml != false){
43
+ $interests = $this->getInterests();
44
+ if(!empty($interests[0])){
45
+ $isInterestedInSelfUpgrades = in_array(Biztech_All_Model_Source_Updates_Type::TYPE_INSTALLED_UPDATE, $interests);
46
+ $isInterestedInAllUpgrades = in_array(Biztech_All_Model_Source_Updates_Type::TYPE_UPDATE_RELEASE, $interests);
47
+ $modules = Mage::getConfig()->getNode('modules')->children();
48
+ $modulesArray = (array)$modules;
49
+ foreach($xml->channel->item as $keys=>$extensions) {
50
+ $types[] = (string) $extensions->update_notifications->type;
51
+ $extensions_name = (string)$extensions->update_notifications->extensions;
52
+
53
+ if((string)$extensions->update_notifications->date!=""&&(string)$extensions->update_notifications->extension_title!=""&&(string)$extensions->update_notifications->extension_content!=""&&(string)$extensions->update_notifications->product_url!=""){
54
+ if(!$isInterestedInAllUpgrades){
55
+ if ($this->isExtensionInstalled($extensions_name)) {
56
+ $feedData[] = array(
57
+ 'severity' => 4,
58
+ 'date_added' => (string) $extensions->update_notifications->date,
59
+ 'title' => (string)$extensions->update_notifications->extension_title,
60
+ 'description' => (string)$extensions->update_notifications->extension_content,
61
+ 'url' => (string)$extensions->update_notifications->product_url,
62
+ );
63
+ }
64
+ } else{
65
+ $feedData[] = array(
66
+ 'severity' => 4,
67
+ 'date_added' => (string)$extensions->update_notifications->date,
68
+ 'title' => (string)$extensions->update_notifications->extension_title,
69
+ 'description' => (string)$extensions->update_notifications->extension_content,
70
+ 'url' => (string)$extensions->update_notifications->product_url,
71
+ );
72
+ }
73
+ }
74
+ }
75
+ if ($feedData) {
76
+ foreach($feedData as $data){
77
+ if ((array_intersect($types,$interests) && $isInterestedInSelfUpgrades)) {
78
+ Mage::getModel('adminnotification/inbox')->parse(array_reverse(array($data)));
79
+ }
80
+ }
81
+ }
82
+ Mage::app()->saveCache(time(), 'biztech_all_updates_feed_lastcheck');
83
+ return true;
84
+ }
85
+ } else{
86
+ return false;
87
+ }
88
+
89
+ }catch (Exception $e) {
90
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
91
+ }
92
+ }
93
+ }
app/code/local/Biztech/All/etc/config.xml ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Biztech
5
+ * @package Biztech_All
6
+ * @author ModuleCreator
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Biztech_All>
13
+ <version>0.1.0</version>
14
+ </Biztech_All>
15
+ </modules>
16
+ <frontend>
17
+ <routers>
18
+ <all>
19
+ <use>standard</use>
20
+ <args>
21
+ <module>Biztech_All</module>
22
+ <frontName>all</frontName>
23
+ </args>
24
+ </all>
25
+ </routers>
26
+ </frontend>
27
+ <admin>
28
+ <routers>
29
+ <all>
30
+ <use>admin</use>
31
+ <args>
32
+ <module>Biztech_All</module>
33
+ <frontName>all</frontName>
34
+ </args>
35
+ </all>
36
+ </routers>
37
+ </admin>
38
+ <adminhtml>
39
+ <acl>
40
+ <resources>
41
+ <all>
42
+ <title>Allow Everything</title>
43
+ </all>
44
+ <admin>
45
+ <children>
46
+ <Biztech_All>
47
+ <title>All Module</title>
48
+ <sort_order>10</sort_order>
49
+ </Biztech_All>
50
+ </children>
51
+ </admin>
52
+ </resources>
53
+ </acl>
54
+ <events>
55
+ <controller_action_predispatch>
56
+ <observers>
57
+
58
+ <bzall_upds>
59
+ <type>singleton</type>
60
+ <class>all/update</class>
61
+ <method>check</method>
62
+ </bzall_upds>
63
+ </observers>
64
+ </controller_action_predispatch>
65
+ </events>
66
+ </adminhtml>
67
+ <global>
68
+ <models>
69
+ <all>
70
+ <class>Biztech_All_Model</class>
71
+ <resourceModel>all_mysql4</resourceModel>
72
+ </all>
73
+ <all_mysql4>
74
+ <class>Biztech_All_Model_Mysql4</class>
75
+ <entities>
76
+ <all>
77
+ <table>all</table>
78
+ </all>
79
+ </entities>
80
+ </all_mysql4>
81
+ </models>
82
+ <resources>
83
+ <all_setup>
84
+ <setup>
85
+ <module>Biztech_All</module>
86
+ </setup>
87
+ <connection>
88
+ <use>core_setup</use>
89
+ </connection>
90
+ </all_setup>
91
+ <all_write>
92
+ <connection>
93
+ <use>core_write</use>
94
+ </connection>
95
+ </all_write>
96
+ <all_read>
97
+ <connection>
98
+ <use>core_read</use>
99
+ </connection>
100
+ </all_read>
101
+ </resources>
102
+ <blocks>
103
+ <all>
104
+ <class>Biztech_All_Block</class>
105
+ </all>
106
+ </blocks>
107
+ <helpers>
108
+ <all>
109
+ <class>Biztech_All_Helper</class>
110
+ </all>
111
+ </helpers>
112
+ </global>
113
+ <default>
114
+ <all>
115
+ <all_general>
116
+ <check_frequency>86400</check_frequency>
117
+ </all_general>
118
+ </all>
119
+ </default>
120
+ </config>
app/code/local/Biztech/All/etc/system.xml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <config>
3
+ <tabs>
4
+ <biztech translate="label" module="all">
5
+ <label>Biztech Extensions</label>
6
+ <sort_order>400</sort_order>
7
+ </biztech>
8
+ </tabs>
9
+ <sections>
10
+ <all translate="label" module="all">
11
+ <label>Info</label>
12
+ <tab>biztech</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>10</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
+
20
+ <all_general translate="label">
21
+ <label>General</label>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>10</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
+ <fields>
28
+
29
+ <interests translate="label">
30
+ <label>I'd like to be informed by Biztech about:</label>
31
+ <comment></comment>
32
+ <frontend_type>multiselect</frontend_type>
33
+ <sort_order>100</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>1</show_in_store>
37
+ <can_be_empty>1</can_be_empty>
38
+ <source_model>all/source_updates_type</source_model>
39
+ </interests>
40
+
41
+ </fields>
42
+ </all_general>
43
+ </groups>
44
+ </all>
45
+ </sections>
46
+ </config>
app/code/local/Biztech/Desktopnotification/Block/Adminhtml/Desktopnotification.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Biztech_Desktopnotification_Block_Adminhtml_Desktopnotification extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_desktopnotification';
7
+ $this->_blockGroup = 'desktopnotification';
8
+ $this->_headerText = Mage::helper('desktopnotification')->__('Item Manager');
9
+ $this->_addButtonLabel = Mage::helper('desktopnotification')->__('Add Item');
10
+ parent::__construct();
11
+ }
12
+ }
app/code/local/Biztech/Desktopnotification/Block/Adminhtml/Page/Footer.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Biztech_Desktopnotification_Block_Adminhtml_Page_Footer extends Mage_Adminhtml_Block_Template
3
+ {
4
+ const LOCALE_CACHE_LIFETIME = 7200;
5
+ const LOCALE_CACHE_KEY = 'footer_locale';
6
+ const LOCALE_CACHE_TAG = 'adminhtml';
7
+
8
+ protected function _construct()
9
+ {
10
+ //check whether order notification module is enable or disabled & call different template according to that - added by BC(NR)
11
+ $getModuleStatus = Mage::getStoreConfig('desktopnotification/enablemodule/enable_notifications');
12
+ if($getModuleStatus == '1')
13
+ $this->setTemplate('desktopnotification/footer.phtml');
14
+ else
15
+ $this->setTemplate('page/footer.phtml');
16
+
17
+ $this->setShowProfiler(true);
18
+ }
19
+
20
+ public function getChangeLocaleUrl()
21
+ {
22
+ return $this->getUrl('adminhtml/index/changeLocale');
23
+ }
24
+
25
+ public function getUrlForReferer()
26
+ {
27
+ return $this->getUrlEncoded('*/*/*',array('_current'=>true));
28
+ }
29
+
30
+ public function getRefererParamName()
31
+ {
32
+ return Mage_Core_Controller_Varien_Action::PARAM_NAME_URL_ENCODED;
33
+ }
34
+
35
+ public function getLanguageSelect()
36
+ {
37
+ $locale = Mage::app()->getLocale();
38
+ $cacheId = self::LOCALE_CACHE_KEY . $locale->getLocaleCode();
39
+ $html = Mage::app()->loadCache($cacheId);
40
+
41
+ if (!$html) {
42
+ $html = $this->getLayout()->createBlock('adminhtml/html_select')
43
+ ->setName('locale')
44
+ ->setId('interface_locale')
45
+ ->setTitle(Mage::helper('page')->__('Interface Language'))
46
+ ->setExtraParams('style="width:200px"')
47
+ ->setValue($locale->getLocaleCode())
48
+ ->setOptions($locale->getTranslatedOptionLocales())
49
+ ->getHtml();
50
+ Mage::app()->saveCache($html, $cacheId, array(self::LOCALE_CACHE_TAG), self::LOCALE_CACHE_LIFETIME);
51
+ }
52
+
53
+ return $html;
54
+ }
55
+ }
app/code/local/Biztech/Desktopnotification/Block/Desktopnotification.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Biztech_Desktopnotification_Block_Desktopnotification extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ return parent::_prepareLayout();
7
+ }
8
+
9
+ public function getDesktopnotification()
10
+ {
11
+ if (!$this->hasData('desktopnotification')) {
12
+ $this->setData('desktopnotification', Mage::registry('desktopnotification'));
13
+ }
14
+ return $this->getData('desktopnotification');
15
+
16
+ }
17
+ }
app/code/local/Biztech/Desktopnotification/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Biztech_Desktopnotification_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+
5
+ }
app/code/local/Biztech/Desktopnotification/Model/Desktopnotification.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Biztech_Desktopnotification_Model_Desktopnotification extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('desktopnotification/desktopnotification');
9
+ }
10
+ }
app/code/local/Biztech/Desktopnotification/Model/Mysql4/Desktopnotification.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Biztech_Desktopnotification_Model_Mysql4_Desktopnotification extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the desktopnotification_id refers to the key field in your database table.
8
+ $this->_init('desktopnotification/desktopnotification', 'desktopnotification_id');
9
+ }
10
+ }
app/code/local/Biztech/Desktopnotification/Model/Mysql4/Desktopnotification/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Biztech_Desktopnotification_Model_Mysql4_Desktopnotification_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('desktopnotification/desktopnotification');
9
+ }
10
+ }
app/code/local/Biztech/Desktopnotification/Model/Notificationicon.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2006-2014 X.commerce, Inc. (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * System config image field backend model for Zend PDF generator
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Biztech_Desktopnotification_Model_Notificationicon extends Mage_Adminhtml_Model_System_Config_Backend_Image
36
+ {
37
+ /**
38
+ * The tail part of directory path for uploading
39
+ *
40
+ */
41
+ const UPLOAD_DIR = 'bcdesktopnotification/icon';
42
+
43
+ /**
44
+ * Token for the root part of directory path for uploading
45
+ *
46
+ */
47
+ const UPLOAD_ROOT = 'media';
48
+
49
+ /**
50
+ * Return path to directory for upload file
51
+ *
52
+ * @return string
53
+ * @throw Mage_Core_Exception
54
+ */
55
+ protected function _getUploadDir()
56
+ {
57
+ $uploadDir = $this->_appendScopeInfo(self::UPLOAD_DIR);
58
+ $uploadRoot = $this->_getUploadRoot(self::UPLOAD_ROOT);
59
+ $uploadDir = $uploadRoot . '/' . $uploadDir;
60
+ return $uploadDir;
61
+ }
62
+
63
+ /**
64
+ * Makes a decision about whether to add info about the scope.
65
+ *
66
+ * @return boolean
67
+ */
68
+ protected function _addWhetherScopeInfo()
69
+ {
70
+ return true;
71
+ }
72
+
73
+ /**
74
+ * Getter for allowed extensions of uploaded files.
75
+ *
76
+ * @return array
77
+ */
78
+ protected function _getAllowedExtensions()
79
+ {
80
+ return array('ico', 'png', 'gif', 'jpg', 'jpeg', 'apng', 'svg');
81
+ }
82
+
83
+ /**
84
+ * Get real media dir path
85
+ *
86
+ * @param $token
87
+ * @return string
88
+ */
89
+ protected function _getUploadRoot($token) {
90
+ return Mage::getBaseDir($token);
91
+ }
92
+ }
app/code/local/Biztech/Desktopnotification/Model/Observer.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Observer class for Supplier module
4
+ */
5
+ class Biztech_Desktopnotification_Model_Observer
6
+ {
7
+ /**
8
+ * this function will insert the order if in desktop notification table that will further notify the admin that order is placed.
9
+ */
10
+ public function desktopnotification(Varien_Event_Observer $observer)
11
+ {
12
+ //check whether order notification module is enable or disabled & call different template according to that - added by BC(NR)
13
+ $getModuleStatus = Mage::getStoreConfig('desktopnotification/enablemodule/enable_notifications');
14
+
15
+ /* if module is enabled than only it will enter the order in database for desktop notification */
16
+ if($getModuleStatus == '1') {
17
+ $orderDate = date("Y-m-d h:i:m");
18
+ $model = Mage::getModel('desktopnotification/desktopnotification');
19
+
20
+ $model->setIncrementId($observer->getOrder()->getIncrementId())
21
+ ->setNotifiyFlag(0)
22
+ ->setOrderDatetime($orderDate);
23
+
24
+ $model->save();
25
+ }
26
+ }
27
+ }
28
+ ?>
app/code/local/Biztech/Desktopnotification/Model/Status.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Biztech_Desktopnotification_Model_Status extends Varien_Object
4
+ {
5
+ const STATUS_ENABLED = 1;
6
+ const STATUS_DISABLED = 2;
7
+
8
+ static public function getOptionArray()
9
+ {
10
+ return array(
11
+ self::STATUS_ENABLED => Mage::helper('desktopnotification')->__('Enabled'),
12
+ self::STATUS_DISABLED => Mage::helper('desktopnotification')->__('Disabled')
13
+ );
14
+ }
15
+ }
app/code/local/Biztech/Desktopnotification/controllers/Adminhtml/DesktopnotificationController.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Biztech_Desktopnotification_Adminhtml_DesktopnotificationController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ /* function will get pending orders for notification and pass as json array */
6
+ public function indexAction() {
7
+ $ff = $this->getRequest()->getParam('firefox');
8
+ if($ff == 1) {
9
+ $getOrderCollection = Mage::getModel('desktopnotification/desktopnotification')->getCollection()
10
+ ->addFieldToFilter('notify_flag','0')
11
+ ->setPageSize(1);
12
+ }
13
+ else {
14
+ $getOrderCollection = Mage::getModel('desktopnotification/desktopnotification')->getCollection()
15
+ ->addFieldToFilter('notify_flag','0')
16
+ ->setPageSize(3);
17
+ }
18
+
19
+ $getOrderData = $getOrderCollection->getData();
20
+
21
+ for($i=0;$i<count($getOrderData);$i++)
22
+ {
23
+ $getOrdEntID = Mage::getModel('sales/order')->getCollection()
24
+ ->addFieldToFilter('increment_id',$getOrderData[$i]['increment_id'])
25
+ ->getFirstItem();
26
+ $getNotifyMsg = Mage::getStoreConfig('desktopnotification/notificationmessage/message',$getOrdEntID->getStoreId());
27
+ if(Mage::getStoreConfig('desktopnotification/uploadicon/upload_notification_icon')) {
28
+ $icon = Mage::getBaseUrl('media')."bcdesktopnotification/icon/".Mage::getStoreConfig('desktopnotification/uploadicon/upload_notification_icon',$getOrdEntID->getStoreId());
29
+ } else {
30
+ $icon = $this->getSkinUrl('favicon.ico');
31
+ }
32
+
33
+ $getOrdViewUrl= Mage::getUrl('adminhtml/sales_order/view',array('order_id'=>$getOrdEntID->getId()));
34
+ $jsonArray[] = array('increment_id'=>$getOrderData[$i]['increment_id'],'notification_message'=>$getNotifyMsg,'id'=>$getOrderData[$i]['desktopnotification_id'],'order_url'=>$getOrdViewUrl,'icon'=>$icon);
35
+ }
36
+ $jsonData = json_encode($jsonArray);
37
+ $this->getResponse()->setHeader('Content-type', 'application/json');
38
+ $this->getResponse()->setBody($jsonData);
39
+
40
+ }
41
+
42
+ /* function will update the notify flag after notification is displayed */
43
+ public function userAction()
44
+ {
45
+ $id = $this->getRequest()->getParam('id');
46
+ $model = Mage::getModel('desktopnotification/desktopnotification')->load($id)->addData(array('notify_flag'=>1));
47
+ try {
48
+ $model->setDesktopnotificationId($id)->save();
49
+ }catch(Exception $e) {
50
+ $e->getMessage();
51
+ }
52
+ }
53
+ }
app/code/local/Biztech/Desktopnotification/controllers/IndexController.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Biztech_Desktopnotification_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+
5
+ }
app/code/local/Biztech/Desktopnotification/etc/config.xml ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Biztech_Desktopnotification>
5
+ <version>0.1.0</version>
6
+ </Biztech_Desktopnotification>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <desktopnotification>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Biztech_Desktopnotification</module>
14
+ <frontName>desktopnotification</frontName>
15
+ </args>
16
+ </desktopnotification>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <desktopnotification>
21
+ <file>desktopnotification.xml</file>
22
+ </desktopnotification>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <admin>
27
+ <routers>
28
+ <desktopnotification>
29
+ <use>admin</use>
30
+ <args>
31
+ <module>Biztech_Desktopnotification</module>
32
+ <frontName>desktopnotification</frontName>
33
+ </args>
34
+ </desktopnotification>
35
+ </routers>
36
+ </admin>
37
+ <adminhtml>
38
+ <menu>
39
+ </menu>
40
+ <acl>
41
+ <resources>
42
+ <all>
43
+ <title>Allow Everything</title>
44
+ </all>
45
+ <admin>
46
+ <children>
47
+ <Biztech_Desktopnotification>
48
+ <title>Desktopnotification Module</title>
49
+ <sort_order>10</sort_order>
50
+ </Biztech_Desktopnotification>
51
+ <system>
52
+ <children>
53
+ <config>
54
+ <children>
55
+ <desktopnotification>
56
+ <title>Set Notification Message</title>
57
+ </desktopnotification>
58
+ </children>
59
+ </config>
60
+ </children>
61
+ </system>
62
+ </children>
63
+ </admin>
64
+ </resources>
65
+ </acl>
66
+ <layout>
67
+ <updates>
68
+ <desktopnotification>
69
+ <file>desktopnotification.xml</file>
70
+ </desktopnotification>
71
+ </updates>
72
+ </layout>
73
+ </adminhtml>
74
+ <global>
75
+ <models>
76
+ <desktopnotification>
77
+ <class>Biztech_Desktopnotification_Model</class>
78
+ <resourceModel>desktopnotification_mysql4</resourceModel>
79
+ </desktopnotification>
80
+ <desktopnotification_mysql4>
81
+ <class>Biztech_Desktopnotification_Model_Mysql4</class>
82
+ <entities>
83
+ <desktopnotification>
84
+ <table>desktopnotification</table>
85
+ </desktopnotification>
86
+ </entities>
87
+ </desktopnotification_mysql4>
88
+ </models>
89
+ <resources>
90
+ <desktopnotification_setup>
91
+ <setup>
92
+ <module>Biztech_Desktopnotification</module>
93
+ </setup>
94
+ <connection>
95
+ <use>core_setup</use>
96
+ </connection>
97
+ </desktopnotification_setup>
98
+ <desktopnotification_write>
99
+ <connection>
100
+ <use>core_write</use>
101
+ </connection>
102
+ </desktopnotification_write>
103
+ <desktopnotification_read>
104
+ <connection>
105
+ <use>core_read</use>
106
+ </connection>
107
+ </desktopnotification_read>
108
+ </resources>
109
+ <blocks>
110
+ <desktopnotification>
111
+ <class>Biztech_Desktopnotification_Block</class>
112
+ </desktopnotification>
113
+ <adminhtml>
114
+ <rewrite>
115
+ <page_footer>Biztech_Desktopnotification_Block_Adminhtml_Page_Footer</page_footer>
116
+ </rewrite>
117
+ </adminhtml>
118
+ </blocks>
119
+ <helpers>
120
+ <desktopnotification>
121
+ <class>Biztech_Desktopnotification_Helper</class>
122
+ </desktopnotification>
123
+ </helpers>
124
+ <events>
125
+ <sales_order_place_after>
126
+ <observers>
127
+ <orderNotifyEvent>
128
+ <class>desktopnotification/observer</class>
129
+ <method>desktopnotification</method>
130
+ </orderNotifyEvent>
131
+ </observers>
132
+ </sales_order_place_after>
133
+ </events>
134
+ </global>
135
+ </config>
app/code/local/Biztech/Desktopnotification/etc/system.xml ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <!--system configuration for notification module-->
3
+ <config>
4
+ <tabs>
5
+ <biztech module="desktopnotification" translate="label">
6
+ <label>Biztech Extension</label>
7
+ <sort_order>100</sort_order>
8
+ </biztech>
9
+ </tabs>
10
+ <sections>
11
+ <desktopnotification module="desktopnotification" translate="label">
12
+ <label>Desktop Notification</label>
13
+ <sort_order>200</sort_order>
14
+ <show_in_default>1</show_in_default>
15
+ <show_in_website>1</show_in_website>
16
+ <show_in_store>1</show_in_store>
17
+ <tab>biztech</tab>
18
+ <groups>
19
+ <notificationmessage translate="label">
20
+ <label>Set Notification Message</label>
21
+ <sort_order>10</sort_order>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>1</show_in_website>
24
+ <show_in_store>1</show_in_store>
25
+ <fields>
26
+ <message translate="label">
27
+ <label>Notification Message</label>
28
+ <show_in_default>1</show_in_default>
29
+ <show_in_website>1</show_in_website>
30
+ <show_in_store>1</show_in_store>
31
+ <frontend_type>text</frontend_type>
32
+ </message>
33
+ </fields>
34
+ </notificationmessage>
35
+ <enablemodule translate="label">
36
+ <label>Enable/Disable Notifications</label>
37
+ <sort_order>11</sort_order>
38
+ <show_in_default>1</show_in_default>
39
+ <show_in_website>1</show_in_website>
40
+ <show_in_store>1</show_in_store>
41
+ <fields>
42
+ <enable_notifications translate="label">
43
+ <label>Enable Notifications</label>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>1</show_in_store>
47
+ <frontend_type>select</frontend_type>
48
+ <source_model>adminhtml/system_config_source_yesno</source_model>
49
+ </enable_notifications>
50
+ </fields>
51
+ </enablemodule>
52
+ <uploadicon translate="label">
53
+ <label>Upload Notification Icon</label>
54
+ <sort_order>12</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ <fields>
59
+ <upload_notification_icon translate="label">
60
+ <label>Desktop Notification Icon</label>
61
+ <comment>Allowed file types: ICO, PNG, GIF, JPG, JPEG, APNG, SVG. If no icon is selected, it will use favicon. Not all browsers support all these formats!</comment>
62
+ <frontend_type>image</frontend_type>
63
+ <backend_model>Biztech_Desktopnotification_Model_Notificationicon</backend_model>
64
+ <upload_dir config="system/filesystem/media" scope_info="1">bcdesktopnotification/icon</upload_dir>
65
+ <base_url type="media" scope_info="1">bcdesktopnotification/icon</base_url>
66
+ <show_in_default>1</show_in_default>
67
+ <show_in_website>1</show_in_website>
68
+ <show_in_store>1</show_in_store>
69
+ </upload_notification_icon>
70
+ </fields>
71
+ </uploadicon>
72
+ </groups>
73
+ </desktopnotification>
74
+ </sections>
75
+ </config>
app/code/local/Biztech/Desktopnotification/sql/desktopnotification_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ -- DROP TABLE IF EXISTS {$this->getTable('desktopnotification')};
10
+ CREATE TABLE {$this->getTable('desktopnotification')} (
11
+ `desktopnotification_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
12
+ `increment_id` varchar(10) NOT NULL,
13
+ `notify_flag` tinyint(5) NOT NULL DEFAULT '0',
14
+ `order_datetime` datetime NOT NULL,
15
+ PRIMARY KEY (`desktopnotification_id`),
16
+ UNIQUE KEY `increment_id` (`increment_id`)
17
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
18
+
19
+ ");
20
+
21
+ $installer->endSetup();
app/design/adminhtml/default/default/template/desktopnotification/footer.phtml ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p class="bug-report">
2
+ <a href="<?php echo $this->getBugreportUrl() ?>" id="footer_bug_tracking"><?php echo $this->__('Help Us Keep Magento Healthy - Report All Bugs') ?></a><br/>
3
+ <?php echo $this->__('Interface Locale: %s', $this->getLanguageSelect()) ?>
4
+ </p>
5
+ <p class="legality">
6
+ <a href="<?php echo $this->getConnectWithMagentoUrl() ?>" id="footer_connect"><?php echo $this->__('Connect with the Magento Community') ?></a><br/>
7
+ <img src="<?php echo $this->getSkinUrl('images/varien_logo.gif') ?>" class="v-middle" alt="" />&nbsp;&nbsp;
8
+ <?php echo $this->__('Magento&trade; is a trademark of Magento Inc.<br/>Copyright &copy; %s Magento Inc.', date('Y')) ?>
9
+ </p>
10
+ <?php echo $this->__('Magento ver. %s', Mage::getVersion()) ?>
11
+ <script type="text/javascript">
12
+ $('footer_bug_tracking').target = 'Varien_External';
13
+ $('footer_connect').target = 'Varien_External';
14
+ function setInterfaceLanguage(evt){
15
+ var elem = Event.element(evt);
16
+ if(elem){
17
+ setLocation('<?php echo $this->getChangeLocaleUrl() ?>locale/'+elem.value+'/<?php echo $this->getRefererParamName() ?>/<?php echo $this->getUrlForReferer() ?>');
18
+ }
19
+ }
20
+ Event.observe('interface_locale', 'change', setInterfaceLanguage)
21
+ </script>
22
+
23
+
24
+
25
+
26
+ <!--script that will make ajax request at specified time interval to notify admin if any order is placed -->
27
+ <script type="text/javascript">
28
+
29
+ Event.observe(window, "load", function(){
30
+ ajaxCall();
31
+ });
32
+ setInterval(ajaxCall,20000);
33
+ function ajaxCall() {
34
+ var isFirefox = typeof InstallTrigger !== 'undefined';
35
+ var url = '<?php echo $this->getUrl('desktopnotification/adminhtml_desktopnotification/index'); ?>';
36
+ if(isFirefox == true) {
37
+ var params= {firefox : 1}
38
+ }
39
+ else {
40
+ var params= {firefox : 0}
41
+ }
42
+ new Ajax.Request(url,
43
+ {
44
+ method: 'post',
45
+ asynchronous: true,
46
+ onCreate: function(request) {
47
+ Ajax.Responders.unregister(varienLoaderHandler.handler);
48
+ },
49
+ onSuccess: function(transport) {
50
+ if(transport.status == 200) {
51
+ var response = transport.responseText;
52
+ response = response.evalJSON();
53
+ for(var i=0; i<response.length; i++) {
54
+ notifyMe(response[i].notification_message,response[i].increment_id,response[i].order_url,response[i].icon);
55
+ updateNotifyFlag(response[i].id);
56
+ }
57
+ if(response['error'] ){
58
+ $('login-please-wait').hide();
59
+ $('error_msg').show();
60
+ document.getElementById('error_msg').innerHTML = response['error'];
61
+ }
62
+ }
63
+ },
64
+ parameters : params
65
+ });
66
+ }
67
+
68
+ function notifyMe(notifyMsg,bodyText,orderUrl,msgicon) {
69
+ // Let's check if the browser supports notifications
70
+ if (!("Notification" in window)) {
71
+ alert("This browser does not support desktop notification");
72
+ }
73
+
74
+ // Let's check whether notification permissions have alredy been granted
75
+ else if (Notification.permission === "granted") {
76
+ // If it's okay let's create a notification
77
+ var notification = new Notification(notifyMsg,{ icon: msgicon, body: bodyText});
78
+ notification.onclick = function () {
79
+ var win = window.open(orderUrl,'_self');
80
+ };
81
+ setTimeout(function(){
82
+ notification.close(); //closes the notification
83
+ },10000);
84
+ }
85
+
86
+ // Otherwise, we need to ask the user for permission
87
+ else if (Notification.permission !== 'denied') {
88
+ Notification.requestPermission(function (permission) {
89
+ // If the user accepts, let's create a notification
90
+ if (permission === "granted") {
91
+ var notification = new Notification(notifyMsg,{ icon: "<?php if(Mage::getStoreConfig('desktopnotification/uploadicon/upload_notification_icon')) { echo Mage::getBaseUrl('media')."bcdesktopnotification/icon/".Mage::getStoreConfig('desktopnotification/uploadicon/upload_notification_icon'); } else { echo $this->getSkinUrl('favicon.ico'); } ?>", body: bodyText});
92
+ notification.onclick = function () {
93
+ var win = window.open(orderUrl,'_self');
94
+ };
95
+ setTimeout(function(){
96
+ notification.close(); //closes the notification
97
+ },10000);
98
+ }
99
+ });
100
+ }
101
+
102
+ notification.close();
103
+ }
104
+
105
+ function updateNotifyFlag(ordernotify_id) {
106
+ var url = '<?php echo $this->getUrl('desktopnotification/adminhtml_desktopnotification/user'); ?>';
107
+ var params= {id : ordernotify_id}
108
+ new Ajax.Request(url,
109
+ {
110
+ method: 'post',
111
+ asynchronous: true,
112
+ onCreate: function(request) {
113
+ Ajax.Responders.unregister(varienLoaderHandler.handler);
114
+ },
115
+ parameters : params
116
+ });
117
+ }
118
+ </script>
app/design/adminhtml/default/default/template/desktopnotification/ordernotification.phtml ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script type="text/javascript">
2
+ Event.observe(window, "load", function(){
3
+ ajaxCall();
4
+ });
5
+ setInterval(ajaxCall,30000);
6
+ function ajaxCall() {
7
+ var url = '<?php echo $this->getUrl('ordernotification/index/index'); ?>';
8
+ new Ajax.Request(url,
9
+ {
10
+ method: 'post',
11
+ asynchronous: true,
12
+ onSuccess: function(transport) {
13
+ if(transport.status == 200) {
14
+ var response = transport.responseText;
15
+ response = response.evalJSON();
16
+ for(var i=0; i<response.length; i++) {
17
+ notifyMe(response[i].notification_message,response[i].increment_id);
18
+ updateNotifyFlag(response[i].id);
19
+ }
20
+ if(response['error'] ){
21
+ $('login-please-wait').hide();
22
+ $('error_msg').show();
23
+ document.getElementById('error_msg').innerHTML = response['error'];
24
+ }
25
+ }
26
+ },
27
+ });
28
+ }
29
+
30
+ function notifyMe(notifyMsg,bodyText) {
31
+ // Let's check if the browser supports notifications
32
+ if (!("Notification" in window)) {
33
+ alert("This browser does not support desktop notification");
34
+ }
35
+
36
+ // Let's check whether notification permissions have alredy been granted
37
+ else if (Notification.permission === "granted") {
38
+ // If it's okay let's create a notification
39
+ var notification = new Notification(notifyMsg,{ icon: "alert.ico", body: bodyText});
40
+ setTimeout(function(){
41
+ notification.close(); //closes the notification
42
+ },5000);
43
+ }
44
+
45
+ // Otherwise, we need to ask the user for permission
46
+ else if (Notification.permission !== 'denied') {
47
+ Notification.requestPermission(function (permission) {
48
+ // If the user accepts, let's create a notification
49
+ if (permission === "granted") {
50
+ var notification = new Notification(notifyMsg,{ icon: "alert.ico", body: bodyText});
51
+ setTimeout(function(){
52
+ notification.close(); //closes the notification
53
+ },5000);
54
+ }
55
+ });
56
+ }
57
+
58
+
59
+ notification.close();
60
+ }
61
+
62
+ function updateNotifyFlag(ordernotify_id) {
63
+ var url = '<?php echo $this->getUrl('ordernotification/index/user'); ?>';
64
+ var params= {id : ordernotify_id}
65
+ new Ajax.Request(url,
66
+ {
67
+ method: 'post',
68
+ asynchronous: true,
69
+ parameters : params
70
+ });
71
+ }
72
+ </script>
73
+ <?php
74
+
75
+ ?>
app/etc/modules/Biztech_All.xml ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Biztech
5
+ * @package Biztech_All
6
+ * @author ModuleCreator
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Biztech_All>
13
+ <active>true</active>
14
+ <codePool>local</codePool>
15
+ </Biztech_All>
16
+ </modules>
17
+ <adminhtml>
18
+ <acl>
19
+ <resources>
20
+ <all>
21
+ <title>Allow Everything</title>
22
+ </all>
23
+ <admin>
24
+ <children>
25
+ <Biztech_All>
26
+ <title>All</title>
27
+ <sort_order>10</sort_order>
28
+ </Biztech_All>
29
+ <system>
30
+ <children>
31
+ <config>
32
+ <children>
33
+ <all>
34
+ <title>All</title>
35
+ </all>
36
+ </children>
37
+ </config>
38
+ </children>
39
+ </system>
40
+ </children>
41
+ </admin>
42
+ </resources>
43
+ </acl>
44
+ <layout>
45
+ <updates>
46
+ <all>
47
+ <file>all.xml</file>
48
+ </all>
49
+ </updates>
50
+ </layout>
51
+ </adminhtml>
52
+ </config>
app/etc/modules/Biztech_Desktopnotification.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Biztech_Desktopnotification>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Biztech_Desktopnotification>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>desktop_notification</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Desktop Notification extension for getting in admin side notification when order placed</summary>
10
+ <description>Desktop Notification extension is a Magento extension that pops up message to the admin of the store, on being online and any order is placed by someone. In the event of admin being off line the notifications of order placement gets queued up for display when the admin comes online. </description>
11
+ <notes>new release</notes>
12
+ <authors><author><name>Biztech</name><user>biztechcon</user><email>sales@biztechconsultancy.com</email></author></authors>
13
+ <date>2015-09-26</date>
14
+ <time>11:43:01</time>
15
+ <contents><target name="mageetc"><dir name="modules"><file name="Biztech_Desktopnotification.xml" hash="ffa573d2490131e332e726a7d54e0c0f"/><file name="Biztech_All.xml" hash="f4c3b9c029e56da8f09d7d71336c00f7"/></dir></target><target name="magelocal"><dir name="Biztech"><dir name="Desktopnotification"><dir name="Block"><dir name="Adminhtml"><file name="Desktopnotification.php" hash="1cbf6342b755ec8cddf06eb066bf58cc"/><dir name="Page"><file name="Footer.php" hash="c591eb6333eb913cd3036162fa220c64"/></dir></dir><file name="Desktopnotification.php" hash="49c768f239b7e5ac924c7ca81d478e9a"/></dir><dir name="Helper"><file name="Data.php" hash="3d186311d6d9dd3d35d5c03e8d63a992"/></dir><dir name="Model"><file name="Desktopnotification.php" hash="29e2e17f99d8572acf60b1af46c7ce62"/><dir name="Mysql4"><dir name="Desktopnotification"><file name="Collection.php" hash="8d7e1971482ab391a15938651fc2707b"/></dir><file name="Desktopnotification.php" hash="63ec61b76adab39d8aeea0c65b6805c2"/></dir><file name="Notificationicon.php" hash="dbaf5edc778fd78fe646892d5ab099d1"/><file name="Observer.php" hash="17a00269fc65c40ce3001d4ced311522"/><file name="Status.php" hash="e91b3cd16956bf5de2c072e8a4b1ecce"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="DesktopnotificationController.php" hash="21b5a3ebc0b85b322a7d59ad4c04dffc"/></dir><file name="IndexController.php" hash="23b04a6df6e269a83fd13ddd4b303152"/></dir><dir name="etc"><file name="config.xml" hash="106638ad5d159f6adcda9c1b3c1f98e7"/><file name="system.xml" hash="a881419fde69f2a4ddc5af1cf7dcde51"/></dir><dir name="sql"><dir name="desktopnotification_setup"><file name="mysql4-install-0.1.0.php" hash="30bec82f11dcad2704472d63ca55b9c8"/></dir></dir></dir><dir name="All"><dir name="Helper"><file name="Data.php" hash="e856726fd089e7f73ca7de450b696419"/></dir><dir name="Model"><file name="All.php" hash="a9aeeb9c6d7be9cf20414f405efc878d"/><dir name="Mysql4"><dir name="All"><file name="Collection.php" hash="a1909236183d126f38e628b85bb57e81"/></dir><file name="All.php" hash="f02542393eb26eadfb9b92d901d2ac12"/></dir><dir name="Source"><dir name="Updates"><file name="Type.php" hash="fa695bf4764c2d93c7436ed54bde89ba"/></dir></dir><file name="Status.php" hash="30a6f0da7d9d45e1082da532d5f8dabc"/><file name="Update.php" hash="8be940508b4ee734bf244ccdca9026ea"/></dir><dir name="etc"><file name="config.xml" hash="b6e9f1237b01397baec252c52bcb0ae4"/><file name="system.xml" hash="17262087dc933d934e09ac04cafb4c51"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="desktopnotification"><file name="footer.phtml" hash="71088dfeb0cf1a58cec875d0812ddf27"/><file name="ordernotification.phtml" hash="6960d8ea148f7b2a9d8b920cbc4563e1"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="."><file name="DesktopNotificaion.pdf" hash="66bee11b3612991bc16e7c9dd079fbf0"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>