Version Notes
Minor autentication updates
Download this release
Release Info
Developer | NEKLO |
Extension | neklo_monitor |
Version | 1.3.0 |
Comparing to | |
See all releases |
Code changes from version 1.2.2 to 1.3.0
- app/code/community/Neklo/Monitor/Block/Adminhtml/System/Config/Fieldset/Account.php +18 -0
- app/code/community/Neklo/Monitor/Block/Adminhtml/System/Config/Fieldset/Account/List.php +73 -0
- app/code/community/Neklo/Monitor/Block/Adminhtml/System/Config/Frontend/Button.php +33 -0
- app/code/community/Neklo/Monitor/Block/Adminhtml/System/Config/Frontend/Button/Connect.php +50 -0
- app/code/community/Neklo/Monitor/Block/Adminhtml/System/Config/Frontend/Button/Disconnect.php +41 -0
- app/code/community/Neklo/Monitor/Block/Adminhtml/System/Config/Frontend/Status.php +1 -0
- app/code/community/Neklo/Monitor/Block/Adminhtml/System/Config/Frontend/Version/Current.php +9 -0
- app/code/community/Neklo/Monitor/Block/Adminhtml/System/Config/Frontend/Version/Last.php +9 -0
- app/code/community/Neklo/Monitor/Controller/Abstract.php +4 -3
- app/code/community/Neklo/Monitor/Controller/Adminhtml/Abstract.php +20 -0
- app/code/community/Neklo/Monitor/Helper/Config.php +65 -3
- app/code/community/Neklo/Monitor/Helper/Feed.php +48 -0
- app/code/community/Neklo/Monitor/Helper/Header.php +6 -0
- app/code/community/Neklo/Monitor/Helper/Product.php +63 -0
- app/code/community/Neklo/Monitor/Helper/Request.php +1 -3
- app/code/community/Neklo/Monitor/Helper/Var/Report.php +102 -0
- app/code/community/Neklo/Monitor/Model/Account.php +14 -0
- app/code/community/Neklo/Monitor/Model/Cron.php +34 -0
- app/code/community/Neklo/Monitor/Model/Cron/Abstract.php +6 -52
- app/code/community/Neklo/Monitor/Model/Cron/Queue.php +152 -0
- app/code/community/Neklo/Monitor/Model/Cron/Statistic.php +50 -0
- app/code/community/Neklo/Monitor/Model/Cron/{Server.php → Statistic/Server.php} +2 -2
- app/code/community/Neklo/Monitor/Model/Cron/{Store.php → Statistic/Store.php} +2 -16
- app/code/community/Neklo/Monitor/Model/Cron/Var.php +17 -0
- app/code/community/Neklo/Monitor/Model/Gateway/Connector.php +91 -35
- app/code/community/Neklo/Monitor/Model/Gateway/Queue.php +12 -0
- app/code/community/Neklo/Monitor/Model/Log.php +78 -0
- app/code/community/Neklo/Monitor/Model/Log/Writer/Stream.php +79 -0
- app/code/community/Neklo/Monitor/Model/Minfo.php +47 -9
- app/code/community/Neklo/Monitor/Model/Minfo/Log.php +0 -195
- app/code/community/Neklo/Monitor/Model/Minfo/Parser.php +85 -161
- app/code/community/Neklo/Monitor/Model/Minfo/Report.php +0 -154
- app/code/community/Neklo/Monitor/Model/Observer.php +25 -155
- app/code/community/Neklo/Monitor/Model/Report.php +93 -0
- app/code/community/Neklo/Monitor/Model/Resource/Account.php +9 -0
- app/code/community/Neklo/Monitor/Model/Resource/Account/Collection.php +9 -0
- app/code/community/Neklo/Monitor/Model/Resource/Changelog.php +28 -18
- app/code/community/Neklo/Monitor/Model/Resource/Gateway/Queue.php +11 -8
- app/code/community/Neklo/Monitor/Model/Resource/Log.php +9 -0
- app/code/community/Neklo/Monitor/Model/Resource/Log/Collection.php +39 -0
- app/code/community/Neklo/Monitor/Model/Resource/Minfo/Daily.php +35 -37
- app/code/community/Neklo/Monitor/Model/Resource/Minfo/Daily/ReportsOrderCollection.php +39 -68
- app/code/community/Neklo/Monitor/Model/Resource/Minfo/Log.php +0 -55
- app/code/community/Neklo/Monitor/Model/Resource/Minfo/Log/Collection.php +0 -10
- app/code/community/Neklo/Monitor/Model/Resource/Minfo/Report.php +0 -49
- app/code/community/Neklo/Monitor/Model/Resource/Minfo/Report/Collection.php +0 -10
- app/code/community/Neklo/Monitor/Model/Resource/Report.php +62 -0
- app/code/community/Neklo/Monitor/Model/Resource/Report/Collection.php +39 -0
- app/code/community/Neklo/Monitor/Model/Source/Gateway/Queue/Type.php +13 -0
- app/code/community/Neklo/Monitor/Model/{System/Config/Source → Source/System/Config}/Server/Type.php +2 -2
- app/code/community/Neklo/Monitor/Model/System/Config/Backend/Token.php +0 -17
- app/code/community/Neklo/Monitor/controllers/Adminhtml/Neklo/Monitor/Gateway/AccountController.php +123 -0
- app/code/community/Neklo/Monitor/controllers/Adminhtml/Neklo/Monitor/GatewayController.php +33 -0
- app/code/community/Neklo/Monitor/controllers/CustomerController.php +23 -29
- app/code/community/Neklo/Monitor/controllers/OrderController.php +5 -26
- app/code/community/Neklo/Monitor/controllers/ProductController.php +3 -3
- app/code/community/Neklo/Monitor/controllers/Var/LogController.php +12 -11
- app/code/community/Neklo/Monitor/controllers/Var/ReportController.php +7 -7
- app/code/community/Neklo/Monitor/etc/config.xml +52 -20
- app/code/community/Neklo/Monitor/etc/system.xml +61 -132
- app/code/community/Neklo/Monitor/sql/neklo_monitor_setup/mysql4-upgrade-1.2.1-1.2.2.php +7 -0
- app/code/community/Neklo/Monitor/sql/neklo_monitor_setup/mysql4-upgrade-1.2.2-1.3.0.php +26 -0
- app/design/adminhtml/default/default/template/neklo/monitor/system/config/button/connect.phtml +22 -0
- app/design/adminhtml/default/default/template/neklo/monitor/system/config/button/disconnect.phtml +22 -0
- app/design/adminhtml/default/default/template/neklo/monitor/system/config/fieldset/account/list.phtml +268 -0
- package.xml +1 -1
- skin/adminhtml/default/default/neklo/monitor/css/styles.css +28 -0
app/code/community/Neklo/Monitor/Block/Adminhtml/System/Config/Fieldset/Account.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Block_Adminhtml_System_Config_Fieldset_Account extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
4 |
+
{
|
5 |
+
protected function _getHeaderHtml($element)
|
6 |
+
{
|
7 |
+
return parent::_getHeaderHtml($element) . $this->_getContentHtml();
|
8 |
+
}
|
9 |
+
|
10 |
+
protected function _getContentHtml()
|
11 |
+
{
|
12 |
+
$accountListBlock = $this->getLayout()->createBlock(
|
13 |
+
'neklo_monitor_adminhtml/system_config_fieldset_account_list',
|
14 |
+
'neklo_monitor_account_list'
|
15 |
+
);
|
16 |
+
return $accountListBlock->toHtml();
|
17 |
+
}
|
18 |
+
}
|
app/code/community/Neklo/Monitor/Block/Adminhtml/System/Config/Fieldset/Account/List.php
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Block_Adminhtml_System_Config_Fieldset_Account_List extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
$this->setTemplate('neklo/monitor/system/config/fieldset/account/list.phtml');
|
8 |
+
parent::__construct();
|
9 |
+
}
|
10 |
+
|
11 |
+
public function getAccountRows()
|
12 |
+
{
|
13 |
+
$collection = Mage::getResourceModel('neklo_monitor/account_collection');
|
14 |
+
foreach ($collection as $account) {
|
15 |
+
$account->setData('_id', $account->getId());
|
16 |
+
}
|
17 |
+
return $collection;
|
18 |
+
}
|
19 |
+
|
20 |
+
public function getElement()
|
21 |
+
{
|
22 |
+
return new Varien_Object();
|
23 |
+
}
|
24 |
+
|
25 |
+
protected function _prepareToRender()
|
26 |
+
{
|
27 |
+
$this->addColumn(
|
28 |
+
'phone_mask',
|
29 |
+
array(
|
30 |
+
'label' => $this->__('Phone'),
|
31 |
+
'style' => 'width:150px',
|
32 |
+
'class' => 'required-entry validate-neklo-monitor-phone',
|
33 |
+
)
|
34 |
+
);
|
35 |
+
$this->addColumn(
|
36 |
+
'firstname',
|
37 |
+
array(
|
38 |
+
'label' => $this->__('Firstname'),
|
39 |
+
'style' => 'width:150px',
|
40 |
+
'class' => 'required-entry',
|
41 |
+
)
|
42 |
+
);
|
43 |
+
$this->addColumn(
|
44 |
+
'lastname',
|
45 |
+
array(
|
46 |
+
'label' => $this->__('Lastname'),
|
47 |
+
'style' => 'width:150px',
|
48 |
+
'class' => 'required-entry',
|
49 |
+
)
|
50 |
+
);
|
51 |
+
$this->addColumn(
|
52 |
+
'email',
|
53 |
+
array(
|
54 |
+
'label' => $this->__('Email'),
|
55 |
+
'style' => 'width:150px',
|
56 |
+
'class' => 'required-entry validate-email',
|
57 |
+
)
|
58 |
+
);
|
59 |
+
$this->_addButtonLabel = $this->__('Add');
|
60 |
+
|
61 |
+
parent::_prepareToRender();
|
62 |
+
}
|
63 |
+
|
64 |
+
public function getSaveUrl()
|
65 |
+
{
|
66 |
+
return $this->getUrl('adminhtml/neklo_monitor_gateway_account/add');
|
67 |
+
}
|
68 |
+
|
69 |
+
public function getRemoveUrl()
|
70 |
+
{
|
71 |
+
return $this->getUrl('adminhtml/neklo_monitor_gateway_account/remove');
|
72 |
+
}
|
73 |
+
}
|
app/code/community/Neklo/Monitor/Block/Adminhtml/System/Config/Frontend/Button.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Block_Adminhtml_System_Config_Frontend_Button extends Mage_Adminhtml_Block_System_Config_Form_Field
|
4 |
+
{
|
5 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
6 |
+
{
|
7 |
+
$element->setScope(false);
|
8 |
+
$element->setCanUseWebsiteValue(false);
|
9 |
+
$element->setCanUseDefaultValue(false);
|
10 |
+
return parent::render($element);
|
11 |
+
}
|
12 |
+
|
13 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
14 |
+
{
|
15 |
+
if (!$this->_getConfig()->isConnected()) {
|
16 |
+
$button = $this->getLayout()->createBlock('neklo_monitor_adminhtml/system_config_frontend_button_connect', 'neklo_monitor_button');
|
17 |
+
$button->setTemplate('neklo/monitor/system/config/button/connect.phtml');
|
18 |
+
} else {
|
19 |
+
$button = $this->getLayout()->createBlock('neklo_monitor_adminhtml/system_config_frontend_button_disconnect', 'neklo_monitor_button');
|
20 |
+
$button->setTemplate('neklo/monitor/system/config/button/disconnect.phtml');
|
21 |
+
}
|
22 |
+
$button->setContainerId($element->getContainer()->getHtmlId());
|
23 |
+
return $button->toHtml();
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @return Neklo_Monitor_Helper_Config
|
28 |
+
*/
|
29 |
+
protected function _getConfig()
|
30 |
+
{
|
31 |
+
return Mage::helper('neklo_monitor/config');
|
32 |
+
}
|
33 |
+
}
|
app/code/community/Neklo/Monitor/Block/Adminhtml/System/Config/Frontend/Button/Connect.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Block_Adminhtml_System_Config_Frontend_Button_Connect extends Mage_Adminhtml_Block_Template
|
4 |
+
{
|
5 |
+
protected $_api = null;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* @return Mage_Adminhtml_Block_Widget_Button
|
9 |
+
*/
|
10 |
+
public function getButton()
|
11 |
+
{
|
12 |
+
$button = $this->getLayout()->createBlock('adminhtml/widget_button');
|
13 |
+
$button
|
14 |
+
->setType('button')
|
15 |
+
->setLabel($this->__('Connect to Gateway'))
|
16 |
+
->setStyle("width:280px")
|
17 |
+
->setId('neklo_monitor_button')
|
18 |
+
;
|
19 |
+
return $button;
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @return string
|
24 |
+
*/
|
25 |
+
public function getButtonHtml()
|
26 |
+
{
|
27 |
+
return $this->getButton()->toHtml();
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @return string
|
32 |
+
*/
|
33 |
+
public function getContainerId()
|
34 |
+
{
|
35 |
+
return parent::getContainerId();
|
36 |
+
}
|
37 |
+
|
38 |
+
public function getConnectUrl()
|
39 |
+
{
|
40 |
+
return $this->getUrl('adminhtml/neklo_monitor_gateway/connect');
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @return Neklo_Monitor_Helper_Config
|
45 |
+
*/
|
46 |
+
protected function _getConfig()
|
47 |
+
{
|
48 |
+
return Mage::helper('neklo_monitor/config');
|
49 |
+
}
|
50 |
+
}
|
app/code/community/Neklo/Monitor/Block/Adminhtml/System/Config/Frontend/Button/Disconnect.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Block_Adminhtml_System_Config_Frontend_Button_Disconnect extends Mage_Adminhtml_Block_Template
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* @return Mage_Adminhtml_Block_Widget_Button
|
7 |
+
*/
|
8 |
+
public function getButton()
|
9 |
+
{
|
10 |
+
$button = $this->getLayout()->createBlock('adminhtml/widget_button');
|
11 |
+
$button
|
12 |
+
->setType('button')
|
13 |
+
->setLabel($this->__('Disconnect'))
|
14 |
+
->setStyle("width:280px")
|
15 |
+
->setId('neklo_monitor_button')
|
16 |
+
->setClass('delete')
|
17 |
+
;
|
18 |
+
return $button;
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return string
|
23 |
+
*/
|
24 |
+
public function getButtonHtml()
|
25 |
+
{
|
26 |
+
return $this->getButton()->toHtml();
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @return string
|
31 |
+
*/
|
32 |
+
public function getContainerId()
|
33 |
+
{
|
34 |
+
return parent::getContainerId();
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getDisconnectUrl()
|
38 |
+
{
|
39 |
+
return Mage::helper("adminhtml")->getUrl("adminhtml/neklo_monitor_gateway/disconnect");
|
40 |
+
}
|
41 |
+
}
|
app/code/community/Neklo/Monitor/Block/Adminhtml/System/Config/Frontend/Status.php
CHANGED
@@ -13,6 +13,7 @@ class Neklo_Monitor_Block_Adminhtml_System_Config_Frontend_Status extends Mage_A
|
|
13 |
if ($this->_getConfig()->isConnected($serverType)) {
|
14 |
$element->setValue($this->__('Connected to the %s Gateway', $serverType));
|
15 |
$element->addClass('gateway_status')->addClass('success');
|
|
|
16 |
} else {
|
17 |
$element->setValue($this->__('Not connected to the %s Gateway', $serverType));
|
18 |
$element->addClass('gateway_status')->addClass('error');
|
13 |
if ($this->_getConfig()->isConnected($serverType)) {
|
14 |
$element->setValue($this->__('Connected to the %s Gateway', $serverType));
|
15 |
$element->addClass('gateway_status')->addClass('success');
|
16 |
+
$element->setComment('');
|
17 |
} else {
|
18 |
$element->setValue($this->__('Not connected to the %s Gateway', $serverType));
|
19 |
$element->addClass('gateway_status')->addClass('error');
|
app/code/community/Neklo/Monitor/Block/Adminhtml/System/Config/Frontend/Version/Current.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Block_Adminhtml_System_Config_Frontend_Version_Current extends Neklo_Monitor_Block_Adminhtml_System_Config_Frontend_Label
|
4 |
+
{
|
5 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
6 |
+
{
|
7 |
+
return '<p id="'. $element->getHtmlId() . '">' . Mage::helper('neklo_monitor/config')->getModuleVersion() .'</p>';
|
8 |
+
}
|
9 |
+
}
|
app/code/community/Neklo/Monitor/Block/Adminhtml/System/Config/Frontend/Version/Last.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Block_Adminhtml_System_Config_Frontend_Version_Last extends Neklo_Monitor_Block_Adminhtml_System_Config_Frontend_Label
|
4 |
+
{
|
5 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
6 |
+
{
|
7 |
+
return '<p id="'. $element->getHtmlId() . '">' . Mage::helper('neklo_monitor/config')->getLastVersion() .'</p>';
|
8 |
+
}
|
9 |
+
}
|
app/code/community/Neklo/Monitor/Controller/Abstract.php
CHANGED
@@ -3,7 +3,6 @@
|
|
3 |
class Neklo_Monitor_Controller_Abstract extends Mage_Core_Controller_Front_Action
|
4 |
{
|
5 |
const PAGE_SIZE = 50;
|
6 |
-
const API_VERSION_HEADER = 'X-API-Version';
|
7 |
|
8 |
// some controllers (auth) should skip isConnected checking @see preDispatch
|
9 |
protected $_allowConnectedOnly = true;
|
@@ -52,7 +51,10 @@ class Neklo_Monitor_Controller_Abstract extends Mage_Core_Controller_Front_Actio
|
|
52 |
|
53 |
public function postDispatch()
|
54 |
{
|
55 |
-
$this->getResponse()->setHeader(
|
|
|
|
|
|
|
56 |
return parent::postDispatch();
|
57 |
}
|
58 |
|
@@ -77,5 +79,4 @@ class Neklo_Monitor_Controller_Abstract extends Mage_Core_Controller_Front_Actio
|
|
77 |
{
|
78 |
return Mage::helper('neklo_monitor/config');
|
79 |
}
|
80 |
-
|
81 |
}
|
3 |
class Neklo_Monitor_Controller_Abstract extends Mage_Core_Controller_Front_Action
|
4 |
{
|
5 |
const PAGE_SIZE = 50;
|
|
|
6 |
|
7 |
// some controllers (auth) should skip isConnected checking @see preDispatch
|
8 |
protected $_allowConnectedOnly = true;
|
51 |
|
52 |
public function postDispatch()
|
53 |
{
|
54 |
+
$this->getResponse()->setHeader(
|
55 |
+
Neklo_Monitor_Helper_Header::GATEWAY_API_VERSION_HEADER,
|
56 |
+
$this->_getConfigHelper()->getGatewayApiVersion()
|
57 |
+
);
|
58 |
return parent::postDispatch();
|
59 |
}
|
60 |
|
79 |
{
|
80 |
return Mage::helper('neklo_monitor/config');
|
81 |
}
|
|
|
82 |
}
|
app/code/community/Neklo/Monitor/Controller/Adminhtml/Abstract.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Controller_Adminhtml_Abstract extends Mage_Adminhtml_Controller_Action
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* @return Neklo_Monitor_Model_Gateway_Connector
|
7 |
+
*/
|
8 |
+
protected function _getConnector()
|
9 |
+
{
|
10 |
+
return Mage::getSingleton('neklo_monitor/gateway_connector');
|
11 |
+
}
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @return Neklo_Monitor_Helper_Config
|
15 |
+
*/
|
16 |
+
protected function _getConfig()
|
17 |
+
{
|
18 |
+
return Mage::helper('neklo_monitor/config');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Neklo/Monitor/Helper/Config.php
CHANGED
@@ -14,6 +14,8 @@ class Neklo_Monitor_Helper_Config extends Mage_Core_Helper_Data
|
|
14 |
const GATEWAY_FREQUENCY = 'neklo_monitor/gateway/plan_frequency';
|
15 |
const GATEWAY_LAST_UPDATE = 'neklo_monitor/gateway/last_update';
|
16 |
|
|
|
|
|
17 |
protected $_gatewayConfig = array(
|
18 |
'type' => self::GATEWAY_PLAN,
|
19 |
'frequency' => self::GATEWAY_FREQUENCY,
|
@@ -21,7 +23,35 @@ class Neklo_Monitor_Helper_Config extends Mage_Core_Helper_Data
|
|
21 |
|
22 |
public function getModuleVersion()
|
23 |
{
|
24 |
-
return (string)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
}
|
26 |
|
27 |
public function isEnabled()
|
@@ -78,7 +108,7 @@ class Neklo_Monitor_Helper_Config extends Mage_Core_Helper_Data
|
|
78 |
public function getGatewayServerUri()
|
79 |
{
|
80 |
$serverType = $this->getGatewayServerType();
|
81 |
-
return Mage::getModel('neklo_monitor/
|
82 |
}
|
83 |
|
84 |
public function getGatewaySid()
|
@@ -106,6 +136,16 @@ class Neklo_Monitor_Helper_Config extends Mage_Core_Helper_Data
|
|
106 |
Mage::getConfig()->reinit();
|
107 |
}
|
108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
public function updateGatewayConfig($config)
|
110 |
{
|
111 |
$serverType = $this->getGatewayServerType();
|
@@ -140,6 +180,29 @@ class Neklo_Monitor_Helper_Config extends Mage_Core_Helper_Data
|
|
140 |
return Mage::getStoreConfig(self::GATEWAY_LAST_UPDATE . '_' . $serverType);
|
141 |
}
|
142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
protected function _updateGatewayLastUpdate()
|
144 |
{
|
145 |
$serverType = $this->getGatewayServerType();
|
@@ -151,5 +214,4 @@ class Neklo_Monitor_Helper_Config extends Mage_Core_Helper_Data
|
|
151 |
$configModel = Mage::getModel('core/config');
|
152 |
$configModel->saveConfig($path, $value, $scope, $scopeId);
|
153 |
}
|
154 |
-
|
155 |
}
|
14 |
const GATEWAY_FREQUENCY = 'neklo_monitor/gateway/plan_frequency';
|
15 |
const GATEWAY_LAST_UPDATE = 'neklo_monitor/gateway/last_update';
|
16 |
|
17 |
+
const CRON_REPORT_COLLECTED_AT = 'neklo_monitor/cron/report_collected_at';
|
18 |
+
|
19 |
protected $_gatewayConfig = array(
|
20 |
'type' => self::GATEWAY_PLAN,
|
21 |
'frequency' => self::GATEWAY_FREQUENCY,
|
23 |
|
24 |
public function getModuleVersion()
|
25 |
{
|
26 |
+
return (string)Mage::getConfig()->getNode('modules/Neklo_Monitor/version');
|
27 |
+
}
|
28 |
+
|
29 |
+
public function getLastVersion()
|
30 |
+
{
|
31 |
+
$feed = Mage::helper('neklo_monitor/feed')->getFeed();
|
32 |
+
$extensionKey = strtolower($this->_getModuleName());
|
33 |
+
if (!array_key_exists($extensionKey, $feed)) {
|
34 |
+
return null;
|
35 |
+
}
|
36 |
+
if (!is_array($feed[$extensionKey]) || !array_key_exists('version', $feed[$extensionKey])) {
|
37 |
+
return null;
|
38 |
+
}
|
39 |
+
return $feed[$extensionKey]['version'];
|
40 |
+
}
|
41 |
+
|
42 |
+
public function isUpdateAvailable()
|
43 |
+
{
|
44 |
+
return version_compare($this->getLastVersion(), $this->getModuleVersion(), 'g');
|
45 |
+
}
|
46 |
+
|
47 |
+
public function getGatewayApiVersion()
|
48 |
+
{
|
49 |
+
return (string)Mage::getConfig()->getNode('modules/Neklo_Monitor/api_version');
|
50 |
+
}
|
51 |
+
|
52 |
+
public function getPlatform()
|
53 |
+
{
|
54 |
+
return (string)Mage::getConfig()->getNode('modules/Neklo_Monitor/platform');
|
55 |
}
|
56 |
|
57 |
public function isEnabled()
|
108 |
public function getGatewayServerUri()
|
109 |
{
|
110 |
$serverType = $this->getGatewayServerType();
|
111 |
+
return Mage::getModel('neklo_monitor/source_system_config_server_type')->getServerUri($serverType);
|
112 |
}
|
113 |
|
114 |
public function getGatewaySid()
|
136 |
Mage::getConfig()->reinit();
|
137 |
}
|
138 |
|
139 |
+
public function disconnect()
|
140 |
+
{
|
141 |
+
$serverType = $this->getGatewayServerType();
|
142 |
+
$this->_saveConfig(self::GATEWAY_SID . '_' . $serverType, null);
|
143 |
+
$this->_updateTokenCreatedAt(0); // invalidate Token
|
144 |
+
|
145 |
+
// reinit configuration cache
|
146 |
+
Mage::getConfig()->reinit();
|
147 |
+
}
|
148 |
+
|
149 |
public function updateGatewayConfig($config)
|
150 |
{
|
151 |
$serverType = $this->getGatewayServerType();
|
180 |
return Mage::getStoreConfig(self::GATEWAY_LAST_UPDATE . '_' . $serverType);
|
181 |
}
|
182 |
|
183 |
+
public function getCronReportCollectedAt()
|
184 |
+
{
|
185 |
+
return (int)Mage::getStoreConfig(self::CRON_REPORT_COLLECTED_AT);
|
186 |
+
}
|
187 |
+
|
188 |
+
public function updateCronReportCollectedAt()
|
189 |
+
{
|
190 |
+
$this->_saveConfig(self::CRON_REPORT_COLLECTED_AT, time());
|
191 |
+
}
|
192 |
+
|
193 |
+
public function getExtensionUrl()
|
194 |
+
{
|
195 |
+
$feed = Mage::helper('neklo_monitor/feed')->getFeed();
|
196 |
+
$extensionKey = strtolower($this->_getModuleName());
|
197 |
+
if (!array_key_exists($extensionKey, $feed)) {
|
198 |
+
return null;
|
199 |
+
}
|
200 |
+
if (!is_array($feed[$extensionKey]) || !array_key_exists('url', $feed[$extensionKey])) {
|
201 |
+
return null;
|
202 |
+
}
|
203 |
+
return $feed[$extensionKey]['url'];
|
204 |
+
}
|
205 |
+
|
206 |
protected function _updateGatewayLastUpdate()
|
207 |
{
|
208 |
$serverType = $this->getGatewayServerType();
|
214 |
$configModel = Mage::getModel('core/config');
|
215 |
$configModel->saveConfig($path, $value, $scope, $scopeId);
|
216 |
}
|
|
|
217 |
}
|
app/code/community/Neklo/Monitor/Helper/Feed.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Helper_Feed
|
4 |
+
{
|
5 |
+
const FEED_URL = 'http://store.neklo.com/feed.json';
|
6 |
+
const CACHE_ID = 'NEKLO_EXTENSION_FEED';
|
7 |
+
const CACHE_LIFETIME = 172800;
|
8 |
+
|
9 |
+
public function getFeed()
|
10 |
+
{
|
11 |
+
if (!$feed = Mage::app()->loadCache(self::CACHE_ID)) {
|
12 |
+
$feed = $this->_getFeedFromResource();
|
13 |
+
$this->_save($feed);
|
14 |
+
}
|
15 |
+
$feedArray = Mage::helper('core')->jsonDecode($feed);
|
16 |
+
if (!is_array($feedArray)) {
|
17 |
+
$feedArray = array();
|
18 |
+
}
|
19 |
+
return $feedArray;
|
20 |
+
}
|
21 |
+
|
22 |
+
protected function _getFeedFromResource()
|
23 |
+
{
|
24 |
+
$ch = curl_init();
|
25 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
26 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
27 |
+
curl_setopt($ch, CURLOPT_URL, self::FEED_URL);
|
28 |
+
curl_setopt(
|
29 |
+
$ch,
|
30 |
+
CURLOPT_HTTPHEADER,
|
31 |
+
array(
|
32 |
+
'Content-Type: application/json'
|
33 |
+
)
|
34 |
+
);
|
35 |
+
$result = curl_exec($ch);
|
36 |
+
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) != 200) {
|
37 |
+
$result = '{}';
|
38 |
+
}
|
39 |
+
curl_close($ch);
|
40 |
+
return $result;
|
41 |
+
}
|
42 |
+
|
43 |
+
protected function _save($feed)
|
44 |
+
{
|
45 |
+
Mage::app()->saveCache($feed, self::CACHE_ID, array(), self::CACHE_LIFETIME);
|
46 |
+
return $this;
|
47 |
+
}
|
48 |
+
}
|
app/code/community/Neklo/Monitor/Helper/Header.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Helper_Header extends Mage_Core_Helper_Data
|
4 |
+
{
|
5 |
+
const GATEWAY_API_VERSION_HEADER = 'X-Gateway-Api-Version';
|
6 |
+
}
|
app/code/community/Neklo/Monitor/Helper/Product.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Helper_Product extends Mage_Core_Helper_Data
|
4 |
+
{
|
5 |
+
// TODO: clean
|
6 |
+
/**
|
7 |
+
* @param null $storeId
|
8 |
+
* @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
|
9 |
+
*/
|
10 |
+
public function getProductsOutofstockCollection($storeId = null)
|
11 |
+
{
|
12 |
+
/* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection */
|
13 |
+
$collection = Mage::getResourceModel('catalog/product_collection');
|
14 |
+
if ($storeId) {
|
15 |
+
$collection->addStoreFilter($storeId);
|
16 |
+
}
|
17 |
+
|
18 |
+
$collection->addAttributeToFilter(
|
19 |
+
'status',
|
20 |
+
array('in' => Mage::getSingleton('catalog/product_status')->getSaleableStatusIds())
|
21 |
+
);
|
22 |
+
|
23 |
+
// copy-pasted from CE 1.4 Layer Model
|
24 |
+
/*
|
25 |
+
$attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
|
26 |
+
$collection->addAttributeToSelect($attributes)
|
27 |
+
->addMinimalPrice()
|
28 |
+
->addFinalPrice()
|
29 |
+
->addTaxPercents()
|
30 |
+
;
|
31 |
+
*/
|
32 |
+
|
33 |
+
$collection->addAttributeToSelect(
|
34 |
+
array(
|
35 |
+
'name',
|
36 |
+
'price',
|
37 |
+
'small_image', // exists in collection when Flat Product is enabled
|
38 |
+
)
|
39 |
+
);
|
40 |
+
$collection
|
41 |
+
->joinField(
|
42 |
+
'is_in_stock',
|
43 |
+
'cataloginventory/stock_item',
|
44 |
+
'is_in_stock',
|
45 |
+
'product_id=entity_id',
|
46 |
+
'{{table}}.stock_id=1',
|
47 |
+
'left'
|
48 |
+
)
|
49 |
+
->addAttributeToFilter('is_in_stock', 0)
|
50 |
+
// TODO: investigate qty = 0
|
51 |
+
// ->joinField(
|
52 |
+
// 'qty',
|
53 |
+
// 'cataloginventory/stock_item',
|
54 |
+
// 'qty',
|
55 |
+
// 'product_id=entity_id',
|
56 |
+
// '{{table}}.stock_id=1',
|
57 |
+
// 'left'
|
58 |
+
// )
|
59 |
+
// ->addAttributeToFilter('qty', array('eq' => 0))
|
60 |
+
;
|
61 |
+
return $collection;
|
62 |
+
}
|
63 |
+
}
|
app/code/community/Neklo/Monitor/Helper/Request.php
CHANGED
@@ -25,9 +25,8 @@ class Neklo_Monitor_Helper_Request
|
|
25 |
),
|
26 |
|
27 |
'auth/ping' => array(),
|
28 |
-
'auth/index' => array(
|
29 |
'sid',
|
30 |
-
'device_id',
|
31 |
'plan',
|
32 |
'token',
|
33 |
),
|
@@ -81,7 +80,6 @@ class Neklo_Monitor_Helper_Request
|
|
81 |
'customer/list' => 'dashboard//common',
|
82 |
'customer/online' => 'dashboard//common',
|
83 |
|
84 |
-
'config/alertsave' => 'dashboard//common',
|
85 |
'product/outofstock' => 'dashboard//common',
|
86 |
'order/list' => 'dashboard//common',
|
87 |
|
25 |
),
|
26 |
|
27 |
'auth/ping' => array(),
|
28 |
+
'auth/index' => array(
|
29 |
'sid',
|
|
|
30 |
'plan',
|
31 |
'token',
|
32 |
),
|
80 |
'customer/list' => 'dashboard//common',
|
81 |
'customer/online' => 'dashboard//common',
|
82 |
|
|
|
83 |
'product/outofstock' => 'dashboard//common',
|
84 |
'order/list' => 'dashboard//common',
|
85 |
|
app/code/community/Neklo/Monitor/Helper/Var/Report.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Helper_Var_Report extends Mage_Core_Helper_Data
|
4 |
+
{
|
5 |
+
const VAR_REPORT = 'report';
|
6 |
+
|
7 |
+
public function collectReports()
|
8 |
+
{
|
9 |
+
$fileList = $this->_collectReportFiles();
|
10 |
+
$reportList = $this->_prepareFileData($fileList);
|
11 |
+
return $reportList;
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _collectReportFiles()
|
15 |
+
{
|
16 |
+
$directoryPath = Mage::getBaseDir('var') . DS . self::VAR_REPORT . DS;
|
17 |
+
if (!is_dir($directoryPath) || ! is_readable($directoryPath)) {
|
18 |
+
return false;
|
19 |
+
}
|
20 |
+
|
21 |
+
$lastCollectedAt = $this->_getConfig()->getCronReportCollectedAt();
|
22 |
+
|
23 |
+
$count = 0;
|
24 |
+
$directoryIterator = new RecursiveIteratorIterator(
|
25 |
+
new RecursiveDirectoryIterator($directoryPath, RecursiveDirectoryIterator::SKIP_DOTS),
|
26 |
+
RecursiveIteratorIterator::SELF_FIRST,
|
27 |
+
RecursiveIteratorIterator::CATCH_GET_CHILD
|
28 |
+
);
|
29 |
+
$fileList = array();
|
30 |
+
foreach ($directoryIterator as $file) {
|
31 |
+
/* @var SplFileInfo $file */
|
32 |
+
if (!$file->isFile()) {
|
33 |
+
continue;
|
34 |
+
}
|
35 |
+
if ($lastCollectedAt >= $file->getMTime()) {
|
36 |
+
continue;
|
37 |
+
}
|
38 |
+
$fileList[] = $file;
|
39 |
+
$count++;
|
40 |
+
}
|
41 |
+
$this->_getConfig()->updateCronReportCollectedAt();
|
42 |
+
|
43 |
+
return $fileList;
|
44 |
+
}
|
45 |
+
|
46 |
+
protected function _prepareFileData(array $fileList)
|
47 |
+
{
|
48 |
+
$preparedFileList = array();
|
49 |
+
|
50 |
+
/* @var SplFileInfo $file */
|
51 |
+
foreach ($fileList as $file) {
|
52 |
+
$reportContent = file_get_contents($file->getPathname());
|
53 |
+
$reportData = @unserialize($reportContent);
|
54 |
+
if (!$reportData || !is_array($reportData) || !count($reportData)) {
|
55 |
+
continue;
|
56 |
+
}
|
57 |
+
|
58 |
+
$message = $reportData[0];
|
59 |
+
$hash = md5($message);
|
60 |
+
if (array_key_exists($hash, $preparedFileList) && is_array($preparedFileList[$hash])) {
|
61 |
+
$preparedFileList[$hash]['qty']++;
|
62 |
+
if ($file->getMTime() < $preparedFileList[$hash]['first_time']) {
|
63 |
+
$preparedFileList[$hash]['first_time'] = $file->getMTime();
|
64 |
+
}
|
65 |
+
if ($file->getMTime() > $preparedFileList[$hash]['last_time']) {
|
66 |
+
$preparedFileList[$hash]['last_time'] = $file->getMTime();
|
67 |
+
}
|
68 |
+
$preparedFileList[$hash]['files'][] = array(
|
69 |
+
'name' => $file->getFilename(),
|
70 |
+
'path' => $file->getPathname(),
|
71 |
+
'time' => $file->getMTime(),
|
72 |
+
'size' => $file->getSize(),
|
73 |
+
);
|
74 |
+
} else {
|
75 |
+
$preparedFileList[$hash] = array(
|
76 |
+
'hash' => $hash,
|
77 |
+
'message' => $message,
|
78 |
+
'qty' => 1,
|
79 |
+
'first_time' => $file->getMTime(),
|
80 |
+
'last_time' => $file->getMTime(),
|
81 |
+
'files' => array(
|
82 |
+
array(
|
83 |
+
'name' => $file->getFilename(),
|
84 |
+
'path' => $file->getPathname(),
|
85 |
+
'time' => $file->getMTime(),
|
86 |
+
'size' => $file->getSize(),
|
87 |
+
)
|
88 |
+
),
|
89 |
+
);
|
90 |
+
}
|
91 |
+
}
|
92 |
+
return $preparedFileList;
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* @return Neklo_Monitor_Helper_Config
|
97 |
+
*/
|
98 |
+
protected function _getConfig()
|
99 |
+
{
|
100 |
+
return Mage::helper('neklo_monitor/config');
|
101 |
+
}
|
102 |
+
}
|
app/code/community/Neklo/Monitor/Model/Account.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Model_Account extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
protected function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('neklo_monitor/account');
|
8 |
+
}
|
9 |
+
|
10 |
+
public function loadByPhoneHash($phoneHash)
|
11 |
+
{
|
12 |
+
return $this->load($phoneHash, 'phone_hash');
|
13 |
+
}
|
14 |
+
}
|
app/code/community/Neklo/Monitor/Model/Cron.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Model_Cron
|
4 |
+
{
|
5 |
+
public function sendServerInfo(Mage_Cron_Model_Schedule $schedule)
|
6 |
+
{
|
7 |
+
Mage::getModel('neklo_monitor/cron_statistic_server')->run($schedule);
|
8 |
+
}
|
9 |
+
|
10 |
+
public function sendStoreInfo(Mage_Cron_Model_Schedule $schedule)
|
11 |
+
{
|
12 |
+
Mage::getModel('neklo_monitor/cron_statistic_store')->run($schedule);
|
13 |
+
}
|
14 |
+
|
15 |
+
public function collectVarReports(Mage_Cron_Model_Schedule $schedule)
|
16 |
+
{
|
17 |
+
Mage::getModel('neklo_monitor/cron_var')->collectReports($schedule);
|
18 |
+
}
|
19 |
+
|
20 |
+
public function convertInventoryChangelogToQueue(Mage_Cron_Model_Schedule $schedule)
|
21 |
+
{
|
22 |
+
Mage::getModel('neklo_monitor/cron_queue')->convertInventoryChangelogToQueue($schedule);
|
23 |
+
}
|
24 |
+
|
25 |
+
public function aggregateSalesReportOrderData(Mage_Cron_Model_Schedule $schedule)
|
26 |
+
{
|
27 |
+
Mage::getModel('neklo_monitor/cron_queue')->aggregateSalesReportOrderData($schedule);
|
28 |
+
}
|
29 |
+
|
30 |
+
public function sendQueue(Mage_Cron_Model_Schedule $schedule)
|
31 |
+
{
|
32 |
+
Mage::getModel('neklo_monitor/cron_queue')->sendQueue($schedule);
|
33 |
+
}
|
34 |
+
}
|
app/code/community/Neklo/Monitor/Model/Cron/Abstract.php
CHANGED
@@ -2,50 +2,12 @@
|
|
2 |
|
3 |
abstract class Neklo_Monitor_Model_Cron_Abstract
|
4 |
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
if (!$this->_getConfig()->isEnabled()) {
|
10 |
-
$schedule->setMessages('Disabled');
|
11 |
-
return;
|
12 |
-
}
|
13 |
-
|
14 |
-
if (!$this->_getConfig()->isConnected()) {
|
15 |
-
$schedule->setMessages('Not connected');
|
16 |
-
return;
|
17 |
-
}
|
18 |
-
|
19 |
-
if ($this->_isLocked()) {
|
20 |
-
$schedule->setMessages('Locked');
|
21 |
-
return;
|
22 |
-
}
|
23 |
-
|
24 |
-
$this->_lock();
|
25 |
-
$this->_passData($schedule);
|
26 |
-
|
27 |
-
$msg = $schedule->getMessages();
|
28 |
-
if ($msg) {
|
29 |
-
$msg .= "\n";
|
30 |
-
}
|
31 |
-
$msg .= 'Sent';
|
32 |
-
$schedule->setMessages($msg);
|
33 |
-
}
|
34 |
-
|
35 |
-
abstract protected function _passData(Mage_Cron_Model_Schedule $schedule);
|
36 |
-
|
37 |
-
protected function _isLocked()
|
38 |
-
{
|
39 |
-
$lockedAt = Mage::app()->loadCache($this->_name);
|
40 |
-
if ($lockedAt && (time() - $lockedAt < $this->_getConfig()->getGatewayFrequency() * 60)) {
|
41 |
-
return true;
|
42 |
-
}
|
43 |
-
return false;
|
44 |
-
}
|
45 |
-
|
46 |
-
protected function _lock()
|
47 |
{
|
48 |
-
Mage::
|
49 |
}
|
50 |
|
51 |
/**
|
@@ -55,12 +17,4 @@ abstract class Neklo_Monitor_Model_Cron_Abstract
|
|
55 |
{
|
56 |
return Mage::helper('neklo_monitor/config');
|
57 |
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* @return Neklo_Monitor_Model_Gateway_Connector
|
61 |
-
*/
|
62 |
-
protected function _getConnector()
|
63 |
-
{
|
64 |
-
return Mage::getSingleton('neklo_monitor/gateway_connector');
|
65 |
-
}
|
66 |
-
}
|
2 |
|
3 |
abstract class Neklo_Monitor_Model_Cron_Abstract
|
4 |
{
|
5 |
+
/**
|
6 |
+
* @return Neklo_Monitor_Model_Gateway_Connector
|
7 |
+
*/
|
8 |
+
protected function _getConnector()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
{
|
10 |
+
return Mage::getSingleton('neklo_monitor/gateway_connector');
|
11 |
}
|
12 |
|
13 |
/**
|
17 |
{
|
18 |
return Mage::helper('neklo_monitor/config');
|
19 |
}
|
20 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Neklo/Monitor/Model/Cron/Queue.php
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Model_Cron_Queue extends Neklo_Monitor_Model_Cron_Abstract
|
4 |
+
{
|
5 |
+
public function convertInventoryChangelogToQueue(Mage_Cron_Model_Schedule $schedule)
|
6 |
+
{
|
7 |
+
if (!$this->_getConfig()->isEnabled()) {
|
8 |
+
$schedule->setMessages('Neklo_Monitor is disabled');
|
9 |
+
return;
|
10 |
+
}
|
11 |
+
|
12 |
+
if (!$this->_getConfig()->isConnected()) {
|
13 |
+
$schedule->setMessages('Neklo_Monitor is not connected to gateway');
|
14 |
+
return;
|
15 |
+
}
|
16 |
+
|
17 |
+
/* @var Neklo_Monitor_Model_Resource_Changelog $changelog */
|
18 |
+
$changelog = Mage::getResourceModel('neklo_monitor/changelog');
|
19 |
+
$changelogData = $changelog->fetch();
|
20 |
+
if ($changelogData && is_array($changelogData)) {
|
21 |
+
foreach ($changelogData as $_item) {
|
22 |
+
$this->_addToRequestQueue(
|
23 |
+
Neklo_Monitor_Model_Source_Gateway_Queue_Type::INVENTORY_CODE,
|
24 |
+
array(
|
25 |
+
'name' => $_item['name'],
|
26 |
+
'sku' => $_item['sku'],
|
27 |
+
'attribute_set_id' => $_item['attribute_set_id'],
|
28 |
+
'attribute_set_name' => $_item['attribute_set_name'],
|
29 |
+
'qty' => $_item['qty'],
|
30 |
+
'in_stock' => $_item['stock_status'] ? 1 : 0,
|
31 |
+
)
|
32 |
+
);
|
33 |
+
}
|
34 |
+
|
35 |
+
$schedule->setMessages(
|
36 |
+
sprintf('Ready to send %d inventory updates.', count($changelogData))
|
37 |
+
);
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
public function aggregateSalesReportOrderData($schedule)
|
42 |
+
{
|
43 |
+
if (!$this->_getConfig()->isEnabled()) {
|
44 |
+
$schedule->setMessages('Neklo_Monitor is disabled');
|
45 |
+
return;
|
46 |
+
}
|
47 |
+
|
48 |
+
if (!$this->_getConfig()->isConnected()) {
|
49 |
+
$schedule->setMessages('Neklo_Monitor is not connected to gateway');
|
50 |
+
return;
|
51 |
+
}
|
52 |
+
|
53 |
+
$report = Mage::getResourceModel('neklo_monitor/minfo_daily')->collect();
|
54 |
+
$this->_addToRequestQueue(Neklo_Monitor_Model_Source_Gateway_Queue_Type::DAILY_REPORT_CODE, $report);
|
55 |
+
$schedule->setMessages(
|
56 |
+
sprintf('Collected sales report with %d new orders.', $report['orders']['all']['orders_count'])
|
57 |
+
);
|
58 |
+
}
|
59 |
+
|
60 |
+
public function sendQueue(Mage_Cron_Model_Schedule $schedule)
|
61 |
+
{
|
62 |
+
if (!$this->_getConfig()->isEnabled()) {
|
63 |
+
$schedule->setMessages('Neklo_Monitor is disabled');
|
64 |
+
return;
|
65 |
+
}
|
66 |
+
|
67 |
+
if (!$this->_getConfig()->isConnected()) {
|
68 |
+
$schedule->setMessages('Neklo_Monitor is not connected to gateway');
|
69 |
+
return;
|
70 |
+
}
|
71 |
+
|
72 |
+
$startedAt = time();
|
73 |
+
|
74 |
+
/* @var Neklo_Monitor_Model_Resource_Gateway_Queue $gatewayQueue */
|
75 |
+
$gatewayQueue = Mage::getResourceModel('neklo_monitor/gateway_queue');
|
76 |
+
|
77 |
+
// release entries stuck for 1hr and more: started, but not sent
|
78 |
+
$countStuck = $gatewayQueue->releaseEntries($startedAt - 60 * 60);
|
79 |
+
if ($countStuck > 0) {
|
80 |
+
$schedule->setMessages(
|
81 |
+
$schedule->getMessages() . sprintf('%d stuck items rescheduled.', $countStuck)
|
82 |
+
);
|
83 |
+
}
|
84 |
+
|
85 |
+
// remove old entries sent 30 days ago: started and sent
|
86 |
+
$countOld = $gatewayQueue->cleanupEntries(
|
87 |
+
$startedAt - 60 * 60 * 24 * 30
|
88 |
+
);
|
89 |
+
if ($countOld > 0) {
|
90 |
+
$schedule->setMessages(
|
91 |
+
$schedule->getMessages() . sprintf('%d archive items removed.', $countOld)
|
92 |
+
);
|
93 |
+
}
|
94 |
+
|
95 |
+
/* @var Neklo_Monitor_Model_Resource_Gateway_Queue_Collection $queueCollection */
|
96 |
+
$queueCollection = Mage::getResourceModel('neklo_monitor/gateway_queue_collection');
|
97 |
+
$queueCollection->addFieldToFilter('started_at', $startedAt);
|
98 |
+
if ($queueCollection->getSize() > 0) {
|
99 |
+
// to prevent several cron runs at the same timestamp
|
100 |
+
return;
|
101 |
+
}
|
102 |
+
|
103 |
+
// mark pending requests to run at $time
|
104 |
+
// to prevent same rows sent by different cron processes,
|
105 |
+
// i.e. when previous sending process lasts too long and another cron process has started
|
106 |
+
$gatewayQueue->bookEntries($startedAt);
|
107 |
+
|
108 |
+
// fetch entries to send
|
109 |
+
/* @var Neklo_Monitor_Model_Resource_Gateway_Queue_Collection $queueCollection */
|
110 |
+
$queueCollection = Mage::getResourceModel('neklo_monitor/gateway_queue_collection');
|
111 |
+
$queueCollection->addFieldToFilter('started_at', $startedAt);
|
112 |
+
if (!$queueCollection->getSize()) {
|
113 |
+
$schedule->setMessages('Nothing to send');
|
114 |
+
return;
|
115 |
+
}
|
116 |
+
|
117 |
+
$requestData = array();
|
118 |
+
foreach ($queueCollection as $queue) {
|
119 |
+
/* @var Neklo_Monitor_Model_Gateway_Queue $queue */
|
120 |
+
if (!array_key_exists($queue->getType(), $requestData)) {
|
121 |
+
$requestData[$queue->getType()] = array();
|
122 |
+
}
|
123 |
+
// TODO: check base64
|
124 |
+
$requestData[$queue->getType()][] = base64_encode($queue->getMessage());
|
125 |
+
}
|
126 |
+
|
127 |
+
try {
|
128 |
+
$gatewayConfig = $this->_getConnector()->sendAlert($requestData);
|
129 |
+
$this->_getConfig()->updateGatewayConfig($gatewayConfig);
|
130 |
+
|
131 |
+
if ($queueCollection->count() > 0) {
|
132 |
+
$schedule->setMessages(
|
133 |
+
sprintf('%d items sent.', $queueCollection->count())
|
134 |
+
);
|
135 |
+
}
|
136 |
+
|
137 |
+
// mark as sent
|
138 |
+
$sentAt = time();
|
139 |
+
$gatewayQueue->sentEntries($startedAt, $sentAt);
|
140 |
+
} catch (Exception $e) {
|
141 |
+
$schedule->setMessages($e->getMessage());
|
142 |
+
Mage::logException($e);
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
protected function _addToRequestQueue($type, $info)
|
147 |
+
{
|
148 |
+
/* @var Neklo_Monitor_Model_Gateway_Queue $queue */
|
149 |
+
$queue = Mage::getModel('neklo_monitor/gateway_queue');
|
150 |
+
$queue->addToQueue($type, $info);
|
151 |
+
}
|
152 |
+
}
|
app/code/community/Neklo/Monitor/Model/Cron/Statistic.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
abstract class Neklo_Monitor_Model_Cron_Statistic extends Neklo_Monitor_Model_Cron_Abstract
|
4 |
+
{
|
5 |
+
protected $_name = '';
|
6 |
+
|
7 |
+
public function run(Mage_Cron_Model_Schedule $schedule)
|
8 |
+
{
|
9 |
+
if (!$this->_getConfig()->isEnabled()) {
|
10 |
+
$schedule->setMessages('Disabled');
|
11 |
+
return;
|
12 |
+
}
|
13 |
+
|
14 |
+
if (!$this->_getConfig()->isConnected()) {
|
15 |
+
$schedule->setMessages('Not connected');
|
16 |
+
return;
|
17 |
+
}
|
18 |
+
|
19 |
+
if ($this->_isLocked()) {
|
20 |
+
$schedule->setMessages('Locked');
|
21 |
+
return;
|
22 |
+
}
|
23 |
+
|
24 |
+
$this->_lock();
|
25 |
+
$this->_passData($schedule);
|
26 |
+
|
27 |
+
$msg = $schedule->getMessages();
|
28 |
+
if ($msg) {
|
29 |
+
$msg .= "\n";
|
30 |
+
}
|
31 |
+
$msg .= 'Sent';
|
32 |
+
$schedule->setMessages($msg);
|
33 |
+
}
|
34 |
+
|
35 |
+
abstract protected function _passData(Mage_Cron_Model_Schedule $schedule);
|
36 |
+
|
37 |
+
protected function _isLocked()
|
38 |
+
{
|
39 |
+
$lockedAt = Mage::app()->loadCache($this->_name);
|
40 |
+
if ($lockedAt && (time() - $lockedAt < $this->_getConfig()->getGatewayFrequency() * 60)) {
|
41 |
+
return true;
|
42 |
+
}
|
43 |
+
return false;
|
44 |
+
}
|
45 |
+
|
46 |
+
protected function _lock()
|
47 |
+
{
|
48 |
+
Mage::app()->saveCache(time(), $this->_name, array(), $this->_getConfig()->getGatewayFrequency() * 60);
|
49 |
+
}
|
50 |
+
}
|
app/code/community/Neklo/Monitor/Model/Cron/{Server.php → Statistic/Server.php}
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class
|
4 |
{
|
5 |
protected $_name = 'neklo_monitor_cron_server_lock_id';
|
6 |
|
@@ -11,7 +11,7 @@ class Neklo_Monitor_Model_Cron_Server extends Neklo_Monitor_Model_Cron_Abstract
|
|
11 |
$gatewayConfig = $this->_getConnector()->sendInfo('server', $serverData);
|
12 |
$this->_getConfig()->updateGatewayConfig($gatewayConfig);
|
13 |
} catch (Exception $e) {
|
14 |
-
|
15 |
$msg = $schedule->getMessages();
|
16 |
if ($msg) {
|
17 |
$msg .= "\n";
|
1 |
<?php
|
2 |
|
3 |
+
class Neklo_Monitor_Model_Cron_Statistic_Server extends Neklo_Monitor_Model_Cron_Statistic
|
4 |
{
|
5 |
protected $_name = 'neklo_monitor_cron_server_lock_id';
|
6 |
|
11 |
$gatewayConfig = $this->_getConnector()->sendInfo('server', $serverData);
|
12 |
$this->_getConfig()->updateGatewayConfig($gatewayConfig);
|
13 |
} catch (Exception $e) {
|
14 |
+
Mage::logException($e);
|
15 |
$msg = $schedule->getMessages();
|
16 |
if ($msg) {
|
17 |
$msg .= "\n";
|
app/code/community/Neklo/Monitor/Model/Cron/{Store.php → Statistic/Store.php}
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class
|
4 |
{
|
5 |
protected $_name = 'neklo_monitor_cron_store_lock_id';
|
6 |
|
@@ -11,7 +11,7 @@ class Neklo_Monitor_Model_Cron_Store extends Neklo_Monitor_Model_Cron_Abstract
|
|
11 |
$gatewayConfig = $this->_getConnector()->sendInfo('store', $storeData);
|
12 |
$this->_getConfig()->updateGatewayConfig($gatewayConfig);
|
13 |
} catch (Exception $e) {
|
14 |
-
|
15 |
$msg = $schedule->getMessages();
|
16 |
if ($msg) {
|
17 |
$msg .= "\n";
|
@@ -40,18 +40,4 @@ class Neklo_Monitor_Model_Cron_Store extends Neklo_Monitor_Model_Cron_Abstract
|
|
40 |
}
|
41 |
return $info;
|
42 |
}
|
43 |
-
|
44 |
-
public function collect()
|
45 |
-
{
|
46 |
-
if (!$this->_getConfig()->isEnabled()) {
|
47 |
-
return;
|
48 |
-
}
|
49 |
-
|
50 |
-
/** @var Neklo_Monitor_Model_Minfo_Parser $parser */
|
51 |
-
$parser = Mage::getModel('neklo_monitor/minfo_parser');
|
52 |
-
$parser->generateReportStats();
|
53 |
-
$parser->generateLogStats('system');
|
54 |
-
$parser->generateLogStats('exception');
|
55 |
-
}
|
56 |
-
|
57 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class Neklo_Monitor_Model_Cron_Statistic_Store extends Neklo_Monitor_Model_Cron_Statistic
|
4 |
{
|
5 |
protected $_name = 'neklo_monitor_cron_store_lock_id';
|
6 |
|
11 |
$gatewayConfig = $this->_getConnector()->sendInfo('store', $storeData);
|
12 |
$this->_getConfig()->updateGatewayConfig($gatewayConfig);
|
13 |
} catch (Exception $e) {
|
14 |
+
Mage::logException($e);
|
15 |
$msg = $schedule->getMessages();
|
16 |
if ($msg) {
|
17 |
$msg .= "\n";
|
40 |
}
|
41 |
return $info;
|
42 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
}
|
app/code/community/Neklo/Monitor/Model/Cron/Var.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Model_Cron_Var extends Neklo_Monitor_Model_Cron_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Collect var/report to DB
|
7 |
+
*/
|
8 |
+
public function collectReports()
|
9 |
+
{
|
10 |
+
if (!$this->_getConfig()->isEnabled()) {
|
11 |
+
return;
|
12 |
+
}
|
13 |
+
|
14 |
+
$reportList = Mage::helper('neklo_monitor/var_report')->collectReports();
|
15 |
+
Mage::getModel('neklo_monitor/report')->saveReports($reportList);
|
16 |
+
}
|
17 |
+
}
|
app/code/community/Neklo/Monitor/Model/Gateway/Connector.php
CHANGED
@@ -4,11 +4,97 @@ class Neklo_Monitor_Model_Gateway_Connector
|
|
4 |
{
|
5 |
protected $_client = null;
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
/**
|
8 |
* @return null|Varien_Http_Client
|
9 |
* @throws Zend_Http_Client_Exception
|
10 |
*/
|
11 |
-
|
12 |
{
|
13 |
if ($this->_client === null) {
|
14 |
$this->_client = new Varien_Http_Client();
|
@@ -21,44 +107,15 @@ class Neklo_Monitor_Model_Gateway_Connector
|
|
21 |
'verifypeer' => 0,
|
22 |
)
|
23 |
)
|
|
|
|
|
|
|
|
|
24 |
;
|
25 |
}
|
26 |
return $this->_client;
|
27 |
}
|
28 |
|
29 |
-
public function sendInfo($type, $info, $action = 'info')
|
30 |
-
{
|
31 |
-
if (is_null($type)) {
|
32 |
-
// multiple types, $info is an assoc array
|
33 |
-
$requestData = $info;
|
34 |
-
} else {
|
35 |
-
$requestData = array(
|
36 |
-
$type => $info,
|
37 |
-
);
|
38 |
-
}
|
39 |
-
|
40 |
-
$requestData['SID'] = $this->_getConfig()->getGatewaySid();
|
41 |
-
|
42 |
-
$client = $this->getClient();
|
43 |
-
|
44 |
-
$url = $this->_getUri($action);
|
45 |
-
$client->setUri($url);
|
46 |
-
$client->setRawData(Mage::helper('core')->jsonEncode($requestData));
|
47 |
-
|
48 |
-
$result = $client->request();
|
49 |
-
|
50 |
-
if (!$result->isSuccessful()) {
|
51 |
-
throw new Exception(Mage::helper('core')->__('Error sending request to %s: %s', $url, $result->getMessage()));
|
52 |
-
}
|
53 |
-
|
54 |
-
return Mage::helper('core')->jsonDecode($this->_getBody($result));
|
55 |
-
}
|
56 |
-
|
57 |
-
protected function _getUri($action)
|
58 |
-
{
|
59 |
-
return $this->_getConfig()->getGatewayServerUri() . 'server/' . $action;
|
60 |
-
}
|
61 |
-
|
62 |
/**
|
63 |
* @return Neklo_Monitor_Helper_Config
|
64 |
*/
|
@@ -107,5 +164,4 @@ class Neklo_Monitor_Model_Gateway_Connector
|
|
107 |
|
108 |
return $body;
|
109 |
}
|
110 |
-
|
111 |
}
|
4 |
{
|
5 |
protected $_client = null;
|
6 |
|
7 |
+
public function connect()
|
8 |
+
{
|
9 |
+
$requestData = array(
|
10 |
+
'token' => $this->_getConfig()->getToken(),
|
11 |
+
'url' => Mage::getBaseUrl(),
|
12 |
+
'platform' => $this->_getConfig()->getPlatform(),
|
13 |
+
'platform_version' => Mage::getVersion(),
|
14 |
+
'connector_version' => $this->_getConfig()->getModuleVersion(),
|
15 |
+
);
|
16 |
+
return $this->_request('store', 'connect', $requestData);
|
17 |
+
}
|
18 |
+
|
19 |
+
public function disconnect()
|
20 |
+
{
|
21 |
+
$result = $this->_request('store', 'disconnect');
|
22 |
+
$this->_getConfig()->disconnect();
|
23 |
+
return $result;
|
24 |
+
}
|
25 |
+
|
26 |
+
public function addAccount(array $accountData)
|
27 |
+
{
|
28 |
+
return $this->_request('account', 'add', $accountData);
|
29 |
+
}
|
30 |
+
|
31 |
+
public function removeAccount($phoneHash)
|
32 |
+
{
|
33 |
+
$requestData = array(
|
34 |
+
'phone_hash' => $phoneHash,
|
35 |
+
);
|
36 |
+
return $this->_request('account', 'remove', $requestData);
|
37 |
+
}
|
38 |
+
|
39 |
+
public function sendInfo($type, $info, $action = 'info')
|
40 |
+
{
|
41 |
+
$requestData = array(
|
42 |
+
$type => $info,
|
43 |
+
);
|
44 |
+
return $this->_request('server', $action, $requestData);
|
45 |
+
}
|
46 |
+
|
47 |
+
// TODO: check base64
|
48 |
+
public function sendAlert($info)
|
49 |
+
{
|
50 |
+
$requestData = $info;
|
51 |
+
return $this->_request('server', 'alert', $requestData);
|
52 |
+
}
|
53 |
+
|
54 |
+
protected function _request($controller, $action, array $data = array())
|
55 |
+
{
|
56 |
+
$uri = $this->_getUri($controller, $action);
|
57 |
+
|
58 |
+
$data['SID'] = $this->_getConfig()->getGatewaySid();
|
59 |
+
|
60 |
+
$client = $this->_getClient();
|
61 |
+
$client->setUri($uri);
|
62 |
+
$client->setRawData(Mage::helper('core')->jsonEncode($data));
|
63 |
+
|
64 |
+
$result = $client->request();
|
65 |
+
|
66 |
+
if (!$result->isSuccessful()) {
|
67 |
+
throw new Exception(
|
68 |
+
Mage::helper('core')->__('Error sending request to %s: %s', $uri, $result->getMessage())
|
69 |
+
);
|
70 |
+
}
|
71 |
+
|
72 |
+
// TODO: update frequency config
|
73 |
+
|
74 |
+
// TODO: improve gateway errors
|
75 |
+
// if (!$result->isSuccessful()) {
|
76 |
+
// try {
|
77 |
+
// $errorResult = Mage::helper('core')->jsonDecode($this->_getBody($result));
|
78 |
+
// $message = Mage::helper('core')->__('Gateway: %s', $errorResult['message']);
|
79 |
+
// } catch (Exception $e) {
|
80 |
+
// $message = $result->getMessage();
|
81 |
+
// }
|
82 |
+
// throw new Exception($message);
|
83 |
+
// }
|
84 |
+
|
85 |
+
return Mage::helper('core')->jsonDecode($this->_getBody($result));
|
86 |
+
}
|
87 |
+
|
88 |
+
protected function _getUri($controller, $action)
|
89 |
+
{
|
90 |
+
return $this->_getConfig()->getGatewayServerUri() . $controller . '/' . $action;
|
91 |
+
}
|
92 |
+
|
93 |
/**
|
94 |
* @return null|Varien_Http_Client
|
95 |
* @throws Zend_Http_Client_Exception
|
96 |
*/
|
97 |
+
protected function _getClient()
|
98 |
{
|
99 |
if ($this->_client === null) {
|
100 |
$this->_client = new Varien_Http_Client();
|
107 |
'verifypeer' => 0,
|
108 |
)
|
109 |
)
|
110 |
+
->setHeaders(
|
111 |
+
Neklo_Monitor_Helper_Header::GATEWAY_API_VERSION_HEADER,
|
112 |
+
$this->_getConfig()->getGatewayApiVersion()
|
113 |
+
)
|
114 |
;
|
115 |
}
|
116 |
return $this->_client;
|
117 |
}
|
118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
/**
|
120 |
* @return Neklo_Monitor_Helper_Config
|
121 |
*/
|
164 |
|
165 |
return $body;
|
166 |
}
|
|
|
167 |
}
|
app/code/community/Neklo/Monitor/Model/Gateway/Queue.php
CHANGED
@@ -6,4 +6,16 @@ class Neklo_Monitor_Model_Gateway_Queue extends Mage_Core_Model_Abstract
|
|
6 |
{
|
7 |
$this->_init('neklo_monitor/gateway_queue');
|
8 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
}
|
6 |
{
|
7 |
$this->_init('neklo_monitor/gateway_queue');
|
8 |
}
|
9 |
+
|
10 |
+
public function addToQueue($type, $info)
|
11 |
+
{
|
12 |
+
$this
|
13 |
+
->setId(null)
|
14 |
+
->setType($type)
|
15 |
+
->setMessage(Mage::helper('core')->jsonEncode($info))
|
16 |
+
->setScheduledAt(time())
|
17 |
+
->save()
|
18 |
+
;
|
19 |
+
return $this;
|
20 |
+
}
|
21 |
}
|
app/code/community/Neklo/Monitor/Model/Log.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Model_Log extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
protected function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('neklo_monitor/log');
|
8 |
+
}
|
9 |
+
|
10 |
+
public function loadByHash($hash)
|
11 |
+
{
|
12 |
+
return $this->load($hash, 'hash');
|
13 |
+
}
|
14 |
+
|
15 |
+
// TODO: check
|
16 |
+
protected function _afterLoad()
|
17 |
+
{
|
18 |
+
$list = explode(',', $this->_getData('times'));
|
19 |
+
|
20 |
+
// sort by time DESC
|
21 |
+
$list = array_unique($list, SORT_NUMERIC);
|
22 |
+
sort($list, SORT_NUMERIC);
|
23 |
+
$list = array_reverse($list);
|
24 |
+
|
25 |
+
$this->_data['times_list'] = $list;
|
26 |
+
return parent::_afterLoad();
|
27 |
+
}
|
28 |
+
|
29 |
+
// TODO: check
|
30 |
+
/**
|
31 |
+
* @return Varien_Data_Collection
|
32 |
+
*/
|
33 |
+
public function getTimesCollection($startFrom = 0, $limit = null, $filter = array())
|
34 |
+
{
|
35 |
+
// apply filters
|
36 |
+
|
37 |
+
$list = $this->_getData('times_list');
|
38 |
+
if ($filter) {
|
39 |
+
foreach ($list as $_key => $_data) {
|
40 |
+
$valid = true;
|
41 |
+
foreach ($filter as $_expr => $_value) {
|
42 |
+
if ('lt' == $_expr) { if ($_data >= $_value) $valid = false; }
|
43 |
+
// else if ('lteq' == $_expr) { if ($_data[$_field] > $_value) $valid = false; }
|
44 |
+
// else if ('gt' == $_expr) { if ($_data[$_field] <= $_value) $valid = false; }
|
45 |
+
else if ('gteq' == $_expr) { if ($_data < $_value) $valid = false; }
|
46 |
+
// else if ('eq' == $_expr) { if ($_data[$_field] <> $_value) $valid = false; }
|
47 |
+
// else if ('neq' == $_expr) { if ($_data[$_field] == $_value) $valid = false; }
|
48 |
+
}
|
49 |
+
if (!$valid) {
|
50 |
+
unset($list[$_key]);
|
51 |
+
}
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
// apply limits
|
56 |
+
|
57 |
+
$lastIdx = count($list) - 1;
|
58 |
+
if (is_null($limit)) {
|
59 |
+
$finishAt = $lastIdx;
|
60 |
+
} else {
|
61 |
+
$finishAt = $startFrom + $limit - 1;
|
62 |
+
if ($finishAt > $lastIdx) {
|
63 |
+
$finishAt = $lastIdx;
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
$collection = new Varien_Data_Collection();
|
68 |
+
$k = $startFrom;
|
69 |
+
$list = array_values($list); // avoid assoc array, convert to numeric array keys
|
70 |
+
while ($k <= $finishAt) {
|
71 |
+
$_file = new Varien_Object($list[$k]);
|
72 |
+
$collection->addItem($_file);
|
73 |
+
$k++;
|
74 |
+
}
|
75 |
+
|
76 |
+
return $collection;
|
77 |
+
}
|
78 |
+
}
|
app/code/community/Neklo/Monitor/Model/Log/Writer/Stream.php
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Model_Log_Writer_Stream extends Zend_Log_Writer_Stream
|
4 |
+
{
|
5 |
+
protected $_isSystemFile = false;
|
6 |
+
|
7 |
+
public function __construct($streamOrUrl, $mode = 'a')
|
8 |
+
{
|
9 |
+
if ($this->_getConfig()->isEnabled() && !is_resource($streamOrUrl)) {
|
10 |
+
$filename = basename($streamOrUrl);
|
11 |
+
if (
|
12 |
+
Mage::getStoreConfig('dev/log/file') == $filename
|
13 |
+
|| Mage::getStoreConfig('dev/log/exception_file') == $filename
|
14 |
+
) {
|
15 |
+
$this->_isSystemFile = true;
|
16 |
+
}
|
17 |
+
}
|
18 |
+
parent::__construct($streamOrUrl, $mode);
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _write($event)
|
22 |
+
{
|
23 |
+
if ($this->_getConfig()->isEnabled() && $this->_canSave()) {
|
24 |
+
$this->_saveLog($event);
|
25 |
+
}
|
26 |
+
parent::_write($event);
|
27 |
+
}
|
28 |
+
|
29 |
+
protected function _canSave()
|
30 |
+
{
|
31 |
+
return $this->_isSystemFile;
|
32 |
+
}
|
33 |
+
|
34 |
+
protected function _saveLog($event)
|
35 |
+
{
|
36 |
+
$hash = md5(trim($event['message']));
|
37 |
+
|
38 |
+
/* @var $log Neklo_Monitor_Model_Log */
|
39 |
+
$log = Mage::getModel('neklo_monitor/log');
|
40 |
+
$log->loadByHash($hash);
|
41 |
+
|
42 |
+
if ($log->getId()) {
|
43 |
+
$log->addData(
|
44 |
+
array(
|
45 |
+
'last_time' => $this->_getTimestamp($event['timestamp']),
|
46 |
+
'qty' => $log->getQty() + 1,
|
47 |
+
'qty_new' => $log->getQtyNew() + 1,
|
48 |
+
)
|
49 |
+
);
|
50 |
+
} else {
|
51 |
+
$log->addData(
|
52 |
+
array(
|
53 |
+
'first_time' => $this->_getTimestamp($event['timestamp']),
|
54 |
+
'last_time' => $this->_getTimestamp($event['timestamp']),
|
55 |
+
'qty' => 1,
|
56 |
+
'qty_new' => 1,
|
57 |
+
'message' => $event['message'],
|
58 |
+
'hash' => $hash,
|
59 |
+
)
|
60 |
+
);
|
61 |
+
}
|
62 |
+
|
63 |
+
$log->save();
|
64 |
+
}
|
65 |
+
|
66 |
+
protected function _getTimestamp($date)
|
67 |
+
{
|
68 |
+
$zDate = new Zend_Date($date, Zend_Date::ISO_8601);
|
69 |
+
return $zDate->getTimestamp();
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @return Neklo_Monitor_Helper_Config
|
74 |
+
*/
|
75 |
+
protected function _getConfig()
|
76 |
+
{
|
77 |
+
return Mage::helper('neklo_monitor/config');
|
78 |
+
}
|
79 |
+
}
|
app/code/community/Neklo/Monitor/Model/Minfo.php
CHANGED
@@ -6,11 +6,19 @@ class Neklo_Monitor_Model_Minfo
|
|
6 |
|
7 |
protected $_config = array(
|
8 |
'magento' => array(
|
9 |
-
'
|
10 |
-
'var_report' => true,
|
11 |
-
'customer_online' => true,
|
12 |
'products_outofstock' => true,
|
13 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
);
|
15 |
|
16 |
public function getInfo()
|
@@ -25,15 +33,45 @@ class Neklo_Monitor_Model_Minfo
|
|
25 |
|
26 |
$timestamp = time();
|
27 |
$fields = array(
|
28 |
-
'
|
29 |
-
'show' => !empty($this->_config['
|
30 |
'default' => null,
|
31 |
-
'method' => '
|
32 |
),
|
33 |
-
'
|
34 |
-
'show' => !empty($this->_config['
|
35 |
'default' => null,
|
36 |
-
'method' => '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
),
|
38 |
'customer_online' => array(
|
39 |
'show' => !empty($this->_config['magento']['customer_online']),
|
6 |
|
7 |
protected $_config = array(
|
8 |
'magento' => array(
|
9 |
+
'customer_online' => true,
|
|
|
|
|
10 |
'products_outofstock' => true,
|
11 |
),
|
12 |
+
'var' => array(
|
13 |
+
'log_size' => true,
|
14 |
+
'log_file_count' => true,
|
15 |
+
'log_qty' => true,
|
16 |
+
'log_qty_new' => true,
|
17 |
+
'report_size' => true,
|
18 |
+
'report_file_count' => true,
|
19 |
+
'report_qty' => true,
|
20 |
+
'report_qty_new' => true,
|
21 |
+
)
|
22 |
);
|
23 |
|
24 |
public function getInfo()
|
33 |
|
34 |
$timestamp = time();
|
35 |
$fields = array(
|
36 |
+
'log_size' => array(
|
37 |
+
'show' => !empty($this->_config['var']['log_size']),
|
38 |
'default' => null,
|
39 |
+
'method' => 'getLogSize',
|
40 |
),
|
41 |
+
'log_file_count' => array(
|
42 |
+
'show' => !empty($this->_config['var']['log_file_count']),
|
43 |
'default' => null,
|
44 |
+
'method' => 'getLogFileCount',
|
45 |
+
),
|
46 |
+
'log_qty' => array(
|
47 |
+
'show' => !empty($this->_config['var']['log_qty']),
|
48 |
+
'default' => null,
|
49 |
+
'method' => 'getLogQty',
|
50 |
+
),
|
51 |
+
'log_qty_new' => array(
|
52 |
+
'show' => !empty($this->_config['var']['log_qty_new']),
|
53 |
+
'default' => null,
|
54 |
+
'method' => 'getLogQtyNew',
|
55 |
+
),
|
56 |
+
'report_size' => array(
|
57 |
+
'show' => !empty($this->_config['var']['report_size']),
|
58 |
+
'default' => null,
|
59 |
+
'method' => 'getReportSize',
|
60 |
+
),
|
61 |
+
'report_file_count' => array(
|
62 |
+
'show' => !empty($this->_config['var']['report_file_count']),
|
63 |
+
'default' => null,
|
64 |
+
'method' => 'getReportFileCount',
|
65 |
+
),
|
66 |
+
'report_qty' => array(
|
67 |
+
'show' => !empty($this->_config['var']['report_qty']),
|
68 |
+
'default' => null,
|
69 |
+
'method' => 'getReportQty',
|
70 |
+
),
|
71 |
+
'report_qty_new' => array(
|
72 |
+
'show' => !empty($this->_config['var']['report_qty_new']),
|
73 |
+
'default' => null,
|
74 |
+
'method' => 'getReportQtyNew',
|
75 |
),
|
76 |
'customer_online' => array(
|
77 |
'show' => !empty($this->_config['magento']['customer_online']),
|
app/code/community/Neklo/Monitor/Model/Minfo/Log.php
DELETED
@@ -1,195 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* @method Neklo_Monitor_Model_Resource_Minfo_Log getResource()
|
5 |
-
*/
|
6 |
-
class Neklo_Monitor_Model_Minfo_Log extends Mage_Core_Model_Abstract
|
7 |
-
{
|
8 |
-
protected function _construct()
|
9 |
-
{
|
10 |
-
$this->_init('neklo_monitor/minfo_log');
|
11 |
-
}
|
12 |
-
|
13 |
-
public function generateLogs($type)
|
14 |
-
{
|
15 |
-
$logActive = Mage::getStoreConfig('dev/log/active');
|
16 |
-
if (!Mage::getIsDeveloperMode() && !$logActive) {
|
17 |
-
return false;
|
18 |
-
}
|
19 |
-
|
20 |
-
$file = Mage::getStoreConfig('dev/log/file');
|
21 |
-
if ('system' != $type) {
|
22 |
-
$type = 'exception';
|
23 |
-
$file = Mage::getStoreConfig('dev/log/exception_file');
|
24 |
-
}
|
25 |
-
$logFile = Mage::getBaseDir('var') . DS . 'log' . DS . $file;
|
26 |
-
if (!file_exists($logFile)) {
|
27 |
-
return false;
|
28 |
-
}
|
29 |
-
|
30 |
-
$logs = array();
|
31 |
-
|
32 |
-
$fh = fopen($logFile, "r");
|
33 |
-
if (!$fh) {
|
34 |
-
return false;
|
35 |
-
}
|
36 |
-
|
37 |
-
$maxTime = $this->getResource()->fetchMaxTime($type);
|
38 |
-
|
39 |
-
// read log lines according to format
|
40 |
-
// '%timestamp% %priorityName% (%priority%): %message%' . PHP_EOL;
|
41 |
-
// see Mage::log()
|
42 |
-
// exception's $message starts with "/n", i.e. can be found on next line
|
43 |
-
|
44 |
-
while (($line = fgets($fh)) !== false) {
|
45 |
-
// line should contain datetime, priorityName, $priority value least
|
46 |
-
// e.g. "2016-04-18T13:39:42+00:00 ERR (3):"
|
47 |
-
// yes, minimal priorityName is ERR, see Zend_Log
|
48 |
-
if (strlen($line) < 34) {
|
49 |
-
continue;
|
50 |
-
}
|
51 |
-
|
52 |
-
// skip exception stack traces
|
53 |
-
if ('exception' == $type && 0 === strpos($line, '#')) {
|
54 |
-
continue;
|
55 |
-
}
|
56 |
-
|
57 |
-
// search for line with datetime at the beginning
|
58 |
-
// timestamp format is YYYY-mm-ddTHH:ii:ss+00:00
|
59 |
-
$offsetTimezone = strpos($line, '+00:00 ');
|
60 |
-
if (19 !== $offsetTimezone) { // 19 is strlen of 'YYYY-mm-ddTHH:ii:ss'
|
61 |
-
continue;
|
62 |
-
}
|
63 |
-
|
64 |
-
$lineDate = substr($line, 0, $offsetTimezone);
|
65 |
-
$lineTime = strtotime($lineDate);
|
66 |
-
// invalid date?
|
67 |
-
if (false === $lineTime) {
|
68 |
-
continue;
|
69 |
-
}
|
70 |
-
// process only new dates
|
71 |
-
if ($lineTime < $maxTime) {
|
72 |
-
continue;
|
73 |
-
}
|
74 |
-
|
75 |
-
$offsetPriority = $offsetTimezone + 7; // 7 is strlen of '+00:00 ', i.e. 19+7=26
|
76 |
-
$offsetMessage = strpos($line, ': ', $offsetPriority);
|
77 |
-
if (false === $offsetMessage) {
|
78 |
-
continue; // hmmm
|
79 |
-
}
|
80 |
-
$linePriorityInfo = substr($line, $offsetPriority, $offsetMessage - $offsetPriority);
|
81 |
-
list($linePriorityName, $linePriorityValue) = explode(' ', $linePriorityInfo);
|
82 |
-
// skip manual debug lines in system.log
|
83 |
-
if ('debug' == strtolower($linePriorityName)) {
|
84 |
-
continue;
|
85 |
-
}
|
86 |
-
|
87 |
-
$offsetMessage += 2; // ': ' between $priority and $message
|
88 |
-
if ('exception' == $type || $offsetMessage >= strlen($line)) {
|
89 |
-
// read next line for message
|
90 |
-
$line = fgets($fh);
|
91 |
-
if (false == $line) {
|
92 |
-
break; // EOF
|
93 |
-
}
|
94 |
-
$lineMessage = $line;
|
95 |
-
} else {
|
96 |
-
$lineMessage = substr($line, $offsetMessage);
|
97 |
-
}
|
98 |
-
$lineMessage = trim($lineMessage);
|
99 |
-
|
100 |
-
$hash = md5($lineMessage);
|
101 |
-
if (isset($logs[$hash])) {
|
102 |
-
$logs[$hash]['qty']++;
|
103 |
-
if ($lineTime > $logs[$hash]['last_time']) {
|
104 |
-
$logs[$hash]['last_time'] = $lineTime;
|
105 |
-
}
|
106 |
-
$logs[$hash]['times'][] = $lineTime;
|
107 |
-
} else {
|
108 |
-
$logs[$hash] = array(
|
109 |
-
'hash' => $hash,
|
110 |
-
'message' => $lineMessage,
|
111 |
-
'qty' => 1,
|
112 |
-
'last_time' => $lineTime,
|
113 |
-
'times' => array($lineTime),
|
114 |
-
);
|
115 |
-
}
|
116 |
-
}
|
117 |
-
|
118 |
-
fclose($fh);
|
119 |
-
|
120 |
-
// calculate first_time
|
121 |
-
foreach ($logs as $hash => $_log) {
|
122 |
-
$_times = $_log['times'];
|
123 |
-
sort($_times);
|
124 |
-
$logs[$hash]['first_time'] = current($_times);
|
125 |
-
}
|
126 |
-
|
127 |
-
|
128 |
-
list($inserted, $updated) = $this->getResource()->saveLogs($type, $logs);
|
129 |
-
|
130 |
-
return ($inserted+$updated);
|
131 |
-
}
|
132 |
-
|
133 |
-
protected function _afterLoad()
|
134 |
-
{
|
135 |
-
$list = explode(',', $this->_getData('times'));
|
136 |
-
|
137 |
-
// sort by time DESC
|
138 |
-
$list = array_unique($list, SORT_NUMERIC);
|
139 |
-
sort($list, SORT_NUMERIC);
|
140 |
-
$list = array_reverse($list);
|
141 |
-
|
142 |
-
$this->_data['times_list'] = $list;
|
143 |
-
return parent::_afterLoad();
|
144 |
-
}
|
145 |
-
|
146 |
-
/**
|
147 |
-
* @return Varien_Data_Collection
|
148 |
-
*/
|
149 |
-
public function getTimesCollection($startFrom = 0, $limit = null, $filter = array())
|
150 |
-
{
|
151 |
-
// apply filters
|
152 |
-
|
153 |
-
$list = $this->_getData('times_list');
|
154 |
-
if ($filter) {
|
155 |
-
foreach ($list as $_key => $_data) {
|
156 |
-
$valid = true;
|
157 |
-
foreach ($filter as $_expr => $_value) {
|
158 |
-
if ('lt' == $_expr) { if ($_data >= $_value) $valid = false; }
|
159 |
-
// else if ('lteq' == $_expr) { if ($_data[$_field] > $_value) $valid = false; }
|
160 |
-
// else if ('gt' == $_expr) { if ($_data[$_field] <= $_value) $valid = false; }
|
161 |
-
else if ('gteq' == $_expr) { if ($_data < $_value) $valid = false; }
|
162 |
-
// else if ('eq' == $_expr) { if ($_data[$_field] <> $_value) $valid = false; }
|
163 |
-
// else if ('neq' == $_expr) { if ($_data[$_field] == $_value) $valid = false; }
|
164 |
-
}
|
165 |
-
if (!$valid) {
|
166 |
-
unset($list[$_key]);
|
167 |
-
}
|
168 |
-
}
|
169 |
-
}
|
170 |
-
|
171 |
-
// apply limits
|
172 |
-
|
173 |
-
$lastIdx = count($list) - 1;
|
174 |
-
if (is_null($limit)) {
|
175 |
-
$finishAt = $lastIdx;
|
176 |
-
} else {
|
177 |
-
$finishAt = $startFrom + $limit - 1;
|
178 |
-
if ($finishAt > $lastIdx) {
|
179 |
-
$finishAt = $lastIdx;
|
180 |
-
}
|
181 |
-
}
|
182 |
-
|
183 |
-
$collection = new Varien_Data_Collection();
|
184 |
-
$k = $startFrom;
|
185 |
-
$list = array_values($list); // avoid assoc array, convert to numeric array keys
|
186 |
-
while ($k <= $finishAt) {
|
187 |
-
$_file = new Varien_Object($list[$k]);
|
188 |
-
$collection->addItem($_file);
|
189 |
-
$k++;
|
190 |
-
}
|
191 |
-
|
192 |
-
return $collection;
|
193 |
-
}
|
194 |
-
|
195 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Neklo/Monitor/Model/Minfo/Parser.php
CHANGED
@@ -5,207 +5,131 @@ class Neklo_Monitor_Model_Minfo_Parser
|
|
5 |
const VAR_REPORT = 'report';
|
6 |
const VAR_LOG = 'log';
|
7 |
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
9 |
{
|
10 |
-
$
|
11 |
-
|
12 |
-
return array(
|
13 |
-
'size' => $statFiles->getSize(),
|
14 |
-
'count' => $statFiles->getCount(),
|
15 |
-
'details' => $statDb->getDetails(),
|
16 |
-
);
|
17 |
}
|
18 |
|
19 |
-
public function
|
20 |
{
|
21 |
-
$
|
22 |
-
|
23 |
-
return array(
|
24 |
-
'size' => $statFiles->getSize(),
|
25 |
-
'count' => $statFiles->getCount(),
|
26 |
-
'details' => $statDb->getDetails(),
|
27 |
-
);
|
28 |
}
|
29 |
|
30 |
-
|
31 |
{
|
32 |
-
$
|
33 |
-
|
34 |
-
return new Varien_Object();
|
35 |
-
}
|
36 |
-
|
37 |
-
$size = 0;
|
38 |
-
$count = 0;
|
39 |
-
$directoryIterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directoryPath));
|
40 |
-
foreach ($directoryIterator as $file) {
|
41 |
-
/* @var $file SplFileInfo */
|
42 |
-
if (!$file->isFile()) {
|
43 |
-
continue;
|
44 |
-
}
|
45 |
-
$size += $file->getSize();
|
46 |
-
$count++;
|
47 |
-
}
|
48 |
-
|
49 |
-
$stats = new Varien_Object(array(
|
50 |
-
'size' => (int) $size,
|
51 |
-
'count' => (int) $count,
|
52 |
-
));
|
53 |
-
|
54 |
-
return $stats;
|
55 |
}
|
56 |
|
57 |
-
|
58 |
{
|
59 |
-
|
60 |
-
$
|
61 |
-
|
62 |
-
$collection->getSelect(); // Init fields for select
|
63 |
-
$collection->load();
|
64 |
-
|
65 |
-
$gatewayReport = array();
|
66 |
-
foreach ($collection as $hash => $data) {
|
67 |
-
$gatewayReport[] = array(
|
68 |
-
'type' => $data['type'],
|
69 |
-
'hash' => $data['hash'],
|
70 |
-
'qty' => (int) $data['qty'],
|
71 |
-
);
|
72 |
-
}
|
73 |
-
|
74 |
-
$stats = new Varien_Object(array(
|
75 |
-
'details' => $gatewayReport,
|
76 |
-
));
|
77 |
|
78 |
-
|
|
|
|
|
|
|
79 |
}
|
80 |
|
81 |
-
|
82 |
{
|
83 |
-
|
84 |
-
$
|
85 |
-
|
86 |
-
$collection->getSelect(); // Init fields for select
|
87 |
-
$collection->load();
|
88 |
-
|
89 |
-
$gatewayReport = array();
|
90 |
-
foreach ($collection as $hash => $data) {
|
91 |
-
$gatewayReport[] = array(
|
92 |
-
'hash' => $data['hash'],
|
93 |
-
'qty' => (int) $data['qty'],
|
94 |
-
);
|
95 |
-
}
|
96 |
|
97 |
-
|
98 |
-
|
99 |
-
)
|
|
|
|
|
100 |
|
101 |
-
|
|
|
|
|
|
|
102 |
}
|
103 |
|
104 |
public function getCustomerOnline()
|
105 |
{
|
106 |
-
|
107 |
$logModel = Mage::getModel('log/visitor_online');
|
108 |
$logModel->prepare();
|
109 |
/* @var $collection Mage_Log_Model_Mysql4_Visitor_Online_Collection */
|
110 |
$collection = $logModel->getCollection();
|
111 |
-
return
|
112 |
}
|
113 |
|
114 |
public function getProductsOutofstock()
|
115 |
{
|
116 |
-
|
117 |
-
|
|
|
|
|
118 |
}
|
119 |
|
120 |
-
|
121 |
-
|
122 |
-
* @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
|
123 |
-
*/
|
124 |
-
public function getProductsOutofstockCollection($storeId = null)
|
125 |
{
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
*/
|
146 |
-
|
147 |
-
$collection->addAttributeToSelect(
|
148 |
-
array(
|
149 |
-
'name',
|
150 |
-
'price',
|
151 |
-
'small_image', // exists in collection when Flat Product is enabled
|
152 |
-
)
|
153 |
-
);
|
154 |
-
$collection
|
155 |
-
->joinField(
|
156 |
-
'is_in_stock',
|
157 |
-
'cataloginventory/stock_item',
|
158 |
-
'is_in_stock',
|
159 |
-
'product_id=entity_id',
|
160 |
-
'{{table}}.stock_id=1',
|
161 |
-
'left'
|
162 |
-
)
|
163 |
-
->addAttributeToFilter('is_in_stock', 0)
|
164 |
-
// TODO: investigate qty = 0
|
165 |
-
// ->joinField(
|
166 |
-
// 'qty',
|
167 |
-
// 'cataloginventory/stock_item',
|
168 |
-
// 'qty',
|
169 |
-
// 'product_id=entity_id',
|
170 |
-
// '{{table}}.stock_id=1',
|
171 |
-
// 'left'
|
172 |
-
// )
|
173 |
-
// ->addAttributeToFilter('qty', array('eq' => 0))
|
174 |
-
;
|
175 |
-
return $collection;
|
176 |
-
}
|
177 |
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
return false;
|
183 |
-
}
|
184 |
|
185 |
-
|
186 |
-
$directoryIterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directoryPath));
|
187 |
-
$files = array();
|
188 |
-
foreach ($directoryIterator as $_file) {
|
189 |
-
/** @var SplFileInfo $_file */
|
190 |
-
if (!$_file->isFile()) {
|
191 |
-
continue;
|
192 |
-
}
|
193 |
-
$files[$_file->getMTime()][$_file->getFilename()] = $_file;
|
194 |
-
$count++;
|
195 |
}
|
196 |
-
|
197 |
-
return Mage::getSingleton('neklo_monitor/minfo_report')->generateReports($files);
|
198 |
}
|
199 |
|
200 |
-
|
201 |
{
|
202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
}
|
204 |
|
205 |
-
protected function
|
206 |
{
|
207 |
-
|
208 |
-
|
209 |
-
|
|
|
|
|
|
|
|
|
|
|
210 |
}
|
211 |
}
|
5 |
const VAR_REPORT = 'report';
|
6 |
const VAR_LOG = 'log';
|
7 |
|
8 |
+
protected $_directoryStatList = array();
|
9 |
+
|
10 |
+
protected $_logStats = null;
|
11 |
+
protected $_reportStats = null;
|
12 |
+
|
13 |
+
public function getLogSize()
|
14 |
{
|
15 |
+
$stats = $this->_getDirectoryStats(self::VAR_LOG);
|
16 |
+
return $stats->getSize();
|
|
|
|
|
|
|
|
|
|
|
17 |
}
|
18 |
|
19 |
+
public function getLogFileCount()
|
20 |
{
|
21 |
+
$stats = $this->_getDirectoryStats(self::VAR_LOG);
|
22 |
+
return $stats->getCount();
|
|
|
|
|
|
|
|
|
|
|
23 |
}
|
24 |
|
25 |
+
public function getLogQty()
|
26 |
{
|
27 |
+
$stats = $this->_getLogStats();
|
28 |
+
return $stats->getQty();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
}
|
30 |
|
31 |
+
public function getLogQtyNew()
|
32 |
{
|
33 |
+
$stats = $this->_getLogStats();
|
34 |
+
return $stats->getQtyNew();
|
35 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
+
public function getReportSize()
|
38 |
+
{
|
39 |
+
$stats = $this->_getDirectoryStats(self::VAR_REPORT);
|
40 |
+
return $stats->getSize();
|
41 |
}
|
42 |
|
43 |
+
public function getReportFileCount()
|
44 |
{
|
45 |
+
$stats = $this->_getDirectoryStats(self::VAR_REPORT);
|
46 |
+
return $stats->getCount();
|
47 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
+
public function getReportQty()
|
50 |
+
{
|
51 |
+
$stats = $this->_getReportStats();
|
52 |
+
return $stats->getQty();
|
53 |
+
}
|
54 |
|
55 |
+
public function getReportQtyNew()
|
56 |
+
{
|
57 |
+
$stats = $this->_getReportStats();
|
58 |
+
return $stats->getQtyNew();
|
59 |
}
|
60 |
|
61 |
public function getCustomerOnline()
|
62 |
{
|
63 |
+
/* @var Mage_Log_Model_Visitor_Online $logModel */
|
64 |
$logModel = Mage::getModel('log/visitor_online');
|
65 |
$logModel->prepare();
|
66 |
/* @var $collection Mage_Log_Model_Mysql4_Visitor_Online_Collection */
|
67 |
$collection = $logModel->getCollection();
|
68 |
+
return $collection->getSize();
|
69 |
}
|
70 |
|
71 |
public function getProductsOutofstock()
|
72 |
{
|
73 |
+
/** @var Neklo_Monitor_Helper_Product $productHelper */
|
74 |
+
$productHelper = Mage::helper('neklo_monitor/product');
|
75 |
+
$collection = $productHelper->getProductsOutofstockCollection();
|
76 |
+
return $collection->getSize();
|
77 |
}
|
78 |
|
79 |
+
// TODO: move to var.php helper
|
80 |
+
protected function _getDirectoryStats($directory)
|
|
|
|
|
|
|
81 |
{
|
82 |
+
if (!array_key_exists($directory, $this->_directoryStatList)) {
|
83 |
+
$directoryPath = Mage::getBaseDir('var') . DS . $directory;
|
84 |
+
if (!is_dir($directoryPath) || !is_readable($directoryPath)) {
|
85 |
+
return new Varien_Object();
|
86 |
+
}
|
87 |
|
88 |
+
$size = 0;
|
89 |
+
$count = 0;
|
90 |
+
$directoryIterator = new RecursiveIteratorIterator(
|
91 |
+
new RecursiveDirectoryIterator($directoryPath)
|
92 |
+
);
|
93 |
+
foreach ($directoryIterator as $file) {
|
94 |
+
/* @var $file SplFileInfo */
|
95 |
+
if (!$file->isFile()) {
|
96 |
+
continue;
|
97 |
+
}
|
98 |
+
$size += $file->getSize();
|
99 |
+
$count++;
|
100 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
|
102 |
+
$stats = new Varien_Object(array(
|
103 |
+
'size' => (int) $size,
|
104 |
+
'count' => (int) $count,
|
105 |
+
));
|
|
|
|
|
106 |
|
107 |
+
$this->_directoryStatList[$directory] = $stats;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
}
|
109 |
+
return $this->_directoryStatList[$directory];
|
|
|
110 |
}
|
111 |
|
112 |
+
protected function _getLogStats()
|
113 |
{
|
114 |
+
if ($this->_logStats === null) {
|
115 |
+
/* @var Neklo_Monitor_Model_Resource_Log_Collection $collection */
|
116 |
+
$collection = Mage::getResourceModel('neklo_monitor/log_collection');
|
117 |
+
$this->_logStats = new Varien_Object(
|
118 |
+
$collection->getTotal(true)
|
119 |
+
);
|
120 |
+
}
|
121 |
+
return $this->_logStats;
|
122 |
}
|
123 |
|
124 |
+
protected function _getReportStats()
|
125 |
{
|
126 |
+
if ($this->_reportStats === null) {
|
127 |
+
/* @var Neklo_Monitor_Model_Resource_Report_Collection $collection */
|
128 |
+
$collection = Mage::getResourceModel('neklo_monitor/report_collection');
|
129 |
+
$this->_reportStats = new Varien_Object(
|
130 |
+
$collection->getTotal(true)
|
131 |
+
);
|
132 |
+
}
|
133 |
+
return $this->_reportStats;
|
134 |
}
|
135 |
}
|
app/code/community/Neklo/Monitor/Model/Minfo/Report.php
DELETED
@@ -1,154 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* @method Neklo_Monitor_Model_Resource_Minfo_Report getResource()
|
5 |
-
*/
|
6 |
-
class Neklo_Monitor_Model_Minfo_Report extends Mage_Core_Model_Abstract
|
7 |
-
{
|
8 |
-
protected function _construct()
|
9 |
-
{
|
10 |
-
$this->_init('neklo_monitor/minfo_report');
|
11 |
-
}
|
12 |
-
|
13 |
-
public function generateReports($files)
|
14 |
-
{
|
15 |
-
$reports = array();
|
16 |
-
|
17 |
-
// $maxMtime = $this->getResource()->fetchMaxMtime();
|
18 |
-
foreach ($files as $_mtime => $_files) {
|
19 |
-
// if ($_mtime < $maxMtime) {
|
20 |
-
// continue;
|
21 |
-
// }
|
22 |
-
foreach ($_files as $_name => $_file) {
|
23 |
-
/** @var SplFileInfo $_file */
|
24 |
-
$_path = $_file->getPathname();
|
25 |
-
$_dataSer = file_get_contents($_path);
|
26 |
-
if ('a:5:{i:0;s:' != substr($_dataSer, 0, 11)) {
|
27 |
-
continue;
|
28 |
-
}
|
29 |
-
$_data = @unserialize($_dataSer);
|
30 |
-
if ($_data && is_array($_data)) {
|
31 |
-
$message = $_data[0];
|
32 |
-
$hash = md5($message);
|
33 |
-
if (isset($reports[$hash])) {
|
34 |
-
$reports[$hash]['qty']++;
|
35 |
-
if ($_mtime > $reports[$hash]['last_time']) {
|
36 |
-
$reports[$hash]['last_time'] = $_mtime;
|
37 |
-
}
|
38 |
-
$reports[$hash]['files'][] = array(
|
39 |
-
'name' => ''.$_name,
|
40 |
-
'path' => ''.$_path,
|
41 |
-
'time' => (int) $_mtime,
|
42 |
-
'size' => (int) $_file->getSize(),
|
43 |
-
);
|
44 |
-
} else {
|
45 |
-
$reports[$hash] = array(
|
46 |
-
'hash' => $hash,
|
47 |
-
'message' => $message,
|
48 |
-
'qty' => 1,
|
49 |
-
'last_time' => $_mtime,
|
50 |
-
'files' => array(
|
51 |
-
array(
|
52 |
-
'name' => ''.$_name,
|
53 |
-
'path' => ''.$_path,
|
54 |
-
'time' => (int) $_mtime,
|
55 |
-
'size' => (int) $_file->getSize(),
|
56 |
-
)
|
57 |
-
),
|
58 |
-
);
|
59 |
-
}
|
60 |
-
}
|
61 |
-
}
|
62 |
-
|
63 |
-
// calculate first_mtime
|
64 |
-
foreach ($reports as $hash => $_report) {
|
65 |
-
$minTime = time()*2; // server file mtime (incl. locale timezone) might be bigger than now GMT
|
66 |
-
foreach ($_report['files'] as $_file) {
|
67 |
-
if ($_file['time'] < $minTime) {
|
68 |
-
$minTime = $_file['time'];
|
69 |
-
}
|
70 |
-
}
|
71 |
-
$reports[$hash]['first_time'] = $minTime;
|
72 |
-
}
|
73 |
-
}
|
74 |
-
|
75 |
-
list($inserted, $updated) = $this->getResource()->saveReports($reports);
|
76 |
-
|
77 |
-
return ($inserted+$updated);
|
78 |
-
}
|
79 |
-
|
80 |
-
protected function _afterLoad()
|
81 |
-
{
|
82 |
-
$files = Mage::helper('core')->jsonDecode($this->_getData('files'));
|
83 |
-
|
84 |
-
$list = array();
|
85 |
-
foreach ($files as $_data) {
|
86 |
-
$key = $_data['time'] . '_' . $_data['name'];
|
87 |
-
// $_data['key'] = $key;
|
88 |
-
$list[$key] = $_data;
|
89 |
-
}
|
90 |
-
|
91 |
-
// sort by mtime DESC
|
92 |
-
|
93 |
-
ksort($list);
|
94 |
-
$list = array_reverse($list, true);
|
95 |
-
|
96 |
-
$this->_data['files_list'] = $list;
|
97 |
-
return parent::_afterLoad();
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* @return Varien_Data_Collection
|
102 |
-
*/
|
103 |
-
public function getFilesCollection($startFrom = 0, $limit = null, $filter = array())
|
104 |
-
{
|
105 |
-
// apply filters
|
106 |
-
|
107 |
-
$list = $this->_getData('files_list');
|
108 |
-
if ($filter) {
|
109 |
-
foreach ($list as $_key => $_data) {
|
110 |
-
$valid = true;
|
111 |
-
foreach ($filter as $_field => $_cond) {
|
112 |
-
if (!isset($_data[$_field])) {
|
113 |
-
$_data[$_field] = 0; // temporary, will not affect $list
|
114 |
-
}
|
115 |
-
foreach ($_cond as $_expr => $_value) {
|
116 |
-
if ('lt' == $_expr) { if ($_data[$_field] >= $_value) $valid = false; }
|
117 |
-
// else if ('lteq' == $_expr) { if ($_data[$_field] > $_value) $valid = false; }
|
118 |
-
// else if ('gt' == $_expr) { if ($_data[$_field] <= $_value) $valid = false; }
|
119 |
-
else if ('gteq' == $_expr) { if ($_data[$_field] < $_value) $valid = false; }
|
120 |
-
// else if ('eq' == $_expr) { if ($_data[$_field] <> $_value) $valid = false; }
|
121 |
-
// else if ('neq' == $_expr) { if ($_data[$_field] == $_value) $valid = false; }
|
122 |
-
}
|
123 |
-
}
|
124 |
-
if (!$valid) {
|
125 |
-
unset($list[$_key]);
|
126 |
-
}
|
127 |
-
}
|
128 |
-
}
|
129 |
-
|
130 |
-
// apply limits
|
131 |
-
|
132 |
-
$lastIdx = count($list) - 1;
|
133 |
-
if (is_null($limit)) {
|
134 |
-
$finishAt = $lastIdx;
|
135 |
-
} else {
|
136 |
-
$finishAt = $startFrom + $limit - 1;
|
137 |
-
if ($finishAt > $lastIdx) {
|
138 |
-
$finishAt = $lastIdx;
|
139 |
-
}
|
140 |
-
}
|
141 |
-
|
142 |
-
$collection = new Varien_Data_Collection();
|
143 |
-
$k = $startFrom;
|
144 |
-
$list = array_values($list); // avoid assoc array, convert to numeric array keys
|
145 |
-
while ($k <= $finishAt) {
|
146 |
-
$_file = new Varien_Object($list[$k]);
|
147 |
-
$collection->addItem($_file);
|
148 |
-
$k++;
|
149 |
-
}
|
150 |
-
|
151 |
-
return $collection;
|
152 |
-
}
|
153 |
-
|
154 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Neklo/Monitor/Model/Observer.php
CHANGED
@@ -2,11 +2,27 @@
|
|
2 |
|
3 |
class Neklo_Monitor_Model_Observer
|
4 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
/**
|
6 |
* @param Varien_Event_Observer $observer
|
7 |
* @observe order place event
|
8 |
*/
|
9 |
-
public function
|
10 |
{
|
11 |
if (!$this->_getConfig()->isEnabled()) {
|
12 |
return;
|
@@ -16,167 +32,29 @@ class Neklo_Monitor_Model_Observer
|
|
16 |
return;
|
17 |
}
|
18 |
|
19 |
-
|
20 |
$order = $observer->getEvent()->getOrder();
|
21 |
|
|
|
22 |
$total = $order->getGrandTotal();
|
23 |
-
$
|
24 |
|
25 |
$info = array(
|
26 |
'increment_id' => $order->getIncrementId(),
|
27 |
'grand_total' => $total,
|
28 |
-
|
|
|
29 |
'qty' => $order->getTotalQtyOrdered(),
|
30 |
);
|
31 |
|
32 |
-
$this->_addToRequestQueue(
|
33 |
}
|
34 |
|
35 |
protected function _addToRequestQueue($type, $info)
|
36 |
{
|
37 |
-
|
38 |
$queue = Mage::getModel('neklo_monitor/gateway_queue');
|
39 |
-
$queue
|
40 |
-
->setType($type)
|
41 |
-
->setMessage(Mage::helper('core')->jsonEncode($info))
|
42 |
-
->setScheduledAt(time())
|
43 |
-
->save();
|
44 |
-
}
|
45 |
-
|
46 |
-
// * * * * * cronjob
|
47 |
-
|
48 |
-
public function sendQueuedRequest(Mage_Cron_Model_Schedule $schedule)
|
49 |
-
{
|
50 |
-
if (!$this->_getConfig()->isEnabled()) {
|
51 |
-
$schedule->setMessages('Disabled');
|
52 |
-
return;
|
53 |
-
}
|
54 |
-
|
55 |
-
if (!$this->_getConfig()->isConnected()) {
|
56 |
-
$schedule->setMessages('Not connected');
|
57 |
-
return;
|
58 |
-
}
|
59 |
-
|
60 |
-
$startedAt = time();
|
61 |
-
|
62 |
-
/** @var Neklo_Monitor_Model_Resource_Gateway_Queue $resc */
|
63 |
-
$resc = Mage::getResourceModel('neklo_monitor/gateway_queue');
|
64 |
-
|
65 |
-
// release entries stuck for 1hr and more: started, but not sent
|
66 |
-
|
67 |
-
$countStuck = $resc->releaseEntries($startedAt - 60 * 60);
|
68 |
-
if ($countStuck > 0) {
|
69 |
-
$schedule->setMessages($schedule->getMessages()
|
70 |
-
. sprintf('%d stuck items rescheduled.', $countStuck));
|
71 |
-
}
|
72 |
-
|
73 |
-
|
74 |
-
// remove old entries sent 30 days ago: started and sent
|
75 |
-
|
76 |
-
$countOld = $resc->cleanupEntries($startedAt - 60 * 60 * 24 * 30);
|
77 |
-
if ($countOld > 0) {
|
78 |
-
$schedule->setMessages($schedule->getMessages()
|
79 |
-
. sprintf('%d archive items removed.', $countOld));
|
80 |
-
}
|
81 |
-
|
82 |
-
|
83 |
-
/** @var Neklo_Monitor_Model_Resource_Gateway_Queue_Collection $collSending */
|
84 |
-
$collSending = Mage::getResourceModel('neklo_monitor/gateway_queue_collection');
|
85 |
-
$collSending->addFieldToFilter('started_at', $startedAt);
|
86 |
-
if ($collSending->getSize() > 0) {
|
87 |
-
// to prevent several cron runs at the same timestamp
|
88 |
-
return;
|
89 |
-
}
|
90 |
-
|
91 |
-
// mark pending requests to run at $time
|
92 |
-
// to prevent same rows sent by different cron processes,
|
93 |
-
// i.e. when previous sending process lasts too long and another cron process has started
|
94 |
-
|
95 |
-
$resc->bookEntries($startedAt);
|
96 |
-
|
97 |
-
// fetch entries to send
|
98 |
-
|
99 |
-
/** @var Neklo_Monitor_Model_Resource_Gateway_Queue_Collection $collToSend */
|
100 |
-
$collToSend = Mage::getResourceModel('neklo_monitor/gateway_queue_collection');
|
101 |
-
$collToSend->addFieldToFilter('started_at', $startedAt);
|
102 |
-
if (!$collToSend->getSize()) {
|
103 |
-
$schedule->setMessages($schedule->getMessages()
|
104 |
-
. 'Nothing to send');
|
105 |
-
return;
|
106 |
-
}
|
107 |
-
|
108 |
-
$requestData = array();
|
109 |
-
foreach ($collToSend as $queue) {
|
110 |
-
/** @var Neklo_Monitor_Model_Gateway_Queue $queue */
|
111 |
-
if (!array_key_exists($queue->getType(), $requestData)) {
|
112 |
-
$requestData[ $queue->getType() ] = array();
|
113 |
-
}
|
114 |
-
$requestData[ $queue->getType() ][] = base64_encode($queue->getMessage());
|
115 |
-
}
|
116 |
-
|
117 |
-
try {
|
118 |
-
$gatewayConfig = $this->_getConnector()->sendInfo(null, $requestData, 'alert');
|
119 |
-
$this->_getConfig()->updateGatewayConfig($gatewayConfig);
|
120 |
-
} catch (Exception $e) {
|
121 |
-
$schedule->setMessages($schedule->getMessages()
|
122 |
-
. $e->getMessage());
|
123 |
-
// Mage::logException($e);
|
124 |
-
}
|
125 |
-
|
126 |
-
if ($collToSend->count() > 0) {
|
127 |
-
$schedule->setMessages($schedule->getMessages()
|
128 |
-
. sprintf('%d items sent.', $collToSend->count())); // collection is already loaded, so we do not use ->getSize()
|
129 |
-
}
|
130 |
-
|
131 |
-
// mark as sent
|
132 |
-
|
133 |
-
$sentAt = time();
|
134 |
-
$resc->sentEntries($startedAt, $sentAt);
|
135 |
-
|
136 |
-
}
|
137 |
-
|
138 |
-
// * * * * * cronjob
|
139 |
-
// create queue messages based on inventory changelog product ids list
|
140 |
-
public function convertChangelogToQueue(Mage_Cron_Model_Schedule $schedule)
|
141 |
-
{
|
142 |
-
if (!$this->_getConfig()->isEnabled()) {
|
143 |
-
$schedule->setMessages('Disabled');
|
144 |
-
return;
|
145 |
-
}
|
146 |
-
|
147 |
-
if (!$this->_getConfig()->isConnected()) {
|
148 |
-
$schedule->setMessages('Not connected');
|
149 |
-
return;
|
150 |
-
}
|
151 |
-
|
152 |
-
/** @var Neklo_Monitor_Model_Resource_Changelog $resrc */
|
153 |
-
$resrc = Mage::getResourceModel('neklo_monitor/changelog');
|
154 |
-
$data = $resrc->fetchChangelog();
|
155 |
-
if ($data && is_array($data)) {
|
156 |
-
foreach ($data as $_item) {
|
157 |
-
$this->_addToRequestQueue('inventory', array(
|
158 |
-
'name' => $_item['name'],
|
159 |
-
'sku' => $_item['sku'],
|
160 |
-
'attribute_set_id' => $_item['attribute_set_id'],
|
161 |
-
'attribute_set_name'=> $_item['attribute_set_name'],
|
162 |
-
'qty' => $_item['qty'],
|
163 |
-
'in_stock' => $_item['stock_status'] ? 1 : 0,
|
164 |
-
));
|
165 |
-
}
|
166 |
-
|
167 |
-
$schedule->setMessages($schedule->getMessages()
|
168 |
-
. sprintf('Ready to send %d inventory updates.', count($data)));
|
169 |
-
}
|
170 |
-
}
|
171 |
-
|
172 |
-
public function aggregateSalesReportOrderData($schedule)
|
173 |
-
{
|
174 |
-
$report = Mage::getResourceModel('neklo_monitor/minfo_daily')->collect();
|
175 |
-
|
176 |
-
$this->_addToRequestQueue('dailyreport', $report);
|
177 |
-
|
178 |
-
$schedule->setMessages($schedule->getMessages()
|
179 |
-
. sprintf('Collected sales report with %d new orders.', $report['orders']['all']['orders_count']));
|
180 |
}
|
181 |
|
182 |
/**
|
@@ -186,12 +64,4 @@ class Neklo_Monitor_Model_Observer
|
|
186 |
{
|
187 |
return Mage::helper('neklo_monitor/config');
|
188 |
}
|
189 |
-
|
190 |
-
/**
|
191 |
-
* @return Neklo_Monitor_Model_Gateway_Connector
|
192 |
-
*/
|
193 |
-
protected function _getConnector()
|
194 |
-
{
|
195 |
-
return Mage::getSingleton('neklo_monitor/gateway_connector');
|
196 |
-
}
|
197 |
}
|
2 |
|
3 |
class Neklo_Monitor_Model_Observer
|
4 |
{
|
5 |
+
public function actionPreDispatchConfigPage(Varien_Event_Observer $observer)
|
6 |
+
{
|
7 |
+
$request = $observer->getControllerAction()->getRequest();
|
8 |
+
$currentSection = $request->getParam('section', null);
|
9 |
+
if ($currentSection === 'neklo_monitor' && Mage::helper('neklo_monitor/config')->isUpdateAvailable()) {
|
10 |
+
Mage::getSingleton('adminhtml/session')->addNotice(
|
11 |
+
Mage::helper('neklo_monitor')->__(
|
12 |
+
'Currently you are using Magento Store Monitoring <b>%s</b>. Version <b>%s</b> is available. <a href="%s" target="_blank">Update now</a>.',
|
13 |
+
Mage::helper('neklo_monitor/config')->getModuleVersion(),
|
14 |
+
Mage::helper('neklo_monitor/config')->getLastVersion(),
|
15 |
+
Mage::helper('neklo_monitor/config')->getExtensionUrl()
|
16 |
+
)
|
17 |
+
);
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
/**
|
22 |
* @param Varien_Event_Observer $observer
|
23 |
* @observe order place event
|
24 |
*/
|
25 |
+
public function orderPlaceAfter(Varien_Event_Observer $observer)
|
26 |
{
|
27 |
if (!$this->_getConfig()->isEnabled()) {
|
28 |
return;
|
32 |
return;
|
33 |
}
|
34 |
|
35 |
+
/* @var Mage_Sales_Model_Order $order */
|
36 |
$order = $observer->getEvent()->getOrder();
|
37 |
|
38 |
+
// TODO: add base grand total
|
39 |
$total = $order->getGrandTotal();
|
40 |
+
$totalFormatted = $order->getOrderCurrency()->format($total, array(), false);
|
41 |
|
42 |
$info = array(
|
43 |
'increment_id' => $order->getIncrementId(),
|
44 |
'grand_total' => $total,
|
45 |
+
// TODO: typo grand_total_formatted
|
46 |
+
'grand_total_formated' => $totalFormatted,
|
47 |
'qty' => $order->getTotalQtyOrdered(),
|
48 |
);
|
49 |
|
50 |
+
$this->_addToRequestQueue(Neklo_Monitor_Model_Source_Gateway_Queue_Type::ORDER_CODE, $info);
|
51 |
}
|
52 |
|
53 |
protected function _addToRequestQueue($type, $info)
|
54 |
{
|
55 |
+
/* @var Neklo_Monitor_Model_Gateway_Queue $queue */
|
56 |
$queue = Mage::getModel('neklo_monitor/gateway_queue');
|
57 |
+
$queue->addToQueue($type, $info);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
}
|
59 |
|
60 |
/**
|
64 |
{
|
65 |
return Mage::helper('neklo_monitor/config');
|
66 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
}
|
app/code/community/Neklo/Monitor/Model/Report.php
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @method Neklo_Monitor_Model_Resource_Report getResource()
|
5 |
+
*/
|
6 |
+
class Neklo_Monitor_Model_Report extends Mage_Core_Model_Abstract
|
7 |
+
{
|
8 |
+
protected function _construct()
|
9 |
+
{
|
10 |
+
$this->_init('neklo_monitor/report');
|
11 |
+
}
|
12 |
+
|
13 |
+
public function saveReports($reportList)
|
14 |
+
{
|
15 |
+
return $this->getResource()->saveReports($reportList);
|
16 |
+
}
|
17 |
+
|
18 |
+
// TODO: clean
|
19 |
+
/**
|
20 |
+
* @return Varien_Data_Collection
|
21 |
+
*/
|
22 |
+
public function getFilesCollection($startFrom = 0, $limit = null, $filter = array())
|
23 |
+
{
|
24 |
+
// apply filters
|
25 |
+
|
26 |
+
$list = $this->_getData('files_list');
|
27 |
+
if ($filter) {
|
28 |
+
foreach ($list as $_key => $_data) {
|
29 |
+
$valid = true;
|
30 |
+
foreach ($filter as $_field => $_cond) {
|
31 |
+
if (!isset($_data[$_field])) {
|
32 |
+
$_data[$_field] = 0; // temporary, will not affect $list
|
33 |
+
}
|
34 |
+
foreach ($_cond as $_expr => $_value) {
|
35 |
+
if ('lt' == $_expr) { if ($_data[$_field] >= $_value) $valid = false; }
|
36 |
+
// else if ('lteq' == $_expr) { if ($_data[$_field] > $_value) $valid = false; }
|
37 |
+
// else if ('gt' == $_expr) { if ($_data[$_field] <= $_value) $valid = false; }
|
38 |
+
else if ('gteq' == $_expr) { if ($_data[$_field] < $_value) $valid = false; }
|
39 |
+
// else if ('eq' == $_expr) { if ($_data[$_field] <> $_value) $valid = false; }
|
40 |
+
// else if ('neq' == $_expr) { if ($_data[$_field] == $_value) $valid = false; }
|
41 |
+
}
|
42 |
+
}
|
43 |
+
if (!$valid) {
|
44 |
+
unset($list[$_key]);
|
45 |
+
}
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
// apply limits
|
50 |
+
|
51 |
+
$lastIdx = count($list) - 1;
|
52 |
+
if (is_null($limit)) {
|
53 |
+
$finishAt = $lastIdx;
|
54 |
+
} else {
|
55 |
+
$finishAt = $startFrom + $limit - 1;
|
56 |
+
if ($finishAt > $lastIdx) {
|
57 |
+
$finishAt = $lastIdx;
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
$collection = new Varien_Data_Collection();
|
62 |
+
$k = $startFrom;
|
63 |
+
$list = array_values($list); // avoid assoc array, convert to numeric array keys
|
64 |
+
while ($k <= $finishAt) {
|
65 |
+
$_file = new Varien_Object($list[$k]);
|
66 |
+
$collection->addItem($_file);
|
67 |
+
$k++;
|
68 |
+
}
|
69 |
+
|
70 |
+
return $collection;
|
71 |
+
}
|
72 |
+
|
73 |
+
// TODO: clean
|
74 |
+
protected function _afterLoad()
|
75 |
+
{
|
76 |
+
$files = Mage::helper('core')->jsonDecode($this->_getData('files'));
|
77 |
+
|
78 |
+
$list = array();
|
79 |
+
foreach ($files as $_data) {
|
80 |
+
$key = $_data['time'] . '_' . $_data['name'];
|
81 |
+
// $_data['key'] = $key;
|
82 |
+
$list[$key] = $_data;
|
83 |
+
}
|
84 |
+
|
85 |
+
// sort by mtime DESC
|
86 |
+
|
87 |
+
ksort($list);
|
88 |
+
$list = array_reverse($list, true);
|
89 |
+
|
90 |
+
$this->_data['files_list'] = $list;
|
91 |
+
return parent::_afterLoad();
|
92 |
+
}
|
93 |
+
}
|
app/code/community/Neklo/Monitor/Model/Resource/Account.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Model_Resource_Account extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
protected function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('neklo_monitor/account', 'entity_id');
|
8 |
+
}
|
9 |
+
}
|
app/code/community/Neklo/Monitor/Model/Resource/Account/Collection.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Model_Resource_Account_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
protected function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('neklo_monitor/account');
|
8 |
+
}
|
9 |
+
}
|
app/code/community/Neklo/Monitor/Model/Resource/Changelog.php
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
class Neklo_Monitor_Model_Resource_Changelog extends Mage_Core_Model_Mysql4_Abstract
|
5 |
{
|
6 |
protected function _construct()
|
@@ -8,46 +7,57 @@ class Neklo_Monitor_Model_Resource_Changelog extends Mage_Core_Model_Mysql4_Abst
|
|
8 |
$this->_init('neklo_monitor/cicl', 'cl_id');
|
9 |
}
|
10 |
|
11 |
-
public function
|
12 |
{
|
13 |
-
|
14 |
-
$
|
15 |
-
|
16 |
$eavConfig = Mage::getSingleton('eav/config');
|
17 |
-
|
18 |
-
$attrName = $eavConfig->getCollectionAttribute(
|
|
|
|
|
19 |
$attrNameTable = $attrName->getBackendTable();
|
20 |
|
21 |
$select = $this->_getReadAdapter()->select()
|
22 |
->distinct()
|
23 |
->from(array('cl' => $this->getMainTable()), array('cl.product_id'))
|
24 |
-
->join(
|
|
|
25 |
'st.product_id = cl.product_id',
|
26 |
-
array('st.qty', 'st.stock_status')
|
27 |
-
|
|
|
|
|
28 |
'n.entity_id = cl.product_id',
|
29 |
-
array('name' => 'n.value')
|
30 |
-
|
|
|
|
|
31 |
'p.entity_id = cl.product_id',
|
32 |
-
array('p.sku', 'p.attribute_set_id')
|
33 |
-
|
|
|
|
|
34 |
'as.attribute_set_id = p.attribute_set_id',
|
35 |
-
array('as.attribute_set_name')
|
|
|
36 |
->where('n.attribute_id = ?', $attrName->getId())
|
37 |
;
|
38 |
|
39 |
$data = $this->_getReadAdapter()->fetchAssoc($select);
|
40 |
|
41 |
$productIds = array();
|
42 |
-
foreach($data as $_val) {
|
43 |
$productIds[] = $_val['product_id'];
|
44 |
}
|
45 |
|
46 |
if ($productIds) {
|
47 |
-
$this->_getWriteAdapter()->delete(
|
|
|
|
|
48 |
}
|
49 |
|
50 |
return $data;
|
51 |
}
|
52 |
-
|
53 |
}
|
1 |
<?php
|
2 |
|
|
|
3 |
class Neklo_Monitor_Model_Resource_Changelog extends Mage_Core_Model_Mysql4_Abstract
|
4 |
{
|
5 |
protected function _construct()
|
7 |
$this->_init('neklo_monitor/cicl', 'cl_id');
|
8 |
}
|
9 |
|
10 |
+
public function fetch()
|
11 |
{
|
12 |
+
/* @var Mage_Catalog_Model_Resource_Product $productResource */
|
13 |
+
$productResource = Mage::getResourceModel('catalog/product');
|
14 |
+
/* @var Mage_Eav_Model_Config $eavConfig */
|
15 |
$eavConfig = Mage::getSingleton('eav/config');
|
16 |
+
/* @var Mage_Eav_Model_Entity_Attribute_Abstract $attrName */
|
17 |
+
$attrName = $eavConfig->getCollectionAttribute(
|
18 |
+
$productResource->getType(), 'name'
|
19 |
+
);
|
20 |
$attrNameTable = $attrName->getBackendTable();
|
21 |
|
22 |
$select = $this->_getReadAdapter()->select()
|
23 |
->distinct()
|
24 |
->from(array('cl' => $this->getMainTable()), array('cl.product_id'))
|
25 |
+
->join(
|
26 |
+
array('st' => $this->getTable('cataloginventory/stock_status')),
|
27 |
'st.product_id = cl.product_id',
|
28 |
+
array('st.qty', 'st.stock_status')
|
29 |
+
)
|
30 |
+
->join(
|
31 |
+
array('n' => $attrNameTable),
|
32 |
'n.entity_id = cl.product_id',
|
33 |
+
array('name' => 'n.value')
|
34 |
+
)
|
35 |
+
->join(
|
36 |
+
array('p' => $this->getTable('catalog/product')),
|
37 |
'p.entity_id = cl.product_id',
|
38 |
+
array('p.sku', 'p.attribute_set_id')
|
39 |
+
)
|
40 |
+
->join(
|
41 |
+
array('as' => $this->getTable('eav/attribute_set')),
|
42 |
'as.attribute_set_id = p.attribute_set_id',
|
43 |
+
array('as.attribute_set_name')
|
44 |
+
)
|
45 |
->where('n.attribute_id = ?', $attrName->getId())
|
46 |
;
|
47 |
|
48 |
$data = $this->_getReadAdapter()->fetchAssoc($select);
|
49 |
|
50 |
$productIds = array();
|
51 |
+
foreach ($data as $_val) {
|
52 |
$productIds[] = $_val['product_id'];
|
53 |
}
|
54 |
|
55 |
if ($productIds) {
|
56 |
+
$this->_getWriteAdapter()->delete(
|
57 |
+
$this->getMainTable(), array('product_id IN (?)' => $productIds)
|
58 |
+
);
|
59 |
}
|
60 |
|
61 |
return $data;
|
62 |
}
|
|
|
63 |
}
|
app/code/community/Neklo/Monitor/Model/Resource/Gateway/Queue.php
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
class Neklo_Monitor_Model_Resource_Gateway_Queue extends Mage_Core_Model_Mysql4_Abstract
|
5 |
{
|
6 |
protected function _construct()
|
@@ -10,7 +9,8 @@ class Neklo_Monitor_Model_Resource_Gateway_Queue extends Mage_Core_Model_Mysql4_
|
|
10 |
|
11 |
public function bookEntries($startedAt)
|
12 |
{
|
13 |
-
return $this->_getWriteAdapter()->update(
|
|
|
14 |
array('started_at' => $startedAt),
|
15 |
array('started_at = ?' => 0)
|
16 |
);
|
@@ -18,7 +18,8 @@ class Neklo_Monitor_Model_Resource_Gateway_Queue extends Mage_Core_Model_Mysql4_
|
|
18 |
|
19 |
public function sentEntries($startedAt, $sentAt)
|
20 |
{
|
21 |
-
return $this->_getWriteAdapter()->update(
|
|
|
22 |
array('sent_at' => $sentAt),
|
23 |
array('started_at = ?' => $startedAt)
|
24 |
);
|
@@ -26,23 +27,25 @@ class Neklo_Monitor_Model_Resource_Gateway_Queue extends Mage_Core_Model_Mysql4_
|
|
26 |
|
27 |
public function releaseEntries($startedAt)
|
28 |
{
|
29 |
-
return $this->_getWriteAdapter()->update(
|
|
|
30 |
array('started_at' => 0),
|
31 |
array(
|
32 |
'started_at < ?' => $startedAt,
|
33 |
-
'sent_at = ?'
|
34 |
)
|
35 |
);
|
36 |
}
|
37 |
|
38 |
public function cleanupEntries($startedAt)
|
39 |
{
|
40 |
-
return $this->_getWriteAdapter()->delete(
|
|
|
41 |
array(
|
42 |
'started_at > ?' => 0,
|
43 |
'started_at < ?' => $startedAt,
|
44 |
-
'sent_at > ?'
|
45 |
-
'sent_at < ?'
|
46 |
)
|
47 |
);
|
48 |
}
|
1 |
<?php
|
2 |
|
|
|
3 |
class Neklo_Monitor_Model_Resource_Gateway_Queue extends Mage_Core_Model_Mysql4_Abstract
|
4 |
{
|
5 |
protected function _construct()
|
9 |
|
10 |
public function bookEntries($startedAt)
|
11 |
{
|
12 |
+
return $this->_getWriteAdapter()->update(
|
13 |
+
$this->getMainTable(),
|
14 |
array('started_at' => $startedAt),
|
15 |
array('started_at = ?' => 0)
|
16 |
);
|
18 |
|
19 |
public function sentEntries($startedAt, $sentAt)
|
20 |
{
|
21 |
+
return $this->_getWriteAdapter()->update(
|
22 |
+
$this->getMainTable(),
|
23 |
array('sent_at' => $sentAt),
|
24 |
array('started_at = ?' => $startedAt)
|
25 |
);
|
27 |
|
28 |
public function releaseEntries($startedAt)
|
29 |
{
|
30 |
+
return $this->_getWriteAdapter()->update(
|
31 |
+
$this->getMainTable(),
|
32 |
array('started_at' => 0),
|
33 |
array(
|
34 |
'started_at < ?' => $startedAt,
|
35 |
+
'sent_at = ?' => 0,
|
36 |
)
|
37 |
);
|
38 |
}
|
39 |
|
40 |
public function cleanupEntries($startedAt)
|
41 |
{
|
42 |
+
return $this->_getWriteAdapter()->delete(
|
43 |
+
$this->getMainTable(),
|
44 |
array(
|
45 |
'started_at > ?' => 0,
|
46 |
'started_at < ?' => $startedAt,
|
47 |
+
'sent_at > ?' => 0,
|
48 |
+
'sent_at < ?' => $startedAt,
|
49 |
)
|
50 |
);
|
51 |
}
|
app/code/community/Neklo/Monitor/Model/Resource/Log.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Model_Resource_Log extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
protected function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('neklo_monitor/log', 'log_id');
|
8 |
+
}
|
9 |
+
}
|
app/code/community/Neklo/Monitor/Model/Resource/Log/Collection.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Model_Resource_Log_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
protected function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('neklo_monitor/log');
|
8 |
+
}
|
9 |
+
|
10 |
+
public function getTotal($isClearQtyNew = false)
|
11 |
+
{
|
12 |
+
$total = $this->_prepareTotal()->getFirstItem()->getData();
|
13 |
+
if ($isClearQtyNew) {
|
14 |
+
$this->_clearQtyNew($this->getAllIds());
|
15 |
+
}
|
16 |
+
return $total;
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function _prepareTotal()
|
20 |
+
{
|
21 |
+
$this->getSelect()->reset(Zend_Db_Select::COLUMNS);
|
22 |
+
$this->getSelect()->columns(
|
23 |
+
array(
|
24 |
+
'qty' => 'SUM(qty)',
|
25 |
+
'qty_new' => 'SUM(qty_new)',
|
26 |
+
)
|
27 |
+
);
|
28 |
+
return $this;
|
29 |
+
}
|
30 |
+
|
31 |
+
protected function _clearQtyNew($idList = array())
|
32 |
+
{
|
33 |
+
$idExpression = new Zend_Db_Expr('log_id in (' . join(',', $idList) . ')');
|
34 |
+
$this->getConnection()->update(
|
35 |
+
$this->getMainTable(), array('qty_new' => 0), $idExpression
|
36 |
+
);
|
37 |
+
return $this;
|
38 |
+
}
|
39 |
+
}
|
app/code/community/Neklo/Monitor/Model/Resource/Minfo/Daily.php
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
class Neklo_Monitor_Model_Resource_Minfo_Daily extends Mage_Sales_Model_Mysql4_Report_Abstract
|
5 |
{
|
6 |
protected function _construct()
|
@@ -25,72 +24,71 @@ class Neklo_Monitor_Model_Resource_Minfo_Daily extends Mage_Sales_Model_Mysql4_R
|
|
25 |
$dateStart->setMinute(0);
|
26 |
$dateStart->setSecond(0);
|
27 |
|
28 |
-
|
29 |
$report = array(
|
30 |
-
'orders'
|
31 |
-
'all'
|
32 |
-
'orders_count'
|
33 |
-
'subtotal_sum'
|
34 |
-
'subtotal_avg'
|
35 |
-
'revenue_sum'
|
36 |
-
'revenue_avg'
|
37 |
'items_qty_sum' => 0,
|
38 |
'items_qty_avg' => 0,
|
39 |
),
|
40 |
'newcustomers' => array(
|
41 |
-
'orders_count'
|
42 |
-
'subtotal_sum'
|
43 |
-
'subtotal_avg'
|
44 |
-
'revenue_sum'
|
45 |
-
'revenue_avg'
|
46 |
'items_qty_sum' => 0,
|
47 |
'items_qty_avg' => 0,
|
48 |
),
|
49 |
'oldcustomers' => array(
|
50 |
-
'orders_count'
|
51 |
-
'subtotal_sum'
|
52 |
-
'subtotal_avg'
|
53 |
-
'revenue_sum'
|
54 |
-
'revenue_avg'
|
55 |
'items_qty_sum' => 0,
|
56 |
'items_qty_avg' => 0,
|
57 |
),
|
58 |
-
'guests'
|
59 |
-
'orders_count'
|
60 |
-
'subtotal_sum'
|
61 |
-
'subtotal_avg'
|
62 |
-
'revenue_sum'
|
63 |
-
'revenue_avg'
|
64 |
'items_qty_sum' => 0,
|
65 |
'items_qty_avg' => 0,
|
66 |
),
|
67 |
),
|
68 |
'newcustomers_count' => 0,
|
69 |
-
'from'
|
70 |
-
'to'
|
71 |
);
|
72 |
|
73 |
-
|
74 |
-
/** @var Neklo_Monitor_Model_Resource_Minfo_Daily_ReportsOrderCollection $totalData */
|
75 |
$totalData = Mage::getResourceModel('neklo_monitor/minfo_daily_reportsOrderCollection');
|
76 |
$totalData->calculateDailyReport('custom', $dateStart, $dateEnd, false);
|
77 |
foreach ($totalData as $_data) {
|
78 |
$report['orders']['all'] = $this->_fillInDataArray($_data);
|
79 |
}
|
80 |
|
81 |
-
|
82 |
-
/** @var Neklo_Monitor_Model_Resource_Minfo_Daily_ReportsOrderCollection $splitData */
|
83 |
$splitData = Mage::getResourceModel('neklo_monitor/minfo_daily_reportsOrderCollection');
|
84 |
$splitData->calculateDailyReport('custom', $dateStart, $dateEnd, true);
|
85 |
foreach ($splitData as $_data) {
|
86 |
-
$report['orders'][
|
87 |
}
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
$
|
92 |
-
|
93 |
-
|
|
|
|
|
94 |
|
95 |
return $report;
|
96 |
}
|
1 |
<?php
|
2 |
|
|
|
3 |
class Neklo_Monitor_Model_Resource_Minfo_Daily extends Mage_Sales_Model_Mysql4_Report_Abstract
|
4 |
{
|
5 |
protected function _construct()
|
24 |
$dateStart->setMinute(0);
|
25 |
$dateStart->setSecond(0);
|
26 |
|
|
|
27 |
$report = array(
|
28 |
+
'orders' => array(
|
29 |
+
'all' => array(
|
30 |
+
'orders_count' => 0,
|
31 |
+
'subtotal_sum' => $this->_convertPrice(0),
|
32 |
+
'subtotal_avg' => $this->_convertPrice(0),
|
33 |
+
'revenue_sum' => $this->_convertPrice(0),
|
34 |
+
'revenue_avg' => $this->_convertPrice(0),
|
35 |
'items_qty_sum' => 0,
|
36 |
'items_qty_avg' => 0,
|
37 |
),
|
38 |
'newcustomers' => array(
|
39 |
+
'orders_count' => 0,
|
40 |
+
'subtotal_sum' => $this->_convertPrice(0),
|
41 |
+
'subtotal_avg' => $this->_convertPrice(0),
|
42 |
+
'revenue_sum' => $this->_convertPrice(0),
|
43 |
+
'revenue_avg' => $this->_convertPrice(0),
|
44 |
'items_qty_sum' => 0,
|
45 |
'items_qty_avg' => 0,
|
46 |
),
|
47 |
'oldcustomers' => array(
|
48 |
+
'orders_count' => 0,
|
49 |
+
'subtotal_sum' => $this->_convertPrice(0),
|
50 |
+
'subtotal_avg' => $this->_convertPrice(0),
|
51 |
+
'revenue_sum' => $this->_convertPrice(0),
|
52 |
+
'revenue_avg' => $this->_convertPrice(0),
|
53 |
'items_qty_sum' => 0,
|
54 |
'items_qty_avg' => 0,
|
55 |
),
|
56 |
+
'guests' => array(
|
57 |
+
'orders_count' => 0,
|
58 |
+
'subtotal_sum' => $this->_convertPrice(0),
|
59 |
+
'subtotal_avg' => $this->_convertPrice(0),
|
60 |
+
'revenue_sum' => $this->_convertPrice(0),
|
61 |
+
'revenue_avg' => $this->_convertPrice(0),
|
62 |
'items_qty_sum' => 0,
|
63 |
'items_qty_avg' => 0,
|
64 |
),
|
65 |
),
|
66 |
'newcustomers_count' => 0,
|
67 |
+
'from' => $dateStart->toString(Varien_Date::DATETIME_INTERNAL_FORMAT),
|
68 |
+
'to' => $dateEnd->toString(Varien_Date::DATETIME_INTERNAL_FORMAT),
|
69 |
);
|
70 |
|
71 |
+
/* @var Neklo_Monitor_Model_Resource_Minfo_Daily_ReportsOrderCollection $totalData */
|
|
|
72 |
$totalData = Mage::getResourceModel('neklo_monitor/minfo_daily_reportsOrderCollection');
|
73 |
$totalData->calculateDailyReport('custom', $dateStart, $dateEnd, false);
|
74 |
foreach ($totalData as $_data) {
|
75 |
$report['orders']['all'] = $this->_fillInDataArray($_data);
|
76 |
}
|
77 |
|
78 |
+
/* @var Neklo_Monitor_Model_Resource_Minfo_Daily_ReportsOrderCollection $splitData */
|
|
|
79 |
$splitData = Mage::getResourceModel('neklo_monitor/minfo_daily_reportsOrderCollection');
|
80 |
$splitData->calculateDailyReport('custom', $dateStart, $dateEnd, true);
|
81 |
foreach ($splitData as $_data) {
|
82 |
+
$report['orders'][$_data->getData('customer_type')] = $this->_fillInDataArray($_data);
|
83 |
}
|
84 |
|
85 |
+
/* @var Mage_Customer_Model_Entity_Customer_Collection $customerCollection */
|
86 |
+
$customerCollection = Mage::getResourceModel('customer/customer_collection');
|
87 |
+
$customerCollection->addAttributeToFilter(
|
88 |
+
'created_at',
|
89 |
+
array('from' => $dateStart, 'to' => $dateEnd, 'datetime' => true)
|
90 |
+
);
|
91 |
+
$report['newcustomers_count'] = $customerCollection->getSize();
|
92 |
|
93 |
return $report;
|
94 |
}
|
app/code/community/Neklo/Monitor/Model/Resource/Minfo/Daily/ReportsOrderCollection.php
CHANGED
@@ -6,76 +6,32 @@ class Neklo_Monitor_Model_Resource_Minfo_Daily_ReportsOrderCollection extends Ma
|
|
6 |
{
|
7 |
list($from, $to) = $this->getDateRange($range, $customStart, $customEnd, true);
|
8 |
$from = $from->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
|
9 |
-
$to
|
10 |
|
11 |
$this->setMainTable('sales/order');
|
12 |
-
|
13 |
$this->getSelect()->reset(Zend_Db_Select::COLUMNS);
|
14 |
$this->removeAllFieldsFromSelect();
|
15 |
|
16 |
$this->_addRevenueExpression();
|
17 |
|
18 |
-
/*
|
19 |
-
$subtotalExpr = vsprintf(
|
20 |
-
'(main_table.base_subtotal - %s - %s) * main_table.base_to_global_rate',
|
21 |
-
array(
|
22 |
-
new Zend_Db_Expr(sprintf("IFNULL(%s, %s)", 'main_table.base_subtotal_refunded', 0)),
|
23 |
-
new Zend_Db_Expr(sprintf("IFNULL(%s, %s)", 'main_table.base_subtotal_canceled', 0)),
|
24 |
-
)
|
25 |
-
);
|
26 |
-
$this->getSelect()->columns(array(
|
27 |
-
'orders_subtotal' => new Zend_Db_Expr(sprintf('SUM(%s)', $subtotalExpr)),
|
28 |
-
));
|
29 |
-
*/
|
30 |
-
|
31 |
-
/*
|
32 |
-
$shippingExpr = vsprintf(
|
33 |
-
'(main_table.base_shipping_amount - %s - %s) * main_table.base_to_global_rate',
|
34 |
-
array(
|
35 |
-
new Zend_Db_Expr(sprintf("IFNULL(%s, %s)", 'main_table.base_shipping_refunded', 0)),
|
36 |
-
new Zend_Db_Expr(sprintf("IFNULL(%s, %s)", 'main_table.base_shipping_canceled', 0)),
|
37 |
-
)
|
38 |
-
);
|
39 |
-
$this->getSelect()->columns(array(
|
40 |
-
'orders_shipping_sum' => new Zend_Db_Expr(sprintf('SUM(%s)', $shippingExpr))
|
41 |
-
));
|
42 |
-
*/
|
43 |
-
|
44 |
-
/*
|
45 |
-
$taxExpr = vsprintf(
|
46 |
-
'(main_table.base_tax_amount - %s - %s) * main_table.base_to_global_rate',
|
47 |
-
array(
|
48 |
-
new Zend_Db_Expr(sprintf("IFNULL(%s, %s)", 'main_table.base_tax_refunded', 0)),
|
49 |
-
new Zend_Db_Expr(sprintf("IFNULL(%s, %s)", 'main_table.base_tax_canceled', 0)),
|
50 |
-
)
|
51 |
-
);
|
52 |
-
$this->getSelect()->columns(array(
|
53 |
-
'orders_tax_sum' => new Zend_Db_Expr(sprintf('SUM(%s)', $taxExpr))
|
54 |
-
));
|
55 |
-
*/
|
56 |
-
|
57 |
if ($groupByCustomers) {
|
58 |
$this->_groupByCustomers($from, $to);
|
59 |
}
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
66 |
$this->addSumAvgTotals();
|
67 |
-
|
68 |
$this->addOrdersCount();
|
69 |
-
|
70 |
$this->_addSumAvgItems();
|
71 |
-
|
72 |
return $this;
|
73 |
-
|
74 |
}
|
75 |
|
76 |
protected function _addRevenueExpression()
|
77 |
{
|
78 |
-
// _getSalesAmountExpression for 'revenue'
|
79 |
$revenueExpression = vsprintf(
|
80 |
'(%s - %s - %s - (%s - %s - %s)) * main_table.base_to_global_rate',
|
81 |
array(
|
@@ -89,14 +45,22 @@ class Neklo_Monitor_Model_Resource_Minfo_Daily_ReportsOrderCollection extends Ma
|
|
89 |
)
|
90 |
);
|
91 |
$this->getSelect()
|
92 |
-
->columns(
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
|
98 |
Mage_Sales_Model_Order::STATE_NEW)
|
99 |
-
)
|
|
|
100 |
|
101 |
return $this;
|
102 |
}
|
@@ -106,18 +70,24 @@ class Neklo_Monitor_Model_Resource_Minfo_Daily_ReportsOrderCollection extends Ma
|
|
106 |
$adapter = $this->getConnection();
|
107 |
|
108 |
$registeredSubExpression = new Zend_Db_Expr(
|
109 |
-
sprintf(
|
|
|
110 |
$adapter->quoteInto('customers.created_at >= ?', $from),
|
111 |
$adapter->quoteInto('customers.created_at <= ?', $to)
|
112 |
)
|
113 |
);
|
114 |
-
$registeredExpression = new Zend_Db_Expr(
|
|
|
|
|
115 |
$this->getSelect()
|
116 |
-
->columns(
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
|
|
|
|
|
|
121 |
'customers.entity_id = main_table.customer_id',
|
122 |
array()
|
123 |
)
|
@@ -128,11 +98,12 @@ class Neklo_Monitor_Model_Resource_Minfo_Daily_ReportsOrderCollection extends Ma
|
|
128 |
|
129 |
protected function _addSumAvgItems()
|
130 |
{
|
131 |
-
$this->getSelect()
|
132 |
-
|
133 |
"items_qty_sum" => "SUM(main_table.total_qty_ordered)",
|
134 |
"items_qty_avg" => "AVG(main_table.total_qty_ordered)"
|
135 |
-
)
|
|
|
136 |
return $this;
|
137 |
}
|
138 |
}
|
6 |
{
|
7 |
list($from, $to) = $this->getDateRange($range, $customStart, $customEnd, true);
|
8 |
$from = $from->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
|
9 |
+
$to = $to->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
|
10 |
|
11 |
$this->setMainTable('sales/order');
|
|
|
12 |
$this->getSelect()->reset(Zend_Db_Select::COLUMNS);
|
13 |
$this->removeAllFieldsFromSelect();
|
14 |
|
15 |
$this->_addRevenueExpression();
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
if ($groupByCustomers) {
|
18 |
$this->_groupByCustomers($from, $to);
|
19 |
}
|
20 |
+
$this->addFieldToFilter(
|
21 |
+
'main_table.created_at',
|
22 |
+
array(
|
23 |
+
'from' => $from,
|
24 |
+
'to' => $to
|
25 |
+
)
|
26 |
+
);
|
27 |
$this->addSumAvgTotals();
|
|
|
28 |
$this->addOrdersCount();
|
|
|
29 |
$this->_addSumAvgItems();
|
|
|
30 |
return $this;
|
|
|
31 |
}
|
32 |
|
33 |
protected function _addRevenueExpression()
|
34 |
{
|
|
|
35 |
$revenueExpression = vsprintf(
|
36 |
'(%s - %s - %s - (%s - %s - %s)) * main_table.base_to_global_rate',
|
37 |
array(
|
45 |
)
|
46 |
);
|
47 |
$this->getSelect()
|
48 |
+
->columns(
|
49 |
+
array(
|
50 |
+
'revenue_sum' => new Zend_Db_Expr(
|
51 |
+
sprintf('SUM(%s)', $revenueExpression)
|
52 |
+
),
|
53 |
+
'revenue_avg' => new Zend_Db_Expr(
|
54 |
+
sprintf('AVG(%s)', $revenueExpression)
|
55 |
+
),
|
56 |
+
)
|
57 |
+
)
|
58 |
+
->where(
|
59 |
+
'main_table.state NOT IN (?)', array(
|
60 |
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
|
61 |
Mage_Sales_Model_Order::STATE_NEW)
|
62 |
+
)
|
63 |
+
;
|
64 |
|
65 |
return $this;
|
66 |
}
|
70 |
$adapter = $this->getConnection();
|
71 |
|
72 |
$registeredSubExpression = new Zend_Db_Expr(
|
73 |
+
sprintf(
|
74 |
+
"IF(%s AND %s, 'newcustomers', 'oldcustomers')",
|
75 |
$adapter->quoteInto('customers.created_at >= ?', $from),
|
76 |
$adapter->quoteInto('customers.created_at <= ?', $to)
|
77 |
)
|
78 |
);
|
79 |
+
$registeredExpression = new Zend_Db_Expr(
|
80 |
+
"IF(main_table.customer_id IS NULL, 'guests', {$registeredSubExpression})"
|
81 |
+
);
|
82 |
$this->getSelect()
|
83 |
+
->columns(
|
84 |
+
array(
|
85 |
+
// 0 - guest customers, 1 - registered within period, 2 - old customers
|
86 |
+
'customer_type' => $registeredExpression,
|
87 |
+
)
|
88 |
+
)
|
89 |
+
->joinLeft(
|
90 |
+
array('customers' => $this->getTable('customer/entity')),
|
91 |
'customers.entity_id = main_table.customer_id',
|
92 |
array()
|
93 |
)
|
98 |
|
99 |
protected function _addSumAvgItems()
|
100 |
{
|
101 |
+
$this->getSelect()->columns(
|
102 |
+
array(
|
103 |
"items_qty_sum" => "SUM(main_table.total_qty_ordered)",
|
104 |
"items_qty_avg" => "AVG(main_table.total_qty_ordered)"
|
105 |
+
)
|
106 |
+
);
|
107 |
return $this;
|
108 |
}
|
109 |
}
|
app/code/community/Neklo/Monitor/Model/Resource/Minfo/Log.php
DELETED
@@ -1,55 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
class Neklo_Monitor_Model_Resource_Minfo_Log extends Mage_Core_Model_Mysql4_Abstract
|
5 |
-
{
|
6 |
-
protected function _construct()
|
7 |
-
{
|
8 |
-
$this->_init('neklo_monitor/log', 'log_id');
|
9 |
-
}
|
10 |
-
|
11 |
-
public function fetchMaxtime($type)
|
12 |
-
{
|
13 |
-
$select = $this->_getReadAdapter()->select()
|
14 |
-
->from($this->getMainTable(), array('max_time' => new Zend_Db_Expr('MAX(`last_time`)')))
|
15 |
-
->where('type = ?', $type);
|
16 |
-
return (int) $this->_getReadAdapter()->fetchOne($select);
|
17 |
-
}
|
18 |
-
|
19 |
-
public function saveLogs($type, $logs)
|
20 |
-
{
|
21 |
-
$conn = $this->_getWriteAdapter();
|
22 |
-
$updated = $inserted = 0;
|
23 |
-
foreach ($logs as $hash => $data) {
|
24 |
-
|
25 |
-
$select = $conn->select()
|
26 |
-
->from($this->getMainTable())
|
27 |
-
->where('hash = ?', $hash)
|
28 |
-
->where('type = ?', $type);
|
29 |
-
$row = $conn->fetchRow($select);
|
30 |
-
|
31 |
-
$data['times'] = array_unique($data['times'], SORT_NUMERIC);
|
32 |
-
sort($data['times'], SORT_NUMERIC);
|
33 |
-
$data['times'] = array_reverse($data['times']);
|
34 |
-
|
35 |
-
$dbData = array(
|
36 |
-
'last_time' => $data['last_time'],
|
37 |
-
'qty' => $data['qty'],
|
38 |
-
'times' => implode(',', $data['times']),
|
39 |
-
);
|
40 |
-
if ($row) {
|
41 |
-
$conn->update($this->getMainTable(), $dbData, array('log_id = ?' => $row['log_id']));
|
42 |
-
$updated++;
|
43 |
-
} else {
|
44 |
-
$dbData['first_time'] = $data['first_time'];
|
45 |
-
$dbData['hash'] = $hash;
|
46 |
-
$dbData['type'] = $type;
|
47 |
-
$dbData['message'] = $data['message'];
|
48 |
-
$conn->insert($this->getMainTable(), $dbData);
|
49 |
-
$inserted++;
|
50 |
-
}
|
51 |
-
}
|
52 |
-
|
53 |
-
return array($inserted, $updated);
|
54 |
-
}
|
55 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Neklo/Monitor/Model/Resource/Minfo/Log/Collection.php
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
class Neklo_Monitor_Model_Resource_Minfo_Log_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
5 |
-
{
|
6 |
-
protected function _construct()
|
7 |
-
{
|
8 |
-
$this->_init('neklo_monitor/minfo_log');
|
9 |
-
}
|
10 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Neklo/Monitor/Model/Resource/Minfo/Report.php
DELETED
@@ -1,49 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
class Neklo_Monitor_Model_Resource_Minfo_Report extends Mage_Core_Model_Mysql4_Abstract
|
5 |
-
{
|
6 |
-
protected function _construct()
|
7 |
-
{
|
8 |
-
$this->_init('neklo_monitor/report', 'report_id');
|
9 |
-
}
|
10 |
-
|
11 |
-
public function fetchMaxMtime()
|
12 |
-
{
|
13 |
-
$select = $this->_getReadAdapter()->select()
|
14 |
-
->from($this->getMainTable(), array('max_mtime' => new Zend_Db_Expr('MAX(`last_time`)')));
|
15 |
-
return (int) $this->_getReadAdapter()->fetchOne($select);
|
16 |
-
}
|
17 |
-
|
18 |
-
public function saveReports($reports)
|
19 |
-
{
|
20 |
-
$conn = $this->_getWriteAdapter();
|
21 |
-
$updated = $inserted = 0;
|
22 |
-
foreach ($reports as $hash => $data) {
|
23 |
-
|
24 |
-
$select = $conn->select()
|
25 |
-
->from($this->getMainTable())
|
26 |
-
->where('hash = ?', $hash);
|
27 |
-
$row = $conn->fetchRow($select);
|
28 |
-
|
29 |
-
$dbData = array(
|
30 |
-
'last_time' => $data['last_time'],
|
31 |
-
'qty' => $data['qty'],
|
32 |
-
'files' => Mage::helper('core')->jsonEncode($data['files']),
|
33 |
-
);
|
34 |
-
if ($row) {
|
35 |
-
$conn->update($this->getMainTable(), $dbData, array('report_id = ?' => $row['report_id']));
|
36 |
-
$updated++;
|
37 |
-
} else {
|
38 |
-
$dbData['hash'] = $hash;
|
39 |
-
$dbData['message'] = $data['message'];
|
40 |
-
$dbData['first_time'] = $data['first_time'];
|
41 |
-
$conn->insert($this->getMainTable(), $dbData);
|
42 |
-
$inserted++;
|
43 |
-
}
|
44 |
-
}
|
45 |
-
|
46 |
-
return array($inserted, $updated);
|
47 |
-
}
|
48 |
-
|
49 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Neklo/Monitor/Model/Resource/Minfo/Report/Collection.php
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
class Neklo_Monitor_Model_Resource_Minfo_Report_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
5 |
-
{
|
6 |
-
protected function _construct()
|
7 |
-
{
|
8 |
-
$this->_init('neklo_monitor/minfo_report');
|
9 |
-
}
|
10 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Neklo/Monitor/Model/Resource/Report.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Model_Resource_Report extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
protected function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('neklo_monitor/report', 'report_id');
|
8 |
+
}
|
9 |
+
|
10 |
+
public function saveReports($reports)
|
11 |
+
{
|
12 |
+
if (!count($reports)) {
|
13 |
+
return 0;
|
14 |
+
}
|
15 |
+
$updated = $inserted = 0;
|
16 |
+
|
17 |
+
$writeAdapter = $this->_getWriteAdapter();
|
18 |
+
|
19 |
+
// Update exists rows
|
20 |
+
$hashList = array_map(
|
21 |
+
array($writeAdapter, 'quote'), array_keys($reports)
|
22 |
+
);
|
23 |
+
$hashExpression = new Zend_Db_Expr(join(',', $hashList));
|
24 |
+
$select = $writeAdapter->select()
|
25 |
+
->from($this->getMainTable())
|
26 |
+
->where('hash in (?)', $hashExpression)
|
27 |
+
;
|
28 |
+
|
29 |
+
$rowList = $writeAdapter->fetchAll($select);
|
30 |
+
foreach ($rowList as $row) {
|
31 |
+
if (!array_key_exists($row['hash'], $reports)) {
|
32 |
+
continue;
|
33 |
+
}
|
34 |
+
$reportData = $reports[$row['hash']];
|
35 |
+
unset($reports[$row['hash']]);
|
36 |
+
|
37 |
+
$updateData = array(
|
38 |
+
'last_time' => $reportData['last_time'],
|
39 |
+
'qty' => $row['qty'] + $reportData['qty'],
|
40 |
+
'qty_new' => $row['qty_new'] + $reportData['qty'],
|
41 |
+
'files' => Mage::helper('core')->jsonEncode($reportData['files']),
|
42 |
+
);
|
43 |
+
$writeAdapter->update(
|
44 |
+
$this->getMainTable(),
|
45 |
+
$updateData,
|
46 |
+
array('report_id = ?' => $row['report_id'])
|
47 |
+
);
|
48 |
+
$updated++;
|
49 |
+
}
|
50 |
+
|
51 |
+
// Insert new rows
|
52 |
+
foreach ($reports as $hash => $reportData) {
|
53 |
+
$reportData['qty_new'] = $reportData['qty'];
|
54 |
+
$reportData['files'] = Mage::helper('core')->jsonEncode($reportData['files']);
|
55 |
+
$writeAdapter->insert($this->getMainTable(), $reportData);
|
56 |
+
$inserted++;
|
57 |
+
}
|
58 |
+
|
59 |
+
// TODO: check
|
60 |
+
return array($inserted, $updated);
|
61 |
+
}
|
62 |
+
}
|
app/code/community/Neklo/Monitor/Model/Resource/Report/Collection.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Model_Resource_Report_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
protected function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('neklo_monitor/report');
|
8 |
+
}
|
9 |
+
|
10 |
+
public function getTotal($isClearQtyNew = false)
|
11 |
+
{
|
12 |
+
$total = $this->_prepareTotal()->getFirstItem()->getData();
|
13 |
+
if ($isClearQtyNew) {
|
14 |
+
$this->_clearQtyNew($this->getAllIds());
|
15 |
+
}
|
16 |
+
return $total;
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function _prepareTotal()
|
20 |
+
{
|
21 |
+
$this->getSelect()->reset(Zend_Db_Select::COLUMNS);
|
22 |
+
$this->getSelect()->columns(
|
23 |
+
array(
|
24 |
+
'qty' => 'SUM(qty)',
|
25 |
+
'qty_new' => 'SUM(qty_new)',
|
26 |
+
)
|
27 |
+
);
|
28 |
+
return $this;
|
29 |
+
}
|
30 |
+
|
31 |
+
protected function _clearQtyNew($idList = array())
|
32 |
+
{
|
33 |
+
$idExpression = new Zend_Db_Expr('report_id in (' . join(',', $idList) . ')');
|
34 |
+
$this->getConnection()->update(
|
35 |
+
$this->getMainTable(), array('qty_new' => 0), $idExpression
|
36 |
+
);
|
37 |
+
return $this;
|
38 |
+
}
|
39 |
+
}
|
app/code/community/Neklo/Monitor/Model/Source/Gateway/Queue/Type.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Model_Source_Gateway_Queue_Type
|
4 |
+
{
|
5 |
+
const DAILY_REPORT_CODE = 'dailyreport';
|
6 |
+
const DAILY_REPORT_LABEL = 'Daily Report';
|
7 |
+
|
8 |
+
const ORDER_CODE = 'order';
|
9 |
+
const ORDER_LABEL = 'Order';
|
10 |
+
|
11 |
+
const INVENTORY_CODE = 'inventory';
|
12 |
+
const INVENTORY_LABEL = 'Inventory';
|
13 |
+
}
|
app/code/community/Neklo/Monitor/Model/{System/Config/Source → Source/System/Config}/Server/Type.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class
|
4 |
{
|
5 |
const PRODUCTION_CODE = 'production';
|
6 |
const PRODUCTION_LABEL = 'Production';
|
@@ -32,4 +32,4 @@ class Neklo_Monitor_Model_System_Config_Source_Server_Type
|
|
32 |
}
|
33 |
return self::SANDBOX_URL;
|
34 |
}
|
35 |
-
}
|
1 |
<?php
|
2 |
|
3 |
+
class Neklo_Monitor_Model_Source_System_Config_Server_Type
|
4 |
{
|
5 |
const PRODUCTION_CODE = 'production';
|
6 |
const PRODUCTION_LABEL = 'Production';
|
32 |
}
|
33 |
return self::SANDBOX_URL;
|
34 |
}
|
35 |
+
}
|
app/code/community/Neklo/Monitor/Model/System/Config/Backend/Token.php
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Neklo_Monitor_Model_System_Config_Backend_Token extends Mage_Core_Model_Config_Data
|
4 |
-
{
|
5 |
-
public function getValue()
|
6 |
-
{
|
7 |
-
return $this->_getConfig()->getToken();
|
8 |
-
}
|
9 |
-
|
10 |
-
/**
|
11 |
-
* @return Neklo_Monitor_Helper_Config
|
12 |
-
*/
|
13 |
-
protected function _getConfig()
|
14 |
-
{
|
15 |
-
return Mage::helper('neklo_monitor/config');
|
16 |
-
}
|
17 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Neklo/Monitor/controllers/Adminhtml/Neklo/Monitor/Gateway/AccountController.php
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Adminhtml_Neklo_Monitor_Gateway_AccountController extends Neklo_Monitor_Controller_Adminhtml_Abstract
|
4 |
+
{
|
5 |
+
public function addAction()
|
6 |
+
{
|
7 |
+
$result = array(
|
8 |
+
'success' => true,
|
9 |
+
'messages' => array(),
|
10 |
+
);
|
11 |
+
|
12 |
+
if (!$this->_getConfig()->isConnected()) {
|
13 |
+
$result['success'] = false;
|
14 |
+
$result['messages'][] = Mage::helper('neklo_monitor')->__('Gateway is not connected.');
|
15 |
+
$this->getResponse()->setBody(Zend_Json::encode($result));
|
16 |
+
return;
|
17 |
+
}
|
18 |
+
|
19 |
+
$accountKeyList = array(
|
20 |
+
'phone_mask',
|
21 |
+
'firstname',
|
22 |
+
'lastname',
|
23 |
+
'email',
|
24 |
+
);
|
25 |
+
|
26 |
+
$accountData = $this->getRequest()->getParams();
|
27 |
+
|
28 |
+
foreach ($accountData as $key => $value) {
|
29 |
+
if (!in_array($key, $accountKeyList)) {
|
30 |
+
unset($accountData[$key]);
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
if (!is_array($accountData) || !count($accountData)) {
|
35 |
+
$result['success'] = false;
|
36 |
+
$result['messages'][] = Mage::helper('neklo_monitor')->__('Account data is not passed.');
|
37 |
+
$this->getResponse()->setBody(Zend_Json::encode($result));
|
38 |
+
return;
|
39 |
+
}
|
40 |
+
|
41 |
+
$accountData['phone'] = $accountData['phone_mask'];
|
42 |
+
|
43 |
+
$gatewayResult = $this->_getConnector()->addAccount($accountData);
|
44 |
+
|
45 |
+
if (
|
46 |
+
!is_array($gatewayResult) || !array_key_exists('success', $gatewayResult) || !$gatewayResult['success']
|
47 |
+
|| !array_key_exists('phone_hash', $gatewayResult) || !$gatewayResult['phone_hash']
|
48 |
+
) {
|
49 |
+
$result['success'] = false;
|
50 |
+
$result['messages'][] = Mage::helper('neklo_monitor')->__('Account is not created at gateway.');
|
51 |
+
$this->getResponse()->setBody(Zend_Json::encode($result));
|
52 |
+
return;
|
53 |
+
}
|
54 |
+
|
55 |
+
$accountModel = Mage::getModel('neklo_monitor/account')->loadByPhoneHash($result['phone_hash']);
|
56 |
+
if (!$accountModel->getId()) {
|
57 |
+
$accountData['phone_mask'] = $this->_phoneMask($accountData['phone_mask']);
|
58 |
+
$accountData['phone_hash'] = $gatewayResult['phone_hash'];
|
59 |
+
$accountModel->addData($accountData);
|
60 |
+
$accountModel->save();
|
61 |
+
}
|
62 |
+
|
63 |
+
$result['account'] = array(
|
64 |
+
'id' => $accountModel->getId(),
|
65 |
+
'phone_mask' => $accountModel->getPhoneMask(),
|
66 |
+
);
|
67 |
+
|
68 |
+
$result['messages'][] = Mage::helper('neklo_monitor')->__('Account is created.');
|
69 |
+
$this->getResponse()->setBody(Zend_Json::encode($result));
|
70 |
+
}
|
71 |
+
|
72 |
+
public function removeAction()
|
73 |
+
{
|
74 |
+
$result = array(
|
75 |
+
'success' => true,
|
76 |
+
'messages' => array(),
|
77 |
+
);
|
78 |
+
|
79 |
+
if (!$this->_getConfig()->isConnected()) {
|
80 |
+
$result['success'] = false;
|
81 |
+
$result['messages'][] = Mage::helper('neklo_monitor')->__('Gateway is not connected.');
|
82 |
+
$this->getResponse()->setBody(Zend_Json::encode($result));
|
83 |
+
return;
|
84 |
+
}
|
85 |
+
|
86 |
+
$accountId = $this->getRequest()->getParam('entity_id', null);
|
87 |
+
|
88 |
+
$accountModel = Mage::getModel('neklo_monitor/account')->load($accountId);
|
89 |
+
if (!$accountModel->getId()) {
|
90 |
+
$result['success'] = false;
|
91 |
+
$result['messages'][] = Mage::helper('neklo_monitor')->__('Account is not exists.');
|
92 |
+
$this->getResponse()->setBody(Zend_Json::encode($result));
|
93 |
+
return;
|
94 |
+
}
|
95 |
+
|
96 |
+
try {
|
97 |
+
$this->_getConnector()->removeAccount(
|
98 |
+
$accountModel->getPhoneHash()
|
99 |
+
);
|
100 |
+
} catch (Exception $e) {
|
101 |
+
$result['success'] = false;
|
102 |
+
$result['messages'][] = Mage::helper('neklo_monitor')->__('Account is not exists.');
|
103 |
+
$this->getResponse()->setBody($e->getMessage());
|
104 |
+
}
|
105 |
+
|
106 |
+
$accountModel->delete();
|
107 |
+
|
108 |
+
$result['messages'][] = Mage::helper('neklo_monitor')->__('Account hsa been deleted.');
|
109 |
+
$this->getResponse()->setBody(Zend_Json::encode($result));
|
110 |
+
}
|
111 |
+
|
112 |
+
protected function _phoneMask($phone)
|
113 |
+
{
|
114 |
+
$start = 4;
|
115 |
+
$end = 2;
|
116 |
+
|
117 |
+
$startPart = substr($phone, 0, $start);
|
118 |
+
$maskPart = str_repeat('*', strlen($phone) - $start - $end);
|
119 |
+
$endPart = substr($phone, -$end);
|
120 |
+
|
121 |
+
return $startPart . $maskPart . $endPart;
|
122 |
+
}
|
123 |
+
}
|
app/code/community/Neklo/Monitor/controllers/Adminhtml/Neklo/Monitor/GatewayController.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Neklo_Monitor_Adminhtml_Neklo_Monitor_GatewayController extends Neklo_Monitor_Controller_Adminhtml_Abstract
|
4 |
+
{
|
5 |
+
public function connectAction()
|
6 |
+
{
|
7 |
+
if (!$this->_getConfig()->isConnected()) {
|
8 |
+
try {
|
9 |
+
$result = $this->_getConnector()->connect();
|
10 |
+
} catch (Exception $e) {
|
11 |
+
}
|
12 |
+
$this->getResponse()->setBody(Zend_Json::encode($result));
|
13 |
+
}
|
14 |
+
}
|
15 |
+
|
16 |
+
public function disconnectAction()
|
17 |
+
{
|
18 |
+
if ($this->_getConfig()->isConnected()) {
|
19 |
+
try {
|
20 |
+
$result = $this->_getConnector()->disconnect();
|
21 |
+
|
22 |
+
$accountCollection = Mage::getResourceModel('neklo_monitor/account_collection');
|
23 |
+
/* @var $account Neklo_Monitor_Model_Account */
|
24 |
+
foreach ($accountCollection as $account) {
|
25 |
+
$account->isDeleted(true);
|
26 |
+
}
|
27 |
+
$accountCollection->save();
|
28 |
+
} catch (Exception $e) {
|
29 |
+
}
|
30 |
+
$this->getResponse()->setBody(Zend_Json::encode($result));
|
31 |
+
}
|
32 |
+
}
|
33 |
+
}
|
app/code/community/Neklo/Monitor/controllers/CustomerController.php
CHANGED
@@ -30,12 +30,6 @@ class Neklo_Monitor_CustomerController extends Neklo_Monitor_Controller_Abstract
|
|
30 |
$collection->addFieldToFilter('website_id', $store->getWebsiteId());
|
31 |
}
|
32 |
|
33 |
-
$queryTimestamp = (int) $this->_getRequestHelper()->getParam('query_timestamp', 0);
|
34 |
-
$queryDate = $hlpDate->convertToString($queryTimestamp);
|
35 |
-
if ($queryTimestamp > 0) {
|
36 |
-
$collection->addFieldToFilter('created_at', array('lt' => $queryDate));
|
37 |
-
}
|
38 |
-
|
39 |
$offset = $this->_getRequestHelper()->getParam('offset', 0);
|
40 |
$page = ceil($offset / self::PAGE_SIZE) + 1;
|
41 |
$collection->setPage($page, self::PAGE_SIZE);
|
@@ -46,22 +40,20 @@ class Neklo_Monitor_CustomerController extends Neklo_Monitor_Controller_Abstract
|
|
46 |
->toOptionHash()
|
47 |
;
|
48 |
|
49 |
-
$customerIds =
|
50 |
-
/*
|
51 |
-
$customerIds = array(); // // getAllIds without parameters resets limits and pages
|
52 |
foreach ($collection as $customer) {
|
53 |
$customerIds[] = $customer->getData('entity_id');
|
54 |
}
|
55 |
-
*/
|
56 |
|
57 |
/* @var $orders Mage_Sales_Model_Mysql4_Order_Collection */
|
58 |
$orders = Mage::getResourceModel('sales/order_collection');
|
59 |
$orders->addFieldToFilter('customer_id', array('in' => $customerIds));
|
60 |
$orders->addFieldToFilter('state', array('neq' => Mage_Sales_Model_Order::STATE_CANCELED));
|
61 |
|
62 |
-
$expr = ($storeId == 0)
|
63 |
-
? '(main_table.base_subtotal-IFNULL(main_table.base_subtotal_refunded,0)-IFNULL(main_table.base_subtotal_canceled,0))*main_table.base_to_global_rate'
|
64 |
-
: 'main_table.base_subtotal-IFNULL(main_table.base_subtotal_canceled,0)-IFNULL(main_table.base_subtotal_refunded,0)';
|
|
|
65 |
|
66 |
$orders->getSelect()
|
67 |
->group('customer_id')
|
@@ -97,13 +89,13 @@ class Neklo_Monitor_CustomerController extends Neklo_Monitor_Controller_Abstract
|
|
97 |
'billing_city' => $customer->getData('billing_city'),
|
98 |
'billing_postcode' => $customer->getData('billing_postcode'),
|
99 |
'billing_telephone' => $customer->getData('billing_telephone'),
|
100 |
-
'average_order_amount' =>
|
101 |
-
'total_order_amount' =>
|
102 |
'order_count' => 0,
|
103 |
);
|
104 |
if (array_key_exists($customer->getData('entity_id'), $ordersCount)) {
|
105 |
-
$customerData['average_order_amount'] =
|
106 |
-
$customerData['total_order_amount'] =
|
107 |
$customerData['order_count'] = (int)$ordersCount[$customer->getData('entity_id')]['order_count'];
|
108 |
}
|
109 |
|
@@ -112,8 +104,9 @@ class Neklo_Monitor_CustomerController extends Neklo_Monitor_Controller_Abstract
|
|
112 |
// $customerList['sql'] = $collection->getSelectSql(true);
|
113 |
|
114 |
// get new entities count
|
115 |
-
|
116 |
if ($queryTimestamp > 0) {
|
|
|
117 |
/* @var $collection Mage_Customer_Model_Entity_Customer_Collection */
|
118 |
$collection = Mage::getResourceModel('customer/customer_collection');
|
119 |
$collection->addFieldToFilter('created_at', array('gteq' => $queryDate));
|
@@ -163,9 +156,9 @@ class Neklo_Monitor_CustomerController extends Neklo_Monitor_Controller_Abstract
|
|
163 |
->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left')
|
164 |
;
|
165 |
|
166 |
-
|
167 |
$hlpDate = Mage::helper('neklo_monitor/date');
|
168 |
-
|
169 |
$hlpCountry = Mage::helper('neklo_monitor/country');
|
170 |
|
171 |
$customerList = array();
|
@@ -196,14 +189,9 @@ class Neklo_Monitor_CustomerController extends Neklo_Monitor_Controller_Abstract
|
|
196 |
|
197 |
/* @var $collection Mage_Log_Model_Mysql4_Visitor_Online_Collection */
|
198 |
$collection = $logModel->getCollection();
|
199 |
-
$collection
|
200 |
-
|
201 |
-
|
202 |
-
$queryTimestamp = (int) $this->_getRequestHelper()->getParam('query_timestamp', 0);
|
203 |
-
$queryDate = $hlpDate->convertToString($queryTimestamp);
|
204 |
-
if ($queryTimestamp > 0) {
|
205 |
-
$collection->addFieldToFilter('last_visit_at', array('lt' => $queryDate));
|
206 |
-
}
|
207 |
|
208 |
$offset = $this->_getRequestHelper()->getParam('offset', 0);
|
209 |
$page = ceil($offset / self::PAGE_SIZE) + 1;
|
@@ -237,8 +225,9 @@ class Neklo_Monitor_CustomerController extends Neklo_Monitor_Controller_Abstract
|
|
237 |
}
|
238 |
|
239 |
// get new entities count
|
240 |
-
|
241 |
if ($queryTimestamp > 0) {
|
|
|
242 |
/* @var $collection Mage_Log_Model_Mysql4_Visitor_Online_Collection */
|
243 |
$collection = $logModel->getCollection();
|
244 |
$collection->addFieldToFilter('last_url', array('nlike' => '%neklo_monitor%'));
|
@@ -250,4 +239,9 @@ class Neklo_Monitor_CustomerController extends Neklo_Monitor_Controller_Abstract
|
|
250 |
$this->_jsonResult($visitorList);
|
251 |
}
|
252 |
|
|
|
|
|
|
|
|
|
|
|
253 |
}
|
30 |
$collection->addFieldToFilter('website_id', $store->getWebsiteId());
|
31 |
}
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
$offset = $this->_getRequestHelper()->getParam('offset', 0);
|
34 |
$page = ceil($offset / self::PAGE_SIZE) + 1;
|
35 |
$collection->setPage($page, self::PAGE_SIZE);
|
40 |
->toOptionHash()
|
41 |
;
|
42 |
|
43 |
+
$customerIds = array(); // getAllIds without parameters resets limits and pages
|
|
|
|
|
44 |
foreach ($collection as $customer) {
|
45 |
$customerIds[] = $customer->getData('entity_id');
|
46 |
}
|
|
|
47 |
|
48 |
/* @var $orders Mage_Sales_Model_Mysql4_Order_Collection */
|
49 |
$orders = Mage::getResourceModel('sales/order_collection');
|
50 |
$orders->addFieldToFilter('customer_id', array('in' => $customerIds));
|
51 |
$orders->addFieldToFilter('state', array('neq' => Mage_Sales_Model_Order::STATE_CANCELED));
|
52 |
|
53 |
+
// $expr = ($storeId == 0)
|
54 |
+
// ? '(main_table.base_subtotal-IFNULL(main_table.base_subtotal_refunded,0)-IFNULL(main_table.base_subtotal_canceled,0))*main_table.base_to_global_rate'
|
55 |
+
// : 'main_table.base_subtotal-IFNULL(main_table.base_subtotal_canceled,0)-IFNULL(main_table.base_subtotal_refunded,0)';
|
56 |
+
$expr = 'main_table.base_grand_total-IFNULL(main_table.base_total_canceled,0)-IFNULL(main_table.base_total_refunded,0)';
|
57 |
|
58 |
$orders->getSelect()
|
59 |
->group('customer_id')
|
89 |
'billing_city' => $customer->getData('billing_city'),
|
90 |
'billing_postcode' => $customer->getData('billing_postcode'),
|
91 |
'billing_telephone' => $customer->getData('billing_telephone'),
|
92 |
+
'average_order_amount' => $this->_processValueCurrency(0),
|
93 |
+
'total_order_amount' => $this->_processValueCurrency(0),
|
94 |
'order_count' => 0,
|
95 |
);
|
96 |
if (array_key_exists($customer->getData('entity_id'), $ordersCount)) {
|
97 |
+
$customerData['average_order_amount'] = $this->_processValueCurrency($ordersCount[$customer->getData('entity_id')]['average_order_amount']*1);
|
98 |
+
$customerData['total_order_amount'] = $this->_processValueCurrency($ordersCount[$customer->getData('entity_id')]['total_order_amount']*1);
|
99 |
$customerData['order_count'] = (int)$ordersCount[$customer->getData('entity_id')]['order_count'];
|
100 |
}
|
101 |
|
104 |
// $customerList['sql'] = $collection->getSelectSql(true);
|
105 |
|
106 |
// get new entities count
|
107 |
+
$queryTimestamp = (int) $this->_getRequestHelper()->getParam('query_timestamp', 0);
|
108 |
if ($queryTimestamp > 0) {
|
109 |
+
$queryDate = $hlpDate->convertToString($queryTimestamp);
|
110 |
/* @var $collection Mage_Customer_Model_Entity_Customer_Collection */
|
111 |
$collection = Mage::getResourceModel('customer/customer_collection');
|
112 |
$collection->addFieldToFilter('created_at', array('gteq' => $queryDate));
|
156 |
->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left')
|
157 |
;
|
158 |
|
159 |
+
/* @var Neklo_Monitor_Helper_Date $hlpDate */
|
160 |
$hlpDate = Mage::helper('neklo_monitor/date');
|
161 |
+
/* @var Neklo_Monitor_Helper_Country $hlpCountry */
|
162 |
$hlpCountry = Mage::helper('neklo_monitor/country');
|
163 |
|
164 |
$customerList = array();
|
189 |
|
190 |
/* @var $collection Mage_Log_Model_Mysql4_Visitor_Online_Collection */
|
191 |
$collection = $logModel->getCollection();
|
192 |
+
$collection
|
193 |
+
->addFieldToFilter('last_url', array('nlike' => '%neklo_monitor%'))
|
194 |
+
->addFieldToFilter('customer_id', array('notnull' => true));
|
|
|
|
|
|
|
|
|
|
|
195 |
|
196 |
$offset = $this->_getRequestHelper()->getParam('offset', 0);
|
197 |
$page = ceil($offset / self::PAGE_SIZE) + 1;
|
225 |
}
|
226 |
|
227 |
// get new entities count
|
228 |
+
$queryTimestamp = (int) $this->_getRequestHelper()->getParam('query_timestamp', 0);
|
229 |
if ($queryTimestamp > 0) {
|
230 |
+
$queryDate = $hlpDate->convertToString($queryTimestamp);
|
231 |
/* @var $collection Mage_Log_Model_Mysql4_Visitor_Online_Collection */
|
232 |
$collection = $logModel->getCollection();
|
233 |
$collection->addFieldToFilter('last_url', array('nlike' => '%neklo_monitor%'));
|
239 |
$this->_jsonResult($visitorList);
|
240 |
}
|
241 |
|
242 |
+
protected function _processValueCurrency($value)
|
243 |
+
{
|
244 |
+
return Mage::helper('core')->currency($value, true, false);
|
245 |
+
}
|
246 |
+
|
247 |
}
|
app/code/community/Neklo/Monitor/controllers/OrderController.php
CHANGED
@@ -23,17 +23,6 @@ class Neklo_Monitor_OrderController extends Neklo_Monitor_Controller_Abstract
|
|
23 |
|
24 |
$collection->setOrder('main_table.created_at', 'desc');
|
25 |
|
26 |
-
$collection->getSelect()
|
27 |
-
->join(
|
28 |
-
array('ce' => $collection->getTable('customer/entity')),
|
29 |
-
'main_table.customer_id = ce.entity_id',
|
30 |
-
array(
|
31 |
-
'email' => 'ce.email',
|
32 |
-
'customer_group_id' => 'ce.group_id',
|
33 |
-
)
|
34 |
-
)
|
35 |
-
;
|
36 |
-
|
37 |
if ($customerId = $this->_getRequestHelper()->getParam('customer_id', null)) {
|
38 |
$collection->addFieldToFilter('customer_id', $customerId);
|
39 |
}
|
@@ -44,24 +33,14 @@ class Neklo_Monitor_OrderController extends Neklo_Monitor_Controller_Abstract
|
|
44 |
$collection->addFieldToFilter('main_table.store_id', $store->getId());
|
45 |
}
|
46 |
|
47 |
-
$orderItemsSelect = $collection->getConnection()->select();
|
48 |
-
$orderItemsSelect
|
49 |
-
->from(
|
50 |
-
$collection->getTable('sales/order_item'),
|
51 |
-
array(
|
52 |
-
'order_id' => 'order_id',
|
53 |
-
'items_count' => 'count(item_id)',
|
54 |
-
)
|
55 |
-
)
|
56 |
-
->group('order_id')
|
57 |
-
;
|
58 |
-
|
59 |
$collection->getSelect()
|
60 |
->join(
|
61 |
-
array('
|
62 |
-
'main_table.entity_id =
|
63 |
array(
|
64 |
-
'
|
|
|
|
|
65 |
)
|
66 |
)
|
67 |
;
|
23 |
|
24 |
$collection->setOrder('main_table.created_at', 'desc');
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
if ($customerId = $this->_getRequestHelper()->getParam('customer_id', null)) {
|
27 |
$collection->addFieldToFilter('customer_id', $customerId);
|
28 |
}
|
33 |
$collection->addFieldToFilter('main_table.store_id', $store->getId());
|
34 |
}
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
$collection->getSelect()
|
37 |
->join(
|
38 |
+
array('o' => $collection->getTable('sales/order')),
|
39 |
+
'main_table.entity_id = o.entity_id',
|
40 |
array(
|
41 |
+
'email' => 'o.customer_email',
|
42 |
+
'customer_group_id' => 'o.customer_group_id',
|
43 |
+
'items_count' => 'o.total_item_count',
|
44 |
)
|
45 |
)
|
46 |
;
|
app/code/community/Neklo/Monitor/controllers/ProductController.php
CHANGED
@@ -6,9 +6,9 @@ class Neklo_Monitor_ProductController extends Neklo_Monitor_Controller_Abstract
|
|
6 |
{
|
7 |
$storeId = $this->_getRequestHelper()->getParam('store', null);
|
8 |
|
9 |
-
|
10 |
-
$
|
11 |
-
$collection = $
|
12 |
|
13 |
$offset = $this->_getRequestHelper()->getParam('offset', 0);
|
14 |
$page = ceil($offset / self::PAGE_SIZE) + 1;
|
6 |
{
|
7 |
$storeId = $this->_getRequestHelper()->getParam('store', null);
|
8 |
|
9 |
+
/* @var Neklo_Monitor_Helper_Product $productHelper */
|
10 |
+
$productHelper = Mage::helper('neklo_monitor/product');
|
11 |
+
$collection = $productHelper->getProductsOutofstockCollection($storeId);
|
12 |
|
13 |
$offset = $this->_getRequestHelper()->getParam('offset', 0);
|
14 |
$page = ceil($offset / self::PAGE_SIZE) + 1;
|
app/code/community/Neklo/Monitor/controllers/Var/LogController.php
CHANGED
@@ -4,8 +4,8 @@ class Neklo_Monitor_Var_LogController extends Neklo_Monitor_Controller_Abstract
|
|
4 |
{
|
5 |
public function listAction()
|
6 |
{
|
7 |
-
/* @var $collection
|
8 |
-
$collection = Mage::getResourceModel('neklo_monitor/
|
9 |
|
10 |
// for pages lists - load next page rows despite newly inserted rows
|
11 |
$queryTimestamp = (int) $this->_getRequestHelper()->getParam('query_timestamp', 0);
|
@@ -22,13 +22,14 @@ class Neklo_Monitor_Var_LogController extends Neklo_Monitor_Controller_Abstract
|
|
22 |
|
23 |
$list = array('result' => array());
|
24 |
foreach ($collection as $log) {
|
25 |
-
|
|
|
26 |
$list['result'][] = array(
|
27 |
'type' => $log->getData('type'),
|
28 |
'hash' => $log->getData('hash'),
|
29 |
'message' => $log->getData('message'),
|
30 |
'qty' => (int)$log->getData('qty'),
|
31 |
-
'last_time' => (int)$log->getData('last_time'),
|
32 |
'first_time' => (int)$log->getData('first_time'),
|
33 |
);
|
34 |
}
|
@@ -37,8 +38,8 @@ class Neklo_Monitor_Var_LogController extends Neklo_Monitor_Controller_Abstract
|
|
37 |
// get new entities count
|
38 |
|
39 |
if ($queryTimestamp > 0) {
|
40 |
-
/* @var $collection
|
41 |
-
$collection = Mage::getResourceModel('neklo_monitor/
|
42 |
$collection->addFieldToFilter('last_time', array('gteq' => $queryTimestamp));
|
43 |
$list['new_entities_count'] = $collection->getSize();
|
44 |
// $list['sql2'] = $collection->getSelectCountSql()->__toString();
|
@@ -51,9 +52,9 @@ class Neklo_Monitor_Var_LogController extends Neklo_Monitor_Controller_Abstract
|
|
51 |
{
|
52 |
$hash = $this->_getRequestHelper()->getParam('hash', '');
|
53 |
|
54 |
-
/* @var $log
|
55 |
-
$log = Mage::getModel('neklo_monitor/
|
56 |
-
$log->
|
57 |
|
58 |
// for pages lists - load next page rows despite newly inserted rows
|
59 |
$filter = array();
|
@@ -64,12 +65,12 @@ class Neklo_Monitor_Var_LogController extends Neklo_Monitor_Controller_Abstract
|
|
64 |
|
65 |
$offset = $this->_getRequestHelper()->getParam('offset', 0);
|
66 |
|
|
|
67 |
$collection = $log->getTimesCollection($offset, self::PAGE_SIZE, $filter);
|
68 |
|
69 |
$list = array('result' => array());
|
70 |
-
Mage::log($collection->getItems());
|
71 |
foreach ($collection as $_logTime) {
|
72 |
-
|
73 |
$list['result'][] = (int)$_logTime->getData();
|
74 |
}
|
75 |
|
4 |
{
|
5 |
public function listAction()
|
6 |
{
|
7 |
+
/* @var $collection Neklo_Monitor_Model_Resource_Log_Collection */
|
8 |
+
$collection = Mage::getResourceModel('neklo_monitor/log_collection');
|
9 |
|
10 |
// for pages lists - load next page rows despite newly inserted rows
|
11 |
$queryTimestamp = (int) $this->_getRequestHelper()->getParam('query_timestamp', 0);
|
22 |
|
23 |
$list = array('result' => array());
|
24 |
foreach ($collection as $log) {
|
25 |
+
/* @var Neklo_Monitor_Model_Log $log */
|
26 |
+
$lastTime = $log->getData('last_time');
|
27 |
$list['result'][] = array(
|
28 |
'type' => $log->getData('type'),
|
29 |
'hash' => $log->getData('hash'),
|
30 |
'message' => $log->getData('message'),
|
31 |
'qty' => (int)$log->getData('qty'),
|
32 |
+
'last_time' => empty($lastTime) ? (int)$log->getData('first_time') : (int)$log->getData('last_time'),
|
33 |
'first_time' => (int)$log->getData('first_time'),
|
34 |
);
|
35 |
}
|
38 |
// get new entities count
|
39 |
|
40 |
if ($queryTimestamp > 0) {
|
41 |
+
/* @var $collection Neklo_Monitor_Model_Resource_Log_Collection */
|
42 |
+
$collection = Mage::getResourceModel('neklo_monitor/log_collection');
|
43 |
$collection->addFieldToFilter('last_time', array('gteq' => $queryTimestamp));
|
44 |
$list['new_entities_count'] = $collection->getSize();
|
45 |
// $list['sql2'] = $collection->getSelectCountSql()->__toString();
|
52 |
{
|
53 |
$hash = $this->_getRequestHelper()->getParam('hash', '');
|
54 |
|
55 |
+
/* @var $log Neklo_Monitor_Model_Log */
|
56 |
+
$log = Mage::getModel('neklo_monitor/log');
|
57 |
+
$log->loadByHash($hash);
|
58 |
|
59 |
// for pages lists - load next page rows despite newly inserted rows
|
60 |
$filter = array();
|
65 |
|
66 |
$offset = $this->_getRequestHelper()->getParam('offset', 0);
|
67 |
|
68 |
+
// TODO: check
|
69 |
$collection = $log->getTimesCollection($offset, self::PAGE_SIZE, $filter);
|
70 |
|
71 |
$list = array('result' => array());
|
|
|
72 |
foreach ($collection as $_logTime) {
|
73 |
+
/* @var Varien_Object $_logTime */
|
74 |
$list['result'][] = (int)$_logTime->getData();
|
75 |
}
|
76 |
|
app/code/community/Neklo/Monitor/controllers/Var/ReportController.php
CHANGED
@@ -4,8 +4,8 @@ class Neklo_Monitor_Var_ReportController extends Neklo_Monitor_Controller_Abstra
|
|
4 |
{
|
5 |
public function listAction()
|
6 |
{
|
7 |
-
/* @var $collection
|
8 |
-
$collection = Mage::getResourceModel('neklo_monitor/
|
9 |
|
10 |
// for pages lists - load next page rows despite newly inserted rows
|
11 |
$queryTimestamp = (int) $this->_getRequestHelper()->getParam('query_timestamp', 0);
|
@@ -22,7 +22,7 @@ class Neklo_Monitor_Var_ReportController extends Neklo_Monitor_Controller_Abstra
|
|
22 |
|
23 |
$list = array('result' => array());
|
24 |
foreach ($collection as $report) {
|
25 |
-
|
26 |
$list['result'][] = array(
|
27 |
'hash' => $report->getData('hash'),
|
28 |
'message' => $report->getData('message'),
|
@@ -36,8 +36,8 @@ class Neklo_Monitor_Var_ReportController extends Neklo_Monitor_Controller_Abstra
|
|
36 |
// get new entities count
|
37 |
|
38 |
if ($queryTimestamp > 0) {
|
39 |
-
/* @var $collection
|
40 |
-
$collection = Mage::getResourceModel('neklo_monitor/
|
41 |
$collection->addFieldToFilter('last_time', array('gteq' => $queryTimestamp));
|
42 |
$list['new_entities_count'] = $collection->getSize();
|
43 |
// $list['sql2'] = $collection->getSelectCountSql()->__toString();
|
@@ -50,8 +50,8 @@ class Neklo_Monitor_Var_ReportController extends Neklo_Monitor_Controller_Abstra
|
|
50 |
{
|
51 |
$hash = $this->_getRequestHelper()->getParam('hash', '');
|
52 |
|
53 |
-
/* @var $report
|
54 |
-
$report = Mage::getModel('neklo_monitor/
|
55 |
$report->load($hash, 'hash');
|
56 |
|
57 |
// for pages lists - load next page rows despite newly inserted rows
|
4 |
{
|
5 |
public function listAction()
|
6 |
{
|
7 |
+
/* @var $collection Neklo_Monitor_Model_Resource_Report_Collection */
|
8 |
+
$collection = Mage::getResourceModel('neklo_monitor/report_collection');
|
9 |
|
10 |
// for pages lists - load next page rows despite newly inserted rows
|
11 |
$queryTimestamp = (int) $this->_getRequestHelper()->getParam('query_timestamp', 0);
|
22 |
|
23 |
$list = array('result' => array());
|
24 |
foreach ($collection as $report) {
|
25 |
+
/* @var Neklo_Monitor_Model_Report $report */
|
26 |
$list['result'][] = array(
|
27 |
'hash' => $report->getData('hash'),
|
28 |
'message' => $report->getData('message'),
|
36 |
// get new entities count
|
37 |
|
38 |
if ($queryTimestamp > 0) {
|
39 |
+
/* @var $collection Neklo_Monitor_Model_Resource_Report_Collection */
|
40 |
+
$collection = Mage::getResourceModel('neklo_monitor/report_collection');
|
41 |
$collection->addFieldToFilter('last_time', array('gteq' => $queryTimestamp));
|
42 |
$list['new_entities_count'] = $collection->getSize();
|
43 |
// $list['sql2'] = $collection->getSelectCountSql()->__toString();
|
50 |
{
|
51 |
$hash = $this->_getRequestHelper()->getParam('hash', '');
|
52 |
|
53 |
+
/* @var $report Neklo_Monitor_Model_Report */
|
54 |
+
$report = Mage::getModel('neklo_monitor/report');
|
55 |
$report->load($hash, 'hash');
|
56 |
|
57 |
// for pages lists - load next page rows despite newly inserted rows
|
app/code/community/Neklo/Monitor/etc/config.xml
CHANGED
@@ -2,7 +2,9 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Neklo_Monitor>
|
5 |
-
<version>1.
|
|
|
|
|
6 |
</Neklo_Monitor>
|
7 |
</modules>
|
8 |
<global>
|
@@ -36,6 +38,7 @@
|
|
36 |
<log><table>neklo_monitor_log</table></log>
|
37 |
<queue><table>neklo_monitor_queue</table></queue>
|
38 |
<cicl><table>neklo_monitor_cataloginventory_cl</table></cicl>
|
|
|
39 |
</entities>
|
40 |
</neklo_monitor_resource>
|
41 |
</models>
|
@@ -49,13 +52,18 @@
|
|
49 |
<events>
|
50 |
<sales_order_place_after>
|
51 |
<observers>
|
52 |
-
<
|
53 |
<class>neklo_monitor/observer</class>
|
54 |
-
<method>
|
55 |
-
</
|
56 |
</observers>
|
57 |
</sales_order_place_after>
|
58 |
</events>
|
|
|
|
|
|
|
|
|
|
|
59 |
</global>
|
60 |
<frontend>
|
61 |
<routers>
|
@@ -68,6 +76,29 @@
|
|
68 |
</neklo_monitor>
|
69 |
</routers>
|
70 |
</frontend>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
<crontab>
|
72 |
<jobs>
|
73 |
<neklo_monitor_send_server_info>
|
@@ -75,7 +106,7 @@
|
|
75 |
<cron_expr>* * * * *</cron_expr>
|
76 |
</schedule>
|
77 |
<run>
|
78 |
-
<model>neklo_monitor/
|
79 |
</run>
|
80 |
</neklo_monitor_send_server_info>
|
81 |
<neklo_monitor_send_store_info>
|
@@ -83,41 +114,42 @@
|
|
83 |
<cron_expr>* * * * *</cron_expr>
|
84 |
</schedule>
|
85 |
<run>
|
86 |
-
<model>neklo_monitor/
|
87 |
</run>
|
88 |
</neklo_monitor_send_store_info>
|
89 |
-
<
|
90 |
<schedule>
|
91 |
<cron_expr>*/5 * * * *</cron_expr>
|
92 |
</schedule>
|
93 |
<run>
|
94 |
-
<model>neklo_monitor/
|
95 |
</run>
|
96 |
-
</
|
97 |
-
<
|
98 |
<schedule>
|
99 |
<cron_expr>* * * * *</cron_expr>
|
100 |
</schedule>
|
101 |
<run>
|
102 |
-
<model>neklo_monitor/
|
103 |
</run>
|
104 |
-
</
|
105 |
-
|
|
|
106 |
<schedule>
|
107 |
-
<cron_expr
|
108 |
</schedule>
|
109 |
<run>
|
110 |
-
<model>neklo_monitor/
|
111 |
</run>
|
112 |
-
</
|
113 |
-
<
|
114 |
<schedule>
|
115 |
-
<cron_expr
|
116 |
</schedule>
|
117 |
<run>
|
118 |
-
<model>neklo_monitor/
|
119 |
</run>
|
120 |
-
</
|
121 |
</jobs>
|
122 |
</crontab>
|
123 |
<default>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Neklo_Monitor>
|
5 |
+
<version>1.3.0</version>
|
6 |
+
<api_version>1.3.0</api_version>
|
7 |
+
<platform>Magento1</platform>
|
8 |
</Neklo_Monitor>
|
9 |
</modules>
|
10 |
<global>
|
38 |
<log><table>neklo_monitor_log</table></log>
|
39 |
<queue><table>neklo_monitor_queue</table></queue>
|
40 |
<cicl><table>neklo_monitor_cataloginventory_cl</table></cicl>
|
41 |
+
<account><table>neklo_monitor_account</table></account>
|
42 |
</entities>
|
43 |
</neklo_monitor_resource>
|
44 |
</models>
|
52 |
<events>
|
53 |
<sales_order_place_after>
|
54 |
<observers>
|
55 |
+
<neklo_monitor_order_place_after>
|
56 |
<class>neklo_monitor/observer</class>
|
57 |
+
<method>orderPlaceAfter</method>
|
58 |
+
</neklo_monitor_order_place_after>
|
59 |
</observers>
|
60 |
</sales_order_place_after>
|
61 |
</events>
|
62 |
+
<log>
|
63 |
+
<core>
|
64 |
+
<writer_model>Neklo_Monitor_Model_Log_Writer_Stream</writer_model>
|
65 |
+
</core>
|
66 |
+
</log>
|
67 |
</global>
|
68 |
<frontend>
|
69 |
<routers>
|
76 |
</neklo_monitor>
|
77 |
</routers>
|
78 |
</frontend>
|
79 |
+
<admin>
|
80 |
+
<routers>
|
81 |
+
<adminhtml>
|
82 |
+
<args>
|
83 |
+
<modules>
|
84 |
+
<Neklo_Monitor before="Mage_Adminhtml">Neklo_Monitor_Adminhtml</Neklo_Monitor>
|
85 |
+
</modules>
|
86 |
+
</args>
|
87 |
+
</adminhtml>
|
88 |
+
</routers>
|
89 |
+
</admin>
|
90 |
+
<adminhtml>
|
91 |
+
<events>
|
92 |
+
<controller_action_predispatch_adminhtml_system_config_edit>
|
93 |
+
<observers>
|
94 |
+
<neklo_ldap_config_page>
|
95 |
+
<class>neklo_monitor/observer</class>
|
96 |
+
<method>actionPreDispatchConfigPage</method>
|
97 |
+
</neklo_ldap_config_page>
|
98 |
+
</observers>
|
99 |
+
</controller_action_predispatch_adminhtml_system_config_edit>
|
100 |
+
</events>
|
101 |
+
</adminhtml>
|
102 |
<crontab>
|
103 |
<jobs>
|
104 |
<neklo_monitor_send_server_info>
|
106 |
<cron_expr>* * * * *</cron_expr>
|
107 |
</schedule>
|
108 |
<run>
|
109 |
+
<model>neklo_monitor/cron::sendServerInfo</model>
|
110 |
</run>
|
111 |
</neklo_monitor_send_server_info>
|
112 |
<neklo_monitor_send_store_info>
|
114 |
<cron_expr>* * * * *</cron_expr>
|
115 |
</schedule>
|
116 |
<run>
|
117 |
+
<model>neklo_monitor/cron::sendStoreInfo</model>
|
118 |
</run>
|
119 |
</neklo_monitor_send_store_info>
|
120 |
+
<neklo_monitor_collect_var_reports>
|
121 |
<schedule>
|
122 |
<cron_expr>*/5 * * * *</cron_expr>
|
123 |
</schedule>
|
124 |
<run>
|
125 |
+
<model>neklo_monitor/cron::collectVarReports</model>
|
126 |
</run>
|
127 |
+
</neklo_monitor_collect_var_reports>
|
128 |
+
<neklo_monitor_convert_invetory_changelog_to_queue>
|
129 |
<schedule>
|
130 |
<cron_expr>* * * * *</cron_expr>
|
131 |
</schedule>
|
132 |
<run>
|
133 |
+
<model>neklo_monitor/cron::convertInventoryChangelogToQueue</model>
|
134 |
</run>
|
135 |
+
</neklo_monitor_convert_invetory_changelog_to_queue>
|
136 |
+
|
137 |
+
<neklo_monitor_aggregate_sales_report_order_data>
|
138 |
<schedule>
|
139 |
+
<cron_expr>5 0 * * *</cron_expr>
|
140 |
</schedule>
|
141 |
<run>
|
142 |
+
<model>neklo_monitor/cron::aggregateSalesReportOrderData</model>
|
143 |
</run>
|
144 |
+
</neklo_monitor_aggregate_sales_report_order_data>
|
145 |
+
<neklo_monitor_send_queue>
|
146 |
<schedule>
|
147 |
+
<cron_expr>* * * * *</cron_expr>
|
148 |
</schedule>
|
149 |
<run>
|
150 |
+
<model>neklo_monitor/cron::sendQueue</model>
|
151 |
</run>
|
152 |
+
</neklo_monitor_send_queue>
|
153 |
</jobs>
|
154 |
</crontab>
|
155 |
<default>
|
app/code/community/Neklo/Monitor/etc/system.xml
CHANGED
@@ -25,179 +25,108 @@
|
|
25 |
<show_in_store>0</show_in_store>
|
26 |
<expanded>1</expanded>
|
27 |
<fields>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
<is_enabled translate="label">
|
29 |
<label>Is Enabled</label>
|
30 |
<frontend_type>select</frontend_type>
|
31 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
32 |
-
<sort_order>
|
33 |
<show_in_default>1</show_in_default>
|
34 |
<show_in_website>0</show_in_website>
|
35 |
<show_in_store>0</show_in_store>
|
36 |
</is_enabled>
|
37 |
</fields>
|
38 |
</general>
|
39 |
-
<!--security translate="label">
|
40 |
-
<label>Security Settings</label>
|
41 |
-
<frontend_type>text</frontend_type>
|
42 |
-
<sort_order>20</sort_order>
|
43 |
-
<show_in_default>1</show_in_default>
|
44 |
-
<show_in_website>0</show_in_website>
|
45 |
-
<show_in_store>0</show_in_store>
|
46 |
-
<fields>
|
47 |
-
</fields>
|
48 |
-
</security-->
|
49 |
<gateway>
|
50 |
<label>Gateway Connection</label>
|
51 |
<frontend_type>text</frontend_type>
|
52 |
-
<sort_order>
|
53 |
<show_in_default>1</show_in_default>
|
54 |
<show_in_website>0</show_in_website>
|
55 |
<show_in_store>0</show_in_store>
|
56 |
<fields>
|
57 |
-
<token translate="label">
|
58 |
-
<label>Token</label>
|
59 |
-
<frontend_type>label</frontend_type>
|
60 |
-
<backend_model>neklo_monitor/system_config_backend_token</backend_model>
|
61 |
-
<sort_order>19</sort_order>
|
62 |
-
<show_in_default>1</show_in_default>
|
63 |
-
<show_in_website>0</show_in_website>
|
64 |
-
<show_in_store>0</show_in_store>
|
65 |
-
</token>
|
66 |
-
<!--server_type>
|
67 |
-
<label>Server Type</label>
|
68 |
-
<frontend_type>select</frontend_type>
|
69 |
-
<source_model>neklo_monitor/system_config_source_server_type</source_model>
|
70 |
-
<sort_order>10</sort_order>
|
71 |
-
<show_in_default>1</show_in_default>
|
72 |
-
<show_in_website>0</show_in_website>
|
73 |
-
<show_in_store>0</show_in_store>
|
74 |
-
</server_type-->
|
75 |
<status_production translate="label">
|
76 |
<label>Status</label>
|
77 |
<frontend_type>label</frontend_type>
|
78 |
<frontend_model>neklo_monitor_adminhtml/system_config_frontend_status</frontend_model>
|
79 |
<backend_model>neklo_monitor/system_config_backend_empty</backend_model>
|
80 |
-
<sort_order>
|
81 |
<show_in_default>1</show_in_default>
|
82 |
<show_in_website>0</show_in_website>
|
83 |
<show_in_store>0</show_in_store>
|
84 |
<depends>
|
85 |
<server_type>production</server_type>
|
86 |
</depends>
|
|
|
87 |
</status_production>
|
88 |
-
|
89 |
-
<
|
90 |
-
<frontend_type>label</frontend_type>
|
91 |
-
<frontend_model>neklo_monitor_adminhtml/system_config_frontend_status</frontend_model>
|
92 |
-
<backend_model>neklo_monitor/system_config_backend_empty</backend_model>
|
93 |
<sort_order>20</sort_order>
|
94 |
<show_in_default>1</show_in_default>
|
95 |
<show_in_website>0</show_in_website>
|
96 |
<show_in_store>0</show_in_store>
|
97 |
-
|
98 |
-
<server_type>sandbox</server_type>
|
99 |
-
</depends>
|
100 |
-
</status_sandbox>
|
101 |
-
<plan_production translate="label">
|
102 |
-
<label>Plan</label>
|
103 |
-
<frontend_type>label</frontend_type>
|
104 |
-
<frontend_model>neklo_monitor_adminhtml/system_config_frontend_label</frontend_model>
|
105 |
-
<sort_order>30</sort_order>
|
106 |
-
<show_in_default>1</show_in_default>
|
107 |
-
<show_in_website>0</show_in_website>
|
108 |
-
<show_in_store>0</show_in_store>
|
109 |
-
<depends>
|
110 |
-
<server_type>production</server_type>
|
111 |
-
</depends>
|
112 |
-
</plan_production>
|
113 |
-
<plan_sandbox translate="label">
|
114 |
-
<label>Plan</label>
|
115 |
-
<frontend_type>label</frontend_type>
|
116 |
-
<frontend_model>neklo_monitor_adminhtml/system_config_frontend_label</frontend_model>
|
117 |
-
<sort_order>30</sort_order>
|
118 |
-
<show_in_default>1</show_in_default>
|
119 |
-
<show_in_website>0</show_in_website>
|
120 |
-
<show_in_store>0</show_in_store>
|
121 |
-
<depends>
|
122 |
-
<server_type>sandbox</server_type>
|
123 |
-
</depends>
|
124 |
-
</plan_sandbox>
|
125 |
-
<frequency_production translate="label">
|
126 |
-
<label>Frequency</label>
|
127 |
-
<frontend_type>label</frontend_type>
|
128 |
-
<frontend_model>neklo_monitor_adminhtml/system_config_frontend_label</frontend_model>
|
129 |
-
<sort_order>40</sort_order>
|
130 |
-
<show_in_default>1</show_in_default>
|
131 |
-
<show_in_website>0</show_in_website>
|
132 |
-
<show_in_store>0</show_in_store>
|
133 |
-
<depends>
|
134 |
-
<server_type>production</server_type>
|
135 |
-
</depends>
|
136 |
-
</frequency_production>
|
137 |
-
<frequency_sandbox translate="label">
|
138 |
-
<label>Frequency</label>
|
139 |
-
<frontend_type>label</frontend_type>
|
140 |
-
<frontend_model>neklo_monitor_adminhtml/system_config_frontend_label</frontend_model>
|
141 |
-
<sort_order>40</sort_order>
|
142 |
-
<show_in_default>1</show_in_default>
|
143 |
-
<show_in_website>0</show_in_website>
|
144 |
-
<show_in_store>0</show_in_store>
|
145 |
-
<depends>
|
146 |
-
<server_type>sandbox</server_type>
|
147 |
-
</depends>
|
148 |
-
</frequency_sandbox>
|
149 |
-
<last_update_production translate="label">
|
150 |
-
<label>Last Update</label>
|
151 |
-
<frontend_type>label</frontend_type>
|
152 |
-
<frontend_model>neklo_monitor_adminhtml/system_config_frontend_label</frontend_model>
|
153 |
-
<sort_order>50</sort_order>
|
154 |
-
<show_in_default>1</show_in_default>
|
155 |
-
<show_in_website>0</show_in_website>
|
156 |
-
<show_in_store>0</show_in_store>
|
157 |
-
<depends>
|
158 |
-
<server_type>production</server_type>
|
159 |
-
</depends>
|
160 |
-
</last_update_production>
|
161 |
-
<last_update_sandbox translate="label">
|
162 |
-
<label>Last Update</label>
|
163 |
-
<frontend_type>label</frontend_type>
|
164 |
-
<frontend_model>neklo_monitor_adminhtml/system_config_frontend_label</frontend_model>
|
165 |
-
<sort_order>50</sort_order>
|
166 |
-
<show_in_default>1</show_in_default>
|
167 |
-
<show_in_website>0</show_in_website>
|
168 |
-
<show_in_store>0</show_in_store>
|
169 |
-
<depends>
|
170 |
-
<server_type>sandbox</server_type>
|
171 |
-
</depends>
|
172 |
-
</last_update_sandbox-->
|
173 |
</fields>
|
174 |
</gateway>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
<mobileapp translate="label">
|
176 |
<label>Mobile Application</label>
|
177 |
<comment><![CDATA[
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
<tr>
|
184 |
-
<td
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
<
|
192 |
-
</
|
193 |
-
<
|
194 |
-
<td
|
195 |
-
|
196 |
-
|
|
|
|
|
|
|
|
|
197 |
</table>
|
198 |
]]></comment>
|
199 |
<frontend_type>text</frontend_type>
|
200 |
-
<sort_order>
|
201 |
<show_in_default>1</show_in_default>
|
202 |
<show_in_website>0</show_in_website>
|
203 |
<show_in_store>0</show_in_store>
|
25 |
<show_in_store>0</show_in_store>
|
26 |
<expanded>1</expanded>
|
27 |
<fields>
|
28 |
+
<installed_version translate="label">
|
29 |
+
<label>Installed Version</label>
|
30 |
+
<frontend_type>label</frontend_type>
|
31 |
+
<frontend_model>neklo_monitor/adminhtml_system_config_frontend_version_current</frontend_model>
|
32 |
+
<sort_order>10</sort_order>
|
33 |
+
<show_in_default>1</show_in_default>
|
34 |
+
<show_in_website>1</show_in_website>
|
35 |
+
<show_in_store>1</show_in_store>
|
36 |
+
</installed_version>
|
37 |
+
<last_version translate="label">
|
38 |
+
<label>Last Version</label>
|
39 |
+
<frontend_type>label</frontend_type>
|
40 |
+
<frontend_model>neklo_monitor/adminhtml_system_config_frontend_version_last</frontend_model>
|
41 |
+
<sort_order>20</sort_order>
|
42 |
+
<show_in_default>1</show_in_default>
|
43 |
+
<show_in_website>1</show_in_website>
|
44 |
+
<show_in_store>1</show_in_store>
|
45 |
+
</last_version>
|
46 |
<is_enabled translate="label">
|
47 |
<label>Is Enabled</label>
|
48 |
<frontend_type>select</frontend_type>
|
49 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
50 |
+
<sort_order>30</sort_order>
|
51 |
<show_in_default>1</show_in_default>
|
52 |
<show_in_website>0</show_in_website>
|
53 |
<show_in_store>0</show_in_store>
|
54 |
</is_enabled>
|
55 |
</fields>
|
56 |
</general>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
<gateway>
|
58 |
<label>Gateway Connection</label>
|
59 |
<frontend_type>text</frontend_type>
|
60 |
+
<sort_order>20</sort_order>
|
61 |
<show_in_default>1</show_in_default>
|
62 |
<show_in_website>0</show_in_website>
|
63 |
<show_in_store>0</show_in_store>
|
64 |
<fields>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
<status_production translate="label">
|
66 |
<label>Status</label>
|
67 |
<frontend_type>label</frontend_type>
|
68 |
<frontend_model>neklo_monitor_adminhtml/system_config_frontend_status</frontend_model>
|
69 |
<backend_model>neklo_monitor/system_config_backend_empty</backend_model>
|
70 |
+
<sort_order>10</sort_order>
|
71 |
<show_in_default>1</show_in_default>
|
72 |
<show_in_website>0</show_in_website>
|
73 |
<show_in_store>0</show_in_store>
|
74 |
<depends>
|
75 |
<server_type>production</server_type>
|
76 |
</depends>
|
77 |
+
<comment><![CDATA[To connect to the production Gateway,<br>click the “<b>Connect to Gateway</b>” button.]]></comment>
|
78 |
</status_production>
|
79 |
+
<connect>
|
80 |
+
<frontend_model>neklo_monitor_adminhtml/system_config_frontend_button</frontend_model>
|
|
|
|
|
|
|
81 |
<sort_order>20</sort_order>
|
82 |
<show_in_default>1</show_in_default>
|
83 |
<show_in_website>0</show_in_website>
|
84 |
<show_in_store>0</show_in_store>
|
85 |
+
</connect>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
</fields>
|
87 |
</gateway>
|
88 |
+
|
89 |
+
<account translate="label">
|
90 |
+
<label>Account List</label>
|
91 |
+
<frontend_type>text</frontend_type>
|
92 |
+
<frontend_model>neklo_monitor_adminhtml/system_config_fieldset_account</frontend_model>
|
93 |
+
<sort_order>30</sort_order>
|
94 |
+
<show_in_default>1</show_in_default>
|
95 |
+
<show_in_website>0</show_in_website>
|
96 |
+
<show_in_store>0</show_in_store>
|
97 |
+
<comment><![CDATA[Fill in the information for the Magento Store Monitoring accounts allowed to access your store’s data.]]></comment>
|
98 |
+
</account>
|
99 |
+
|
100 |
<mobileapp translate="label">
|
101 |
<label>Mobile Application</label>
|
102 |
<comment><![CDATA[
|
103 |
+
<table cellspacing="0" cellpadding="0">
|
104 |
+
<tr>
|
105 |
+
<td style=""><strong>See installation FAQ</strong></td>
|
106 |
+
<td colspan="2" style="padding:0px 15px 0"><a href="http://store.neklo.com/magento-monitoring/" target="_blank">http://store.neklo.com/magento-monitoring/</a></td>
|
107 |
+
</tr>
|
108 |
+
<tr>
|
109 |
+
<td colspan="3" style="padding:20px 0;width:360px;">
|
110 |
+
To receive data from the module, you need to install a free mobile application and associate it with the module.
|
111 |
+
For detailed instructions how to do this, see Installation FAQ.
|
112 |
+
From now on you will get detailed real-time information on your store's performance, orders, customers and inventory right on the screen of your smartphone.
|
113 |
+
Enjoy.
|
114 |
+
</td>
|
115 |
+
</tr>
|
116 |
+
<tr>
|
117 |
+
<td><strong>Download from iTunes</strong></td>
|
118 |
+
<td style="padding:0 15px 50px"><img width="140" height="140" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIwAAACMCAIAAAAhotZpAAAABmJLR0QA/wD/AP+gvaeTAAADnElEQVR4nO2dzY7kMAgGN6t5/1fuvXoOaEFAkmpV3Sbjv+5PBGFj+vp8Pn/k3fx9egHyfxQJgCIB+Dn/uK5rfIKMzzvnPdtXn2eIPmM0Tqb99vemJQFQJACKBOAn+kcnfore0VVfErWp+q1M3846o/GrROvRkgAoEgBFAhD6pJNMHDDlY6J5O77kfJ7pm3lejf8iMuNoSQAUCYAiAUj5pCk67+ip/b1MDNSJkzbQkgAoEgBFAnCrT6r6hg3/FI3TWec2WhIARQKgSABSPmnqXZyJkzJ+oppf0Nln63z2qe9NSwKgSAAUCUDokzZyyU6m4pup9hv7flNoSQAUCYAiAbie2o+aOlvKtN9Yw51oSQAUCYAiARi7n9S5r7ORn131W9X13xl7aUkAFAmAIgG4OntTG/eEpp5vMJWnV43PtCQAigRAkQD8ipOmzkimfEMnprkzr6GTc2Gc9CUoEgBFAhDGSScbeXedmkOd9m+451T9XFoSAEUCoEgAUnt3d54zbcRAU3UiIjZy00+0JACKBECRALR80kaskxkns4bts6UMU/uHWhIARQKgSABS50kR2/kOmbW94TwpM36nHqCWBECRACgSgHIdh40z/I5vuDPvLsNGPT0tCYAiAVAkAK1c8A5P5SBs521HfTtttCQAigRAkQCUa7Bu3D3q9O3UWq2S+f2LTF2+qn/SkgAoEgBFApDKBT95Q/yU6XtnrnYG6zh8OYoEQJEAlPPupt77qcW9rEbqU7kPWhIARQKgSABacdLGvaXtHPQNvzWVN2icBEaRACgSgPA8aeoOaYfq+U31PGn7HGiqjZYEQJEAKBKAVi541WdUx4/anEzVTZiad2NvUEsCoEgAFAlAORf8V+eX1WjYriGUmSuatzOOlgRAkQAoEoByLngnPujkOFTHmYrVMrFghs6atSQAigRAkQCUawttxEPR+HfeT5qqA1SdN4OWBECRACgSgLHfmY3YyJ+Onk/lF2SeT41/4nkSGEUCoEgAUnl3VTrnPRt1UatnSE/lGUZoSQAUCYAiAUidJz2V2xb1nao90cmJ2LibFaElAVAkAIoEoJzjMEUnp267vmrGh3V8pHUcvhBFAqBIAB7zSVXfM3UfaKp+xJQvtI7Dl6BIABQJQPnO7AYbtVMz7aM20dqqY3bGP9GSACgSAEUCEPqkjRy8k6kznqhvtX00V+Z5FeuCfyGKBECRAFzbMZD00ZIAKBIARQLwD7iyGUSwc3hwAAAAAElFTkSuQmCC" /></td>
|
119 |
+
<td><a href="https://itunes.apple.com/us/app/magento-store-monitoring/id1108796762">https://itunes.apple.com/us/app/magento-store-monitoring/id1108796762</a></td>
|
120 |
+
</tr>
|
121 |
+
<tr>
|
122 |
+
<td><strong>Download from Google Play</strong></td>
|
123 |
+
<td style="padding:0 15px"><img width="140" height="140" style="opacity:0.10" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJEAAACRCAIAAABMus10AAAABmJLR0QA/wD/AP+gvaeTAAADHUlEQVR4nO2dy24kMQgAd1b5/1+e3DnQQTbY1aq6RdPPlJARtunPvym+3+/fD/58Psm54dfSjfJzS5SeaiP/Z24jG9EZD53x0BmPn/B3KVPIycfkPMvIyQf/Ui6w8X37rhzeyDjjoTMeOuOhMx4xBwn0jef5waVaRp6SbKy/rLDxP2mc8dAZD53x0BmPhxykj41jcqngsvFGfTWUHOOMh8546IyHzngcy0FWihcr5/bVUMYwznjojIfOeOiMx0MO0jcIl8oTGw9eeaNT5waMMx4646EzHjrjEXOQsc0dgVI9ou/XnJWCy0aMMx4646EzHjrj8blkumFsecgl77uCccZDZzx0xkNnPH7u7JdRutTKjfrKIn2/Gmc8dMZDZzx0xmNnHWRjY7G+HmWBjZnCGMYZD53x0BkPnfHYOYr2dTPtW3nRV7zIbxQova9xxkNnPHTGQ2c8Yh1kbH4hMNZJ7NSa1I37iY0zHjrjoTMeOuPxkIMETk1V3Dmts7GZiHWQl6MzHjrjoTMeD2nC2A6UO8sTp8ifyjjjoTMeOuOhMx61OkjgzgE8p28dytiuX+OMh8546IyHzngsfTd3Y/Eif4xTsx75uSv3Dbge5OXojIfOeOiMx9JcTLxW29qKsdanOZfMEBlnPHTGQ2c8dMYjjsB9CzrHWpadaqE+NjNlnPHQGQ+d8dAZj4ccpHatfVnGnfftmxIKuC/mbeiMh8546IzHUh2kdqe2L8L0rRy9pNBjr3Y8OuOhMx4647FUBxmb1yjd984so3Rl6yBvQ2c8dMZDZzyOfTf3zrLI2OLXlYc0znjojIfOeOiMx1xHj1PrWXP62qP0tao3znjojIfOeOiMx1J/kJyNo+7KuWOd08b+dcYZD53x0BkPnfGIOUjgVPuMvpUXpcfIDx7bbRwwznjojIfOeOiMx0MOcgljH5rry7k2PoZxxkNnPHTGQ2c8GDlIIB+xS3lEX/v1nFL+4ppUPDrjoTMeOuPxkIOc2jXTtze3b2/L2OySccZDZzx0xkNnPGIOgvj2baCUC4xtxi1hf5CXozMeOuOhMx6/Z8gFM4UY+noAAAAASUVORK5CYII=" /></td>
|
124 |
+
<td><i>coming soon...</i></td>
|
125 |
+
</tr>
|
126 |
</table>
|
127 |
]]></comment>
|
128 |
<frontend_type>text</frontend_type>
|
129 |
+
<sort_order>40</sort_order>
|
130 |
<show_in_default>1</show_in_default>
|
131 |
<show_in_website>0</show_in_website>
|
132 |
<show_in_store>0</show_in_store>
|
app/code/community/Neklo/Monitor/sql/neklo_monitor_setup/mysql4-upgrade-1.2.1-1.2.2.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/** @var $installer Mage_Core_Model_Resource_Setup */
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
$installer->run("");
|
7 |
+
$installer->endSetup();
|
app/code/community/Neklo/Monitor/sql/neklo_monitor_setup/mysql4-upgrade-1.2.2-1.3.0.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
$installer->run("
|
7 |
+
CREATE TABLE `{$installer->getTable('neklo_monitor/account')}` (
|
8 |
+
`entity_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
9 |
+
`phone_hash` varchar(32) NOT NULL,
|
10 |
+
`phone_mask` varchar(255) NOT NULL,
|
11 |
+
`firstname` varchar(255) DEFAULT NULL,
|
12 |
+
`lastname` varchar(255) DEFAULT NULL,
|
13 |
+
`email` varchar(255) DEFAULT NULL,
|
14 |
+
PRIMARY KEY (`entity_id`),
|
15 |
+
UNIQUE KEY `phone_hash` (`phone_hash`)
|
16 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
17 |
+
|
18 |
+
ALTER TABLE `{$installer->getTable('neklo_monitor/report')}`
|
19 |
+
ADD COLUMN `qty_new` INT(11) UNSIGNED NOT NULL AFTER `qty`;
|
20 |
+
|
21 |
+
ALTER TABLE `{$installer->getTable('neklo_monitor/log')}`
|
22 |
+
ADD COLUMN `qty_new` INT(11) UNSIGNED NOT NULL AFTER `qty`,
|
23 |
+
DROP COLUMN `type`,
|
24 |
+
DROP COLUMN `times`;
|
25 |
+
");
|
26 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/template/neklo/monitor/system/config/button/connect.phtml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php /* @var $this Neklo_Monitor_Block_Adminhtml_System_Config_Frontend_Button_Connect */ ?>
|
2 |
+
<?php echo $this->getButtonHtml(); ?>
|
3 |
+
<script type="text/javascript">
|
4 |
+
var button = $('<?php echo $this->getButton()->getId(); ?>');
|
5 |
+
if (button) {
|
6 |
+
Event.observe(button, 'click', function(e) {
|
7 |
+
Event.stop(e);
|
8 |
+
new Ajax.Request(
|
9 |
+
'<?php echo $this->getConnectUrl(); ?>',
|
10 |
+
{
|
11 |
+
method: 'POST',
|
12 |
+
onSuccess: function(transport) {
|
13 |
+
location.reload();
|
14 |
+
},
|
15 |
+
onFailure: function () {
|
16 |
+
location.reload();
|
17 |
+
}
|
18 |
+
}
|
19 |
+
);
|
20 |
+
});
|
21 |
+
}
|
22 |
+
</script>
|
app/design/adminhtml/default/default/template/neklo/monitor/system/config/button/disconnect.phtml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php /* @var $this Neklo_Monitor_Block_Adminhtml_System_Config_Frontend_Button_Disconnect */ ?>
|
2 |
+
<?php echo $this->getButtonHtml(); ?>
|
3 |
+
<script type="text/javascript">
|
4 |
+
var button = $('<?php echo $this->getButton()->getId(); ?>');
|
5 |
+
if (button) {
|
6 |
+
Event.observe(button, 'click', function(e) {
|
7 |
+
Event.stop(e);
|
8 |
+
new Ajax.Request(
|
9 |
+
'<?php echo $this->getDisconnectUrl(); ?>',
|
10 |
+
{
|
11 |
+
method: 'POST',
|
12 |
+
onSuccess: function(transport) {
|
13 |
+
location.reload();
|
14 |
+
},
|
15 |
+
onFailure: function () {
|
16 |
+
location.reload();
|
17 |
+
}
|
18 |
+
}
|
19 |
+
);
|
20 |
+
});
|
21 |
+
}
|
22 |
+
</script>
|
app/design/adminhtml/default/default/template/neklo/monitor/system/config/fieldset/account/list.phtml
ADDED
@@ -0,0 +1,268 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php /* @var $this Neklo_Monitor_Block_Adminhtml_System_Config_Fieldset_Account_List */ ?>
|
2 |
+
<?php $_htmlId = $this->getHtmlId() ? $this->getHtmlId() : '_' . uniqid(); ?>
|
3 |
+
|
4 |
+
<tr><td>
|
5 |
+
|
6 |
+
<div class="grid" id="grid<?php echo $_htmlId ?>" style="padding-left:5px;">
|
7 |
+
<table cellpadding="0" cellspacing="0" class="border">
|
8 |
+
<tbody>
|
9 |
+
<tr class="headings" id="headings<?php echo $_htmlId ?>">
|
10 |
+
<?php foreach ($this->_columns as $columnName => $column): ?>
|
11 |
+
<th style="<?php echo $column['style'] ?>"><?php echo $column['label'] ?></th>
|
12 |
+
<?php endforeach; ?>
|
13 |
+
<th><?php echo $this->__('Actions'); ?></th>
|
14 |
+
</tr>
|
15 |
+
<tr id="addRow<?php echo $_htmlId ?>">
|
16 |
+
<td colspan="<?php echo count($this->_columns) ?>" class="neklo-monitor-message-conteiner">
|
17 |
+
<span id="neklo_monitor_account_message" class="neklo-monitor-account-message" style="display:none;"></span>
|
18 |
+
</td>
|
19 |
+
<td colspan="1">
|
20 |
+
<button onclick="accountRow<?php echo $_htmlId ?>.add();" class="scalable add" type="button">
|
21 |
+
<span><span><span><?php echo $this->_addButtonLabel ?></span></span></span>
|
22 |
+
</button>
|
23 |
+
</td>
|
24 |
+
</tr>
|
25 |
+
</tbody>
|
26 |
+
</table>
|
27 |
+
</div>
|
28 |
+
|
29 |
+
<script type="text/template" id="account-template">
|
30 |
+
<tr id="#{_id}">
|
31 |
+
<?php foreach ($this->_columns as $columnName => $column):?>
|
32 |
+
<td>
|
33 |
+
<?php echo Mage::helper('core')->jsQuoteEscape($this->_renderCellTemplate($columnName)) ?>
|
34 |
+
</td>
|
35 |
+
<?php endforeach;?>
|
36 |
+
<td class="account-actions">
|
37 |
+
<button id="saveBtn#{_id}" onclick="accountRow<?php echo $_htmlId ?>.saveAccount('#{_id}')" class="scalable save action-button" type="button">
|
38 |
+
<span><span><span><?php echo Mage::helper('core')->jsQuoteEscape($this->__('Save')) ?></span></span></span>
|
39 |
+
</button>
|
40 |
+
<button id="delBtn#{_id}" onclick="accountRow<?php echo $_htmlId ?>.deleteAccount('#{_id}')" class="scalable delete action-button" type="button">
|
41 |
+
<span><span><span><?php echo Mage::helper('core')->jsQuoteEscape(Mage::helper('adminhtml')->__('Delete')) ?></span></span></span>
|
42 |
+
</button>
|
43 |
+
</td>
|
44 |
+
</tr>
|
45 |
+
</script>
|
46 |
+
|
47 |
+
<script type="text/javascript">
|
48 |
+
//<![CDATA[
|
49 |
+
var accountRow<?php echo $_htmlId ?> = {
|
50 |
+
template: new Template($('account-template').innerHTML),
|
51 |
+
|
52 |
+
add: function (templateData) {
|
53 |
+
// generate default template data
|
54 |
+
if (arguments.length == 0) {
|
55 |
+
var d = new Date();
|
56 |
+
templateData = {
|
57 |
+
<?php foreach ($this->_columns as $columnName => $column): ?>
|
58 |
+
<?php echo $columnName ?> : '',
|
59 |
+
<?php endforeach;?>
|
60 |
+
_id : 'new_' + d.getTime() + '_' + d.getMilliseconds()
|
61 |
+
};
|
62 |
+
}
|
63 |
+
|
64 |
+
Element.insert($('addRow<?php echo $_htmlId ?>'), {before: this.template.evaluate(templateData)});
|
65 |
+
|
66 |
+
if (arguments.length) {
|
67 |
+
this._disableRow(templateData._id);
|
68 |
+
this._hideSaveButton(templateData._id);
|
69 |
+
}
|
70 |
+
},
|
71 |
+
|
72 |
+
deleteAccount: function (rowId) {
|
73 |
+
if (!this._isNew(rowId)) {
|
74 |
+
this._deleteAccount(rowId);
|
75 |
+
} else {
|
76 |
+
$(rowId).remove();
|
77 |
+
}
|
78 |
+
},
|
79 |
+
|
80 |
+
_isNew: function(rowId) {
|
81 |
+
return rowId.indexOf('new_') >= 0;
|
82 |
+
},
|
83 |
+
|
84 |
+
_deleteAccount: function(rowId) {
|
85 |
+
var me = this;
|
86 |
+
new Ajax.Request(
|
87 |
+
'<?php echo $this->getRemoveUrl(); ?>',
|
88 |
+
{
|
89 |
+
parameters: {
|
90 |
+
'entity_id': rowId
|
91 |
+
},
|
92 |
+
method: 'POST',
|
93 |
+
onCreate: function() {
|
94 |
+
me.hideMessage();
|
95 |
+
},
|
96 |
+
onSuccess: function (transport) {
|
97 |
+
try {
|
98 |
+
eval("var json = " + transport.responseText);
|
99 |
+
} catch(e) {
|
100 |
+
location.reload();
|
101 |
+
}
|
102 |
+
|
103 |
+
if (!json.success) {
|
104 |
+
if (json.messages && json.messages.length) {
|
105 |
+
me.showError(json.messages.first());
|
106 |
+
}
|
107 |
+
} else {
|
108 |
+
if (json.messages && json.messages.length) {
|
109 |
+
me.showSuccess(json.messages.first());
|
110 |
+
}
|
111 |
+
$(rowId).remove();
|
112 |
+
}
|
113 |
+
},
|
114 |
+
onFailure: function (transport) {
|
115 |
+
try {
|
116 |
+
eval("var json = " + transport.responseText);
|
117 |
+
} catch(e) {
|
118 |
+
location.reload();
|
119 |
+
}
|
120 |
+
|
121 |
+
if (json.messages && json.messages.length) {
|
122 |
+
me.showSuccess(json.messages.first());
|
123 |
+
}
|
124 |
+
}
|
125 |
+
}
|
126 |
+
);
|
127 |
+
},
|
128 |
+
|
129 |
+
saveAccount: function (rowId) {
|
130 |
+
var elements = $(rowId).select('input');
|
131 |
+
|
132 |
+
var isValid = true;
|
133 |
+
elements.each(function (element) {
|
134 |
+
isValid = Validation.validate(element) && isValid;
|
135 |
+
});
|
136 |
+
|
137 |
+
if (isValid) {
|
138 |
+
var data = {};
|
139 |
+
elements.each(function (element) {
|
140 |
+
var inputName = element.readAttribute('name');
|
141 |
+
inputName = inputName
|
142 |
+
.replace('[' + rowId + ']', '')
|
143 |
+
.replace('[', '')
|
144 |
+
.replace(']', '')
|
145 |
+
;
|
146 |
+
data[inputName] = element.getValue();
|
147 |
+
});
|
148 |
+
|
149 |
+
this._saveAccount(rowId, data);
|
150 |
+
}
|
151 |
+
},
|
152 |
+
|
153 |
+
_saveAccount: function (rowId, data) {
|
154 |
+
var me = this;
|
155 |
+
new Ajax.Request(
|
156 |
+
'<?php echo $this->getSaveUrl(); ?>',
|
157 |
+
{
|
158 |
+
parameters: data,
|
159 |
+
method: 'POST',
|
160 |
+
onCreate: function() {
|
161 |
+
me.hideMessage();
|
162 |
+
},
|
163 |
+
onSuccess: function (transport) {
|
164 |
+
try {
|
165 |
+
eval("var json = " + transport.responseText);
|
166 |
+
} catch(e) {
|
167 |
+
location.reload();
|
168 |
+
}
|
169 |
+
|
170 |
+
if (!json.success) {
|
171 |
+
if (json.messages && json.messages.length) {
|
172 |
+
me.showError(json.messages.first());
|
173 |
+
}
|
174 |
+
} else {
|
175 |
+
if (json.messages && json.messages.length) {
|
176 |
+
me.showSuccess(json.messages.first());
|
177 |
+
}
|
178 |
+
|
179 |
+
data.phone_mask = json.account.phone_mask;
|
180 |
+
|
181 |
+
me._disableRow(rowId);
|
182 |
+
me._hideSaveButton(rowId);
|
183 |
+
me._updateDeleteButton(rowId, json.account.id, data);
|
184 |
+
}
|
185 |
+
},
|
186 |
+
onFailure: function (transport) {
|
187 |
+
try {
|
188 |
+
eval("var json = " + transport.responseText);
|
189 |
+
} catch(e) {
|
190 |
+
location.reload();
|
191 |
+
}
|
192 |
+
|
193 |
+
if (json.messages && json.messages.length) {
|
194 |
+
me.showSuccess(json.messages.first());
|
195 |
+
}
|
196 |
+
}
|
197 |
+
}
|
198 |
+
);
|
199 |
+
},
|
200 |
+
|
201 |
+
_disableRow: function (rowId) {
|
202 |
+
var elements = $(rowId).select('input');
|
203 |
+
elements.invoke('disable');
|
204 |
+
elements.invoke('addClassName', 'input-disabled');
|
205 |
+
},
|
206 |
+
|
207 |
+
_hideSaveButton: function(rowId) {
|
208 |
+
var saveButton = $('saveBtn' + rowId);
|
209 |
+
if (saveButton) {
|
210 |
+
saveButton.hide();
|
211 |
+
}
|
212 |
+
},
|
213 |
+
|
214 |
+
_updateDeleteButton: function(oldId, newId, data) {
|
215 |
+
var row = $(oldId);
|
216 |
+
if (row) {
|
217 |
+
var updatedRowHtml = row.outerHTML.replace(new RegExp(oldId, 'g'), newId);
|
218 |
+
row.outerHTML = updatedRowHtml;
|
219 |
+
$H(data).each(function(dataItem) {
|
220 |
+
var dataInput = $$('input[name="[' + newId + '][' + dataItem.key + ']"]').first();
|
221 |
+
if (dataInput) {
|
222 |
+
dataInput.setValue(dataItem.value);
|
223 |
+
}
|
224 |
+
});
|
225 |
+
}
|
226 |
+
},
|
227 |
+
|
228 |
+
showSuccess: function(message) {
|
229 |
+
this._showMessage(message, 'success', 'error');
|
230 |
+
},
|
231 |
+
|
232 |
+
showError: function(message) {
|
233 |
+
this._showMessage(message, 'error', 'success');
|
234 |
+
},
|
235 |
+
|
236 |
+
hideMessage: function() {
|
237 |
+
var messageContainer = $('neklo_monitor_account_message');
|
238 |
+
if (messageContainer) {
|
239 |
+
messageContainer.update('');
|
240 |
+
messageContainer.hide();
|
241 |
+
}
|
242 |
+
},
|
243 |
+
|
244 |
+
_showMessage: function(message, addClassName, removeClassName) {
|
245 |
+
var messageContainer = $('neklo_monitor_account_message');
|
246 |
+
if (messageContainer) {
|
247 |
+
messageContainer.update(message);
|
248 |
+
messageContainer.removeClassName(removeClassName);
|
249 |
+
messageContainer.addClassName(addClassName);
|
250 |
+
messageContainer.show();
|
251 |
+
}
|
252 |
+
}
|
253 |
+
};
|
254 |
+
|
255 |
+
// add existing rows
|
256 |
+
<?php foreach ($this->getAccountRows() as $accountId => $account): ?>
|
257 |
+
accountRow<?php echo $_htmlId; ?>.add(<?php echo $account->toJson(); ?>);
|
258 |
+
<?php endforeach; ?>
|
259 |
+
|
260 |
+
// Validation
|
261 |
+
Validation.add('validate-neklo-monitor-phone', 'Requires E.164 number formatting for phone number.', function(v) {
|
262 |
+
return Validation.get('IsEmpty').test(v) || /^\+[1-9]\d{1,14}$/.test(v);
|
263 |
+
});
|
264 |
+
|
265 |
+
//]]>
|
266 |
+
</script>
|
267 |
+
|
268 |
+
</td></tr>
|
package.xml
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
-
<package><name>Neklo_Monitor</name><version>1.2.2</version><stability>stable</stability><license>License</license><channel>community</channel><extends></extends><summary>Minor Upgrade</summary><description>Connector for Magento Monitor Application</description><notes></notes><authors><author><name>NEKLO</name><user>NEKLO</user><email>info@neklo.com</email></author></authors><date>2016-06-16</date><time>2:22:58</time><compatible></compatible><dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies><contents><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Neklo_Core.xml" hash="335032ff690c5272626dca9106642680"/><file name="Neklo_Monitor.xml" hash="e93ded9f7368552a843959e953a2bf10"/></dir></dir><dir name="code"><dir name="community"><dir name="Neklo"><dir name="Monitor"><file name="Autoload.php" hash="612c4e0d0a4db5be84c29650655085f6"/><dir name="etc"><file name="adminhtml.xml" hash="897debfe836ca9d58971b44b2232187e"/><file name="config.xml" hash="6cb4b4cf2531790a4fd8da0b6fe281fa"/><file name="system.xml" hash="c99ed6a7ac945fab0fb803d7ac5b820b"/></dir><dir name="controllers"><file name="AuthController.php" hash="2d6dafc8d914558a35a538eae5c87090"/><file name="CustomerController.php" hash="c3da1ec819d0da56c76ad28960979083"/><file name="DashboardController.php" hash="767a8b778586e2d4069f1db2730d33ea"/><file name="InfoController.php" hash="3e58cb421d2d68dabf79dc4d477f12e4"/><file name="OrderController.php" hash="9383692d3ce5b22d22afee32ddfae10b"/><file name="ProductController.php" hash="95ab32749b2eb4ab21cc79a0ba0f9edc"/><dir name="State"><file name="CacheController.php" hash="efb77eeae42be795d7618c620270d0d7"/><file name="IndexerController.php" hash="fa23622aabd0f1d40d4d03de692ae0a2"/></dir><dir name="Var"><file name="LogController.php" hash="b0c9fb0510dd81d3de890d1050d8ac18"/><file name="ReportController.php" hash="5e871965109e78c57252fd221c8e3a9b"/></dir><dir name="Report"><file name="SalesController.php" hash="700675ceeb05054ff3be6155d37cd37c"/></dir></dir><dir name="Controller"><file name="Abstract.php" hash="af6434938fe89b1b375e279449cc219b"/></dir><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Frontend"><file name="Label.php" hash="bd831c28818a1b998dda55df056b28b4"/><file name="Status.php" hash="6c00cedcb46f4886476f2fda6757e692"/></dir></dir></dir></dir></dir><dir name="sql"><dir name="neklo_monitor_setup"><file name="mysql4-install-1.0.0.php" hash="3a5ee59cda3ec27eca737f515eec4a71"/><file name="mysql4-upgrade-1.0.0-1.1.0.php" hash="bba6559d5040c937d775a76df6611b77"/><file name="mysql4-upgrade-1.1.0-1.1.1.php" hash="f3bbc768ae43e1b45009de02c519dcd7"/><file name="mysql4-upgrade-1.1.1-1.1.2.php" hash="0a03caae9eb41f5f8bcf1a2a8476a13a"/><file name="mysql4-upgrade-1.1.2-1.1.3.php" hash="27ea9bdb83ecf08c68a1c9ccc8cb4dac"/><file name="mysql4-upgrade-1.1.3-1.2.0.php" hash="df93eef9daca7e21724f9c045d3852c0"/><file name="mysql4-upgrade-1.2.0-1.2.1.php" hash="ac36e19a977757ee9dc9f31ea5cef017"/></dir></dir><dir name="Model"><file name="Linfo.php" hash="77af1f86a0379d4d6ed86db3f770f2c8"/><file name="Minfo.php" hash="42fae9b23cb42f843e8cfecab4904be6"/><file name="Observer.php" hash="f15fbce459d0986c2eb82e44fbb4c798"/><dir name="System"><dir name="Config"><dir name="Source"><dir name="Server"><file name="Type.php" hash="0886c1a5bbf98e3d2cc5c0e3ea39b7e1"/></dir></dir><dir name="Backend"><file name="Empty.php" hash="556343bcf15ea8b294a15e77f6662cf8"/><file name="Token.php" hash="7669597367cd26bd848d0d8251feb4b7"/></dir></dir></dir><dir name="Cron"><file name="Abstract.php" hash="7183a30f5a456ee29a3e58f814999e87"/><file name="Server.php" hash="b2d82dedce8d53e8145335b417295696"/><file name="Store.php" hash="ad2f68426668cb34f59d383242de886a"/></dir><dir name="Resource"><file name="Changelog.php" hash="1a97f31fe6c54c26ad319d2dccab0f39"/><dir name="Minfo"><file name="Daily.php" hash="b73a98f954e4b0dfa1950dae98ef0af7"/><file name="Log.php" hash="54f05d3ced0a1aee770177265695eac9"/><file name="Report.php" hash="acb9c02688a9403a67904fda72c57533"/><dir name="Log"><file name="Collection.php" hash="fc6cbcd4c15227046cb7e85dfdad614d"/></dir><dir name="Daily"><file name="ReportsOrderCollection.php" hash="0f6155f7d0a1f6de0f6d1a326dd05ba8"/></dir><dir name="Report"><file name="Collection.php" hash="a9c74ab52be17dec7c4fafb883bda732"/></dir></dir><dir name="Gateway"><file name="Queue.php" hash="eb77ef4c7d62a4190a83538f7305916f"/><dir name="Queue"><file name="Collection.php" hash="bd857fa79a53887c3eedc27a94ecd0a7"/></dir></dir></dir><dir name="Minfo"><file name="Log.php" hash="d787eeaab4cae6f3d9fe7e696c427014"/><file name="Parser.php" hash="8d13a7d90fbd381f84299a674f556239"/><file name="Report.php" hash="d97960716a8c152d1614b8d0c752e064"/></dir><dir name="Linfo"><dir name="Os"><file name="Linux.php" hash="e61e9aceb9723b5c8e72200274b7f6ab"/></dir></dir><dir name="Gateway"><file name="Connector.php" hash="28cd6a63283f09ca51e7279f6f5bbb05"/><file name="Queue.php" hash="2d4178daa3efbfe728f96276ee99d34b"/></dir></dir><dir name="Helper"><file name="Config.php" hash="fd5b03012aa7b479a3af4f1b84b31200"/><file name="Country.php" hash="15176ed5b48639f8c50242b126e9dea4"/><file name="Data.php" hash="a5a4c393c5c87b3e9c71d05e0ae755f5"/><file name="Date.php" hash="0aa9fb8caa33c51ba224bd1336724704"/><file name="Flat.php" hash="2b62a8f954c82c8d4ad8a11acc5283c8"/><file name="Request.php" hash="b1476a2c1b3d3030fbd30eb296f18f0b"/><dir name="Request"><file name="Validator.php" hash="16375fad2da02f6732fefd465a388774"/></dir></dir></dir><dir name="Core"><dir name="etc"><file name="adminhtml.xml" hash="68b00ad4118462d74b0c0a7126063462"/><file name="config.xml" hash="dba97e16300307cae724d784309ec72d"/><file name="system.xml" hash="f9ee62f79b22584cc6180ec5e8049539"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Neklo"><dir name="Core"><file name="ContactController.php" hash="fe735a9c3c0ad9c4ecb88edd009059a9"/><file name="NewsletterController.php" hash="b9342c80bf94c29a463251b1c7b02705"/></dir></dir></dir></dir><dir name="Block"><dir name="System"><file name="Contact.php" hash="a0e89ca48de64bb8526c35598f99802b"/><file name="Extension.php" hash="8cd6609bd4f00bf8a8f5913d20e98e65"/><dir name="Contact"><file name="Header.php" hash="a6c4f8dbf002a0d2f6be0ea37445a562"/><file name="Send.php" hash="333d3059033faa826ef3781946676b16"/><dir name="Send"><file name="Button.php" hash="c94e2ae59246a968d7eb2e89e63485c8"/></dir></dir><dir name="Newsletter"><file name="Subscribe.php" hash="1015b8e49758e40c829667e94bb06220"/><dir name="Subscribe"><file name="Button.php" hash="98162d3c3280bdc3da75c90c45fc9500"/></dir></dir><dir name="Extension"><file name="List.php" hash="0006ff459c6b19de9349fa31c8be6b2b"/></dir></dir></dir><dir name="Model"><file name="Feed.php" hash="b5e0d2343b2c9db1f4d86ca0e8b3a922"/><file name="Observer.php" hash="dfc8c917e3f3882d1d99c734831c6e0b"/><dir name="Source"><file name="Reason.php" hash="02eb3c4cfe3433e5a8194862aef636c4"/><dir name="Subscription"><file name="Type.php" hash="616c3f7e7e4ebe3e42e16d54d159d378"/></dir></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="Empty.php" hash="2af2d53c7c56b9ea4a148a2862da224b"/></dir></dir></dir><dir name="Feed"><file name="Extension.php" hash="1ff201b02db7827df350b11c19902fa2"/></dir></dir><dir name="Helper"><file name="Config.php" hash="42eff18ca97b961e1186a790abcb8690"/><file name="Data.php" hash="5492cb13c72b737d85e9009f0f623336"/><file name="Extension.php" hash="c0c987bd848e5270ec31544460438eab"/></dir></dir></dir></dir></dir><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="neklo"><file name="core.xml" hash="8851b2c111c8e0745fb78af2bb57e6a6"/></dir></dir><dir name="template"><dir name="neklo"><dir name="core"><dir name="system"><dir name="contact"><file name="button.phtml" hash="f7b5f21ddb974aa32c888c29f3057d18"/><file name="header.phtml" hash="3c0a401955a9b2bac799aa65b5bf7a81"/></dir><dir name="extension"><file name="list.phtml" hash="29378800cc0a7488badb2698a02220d7"/></dir><dir name="subscribe"><file name="button.phtml" hash="865b84befba4d00e6a1e4de2b989776e"/></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="locale"><dir name="en_US"><file name="Neklo_Core.csv" hash="c6abfbb8be878de9c02339e2ecfc4e16"/></dir></dir></dir><dir name="skin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="neklo"><dir name="core"><dir name="images"><file name="ok.gif" hash="a38bc2ee6e116e39c6e2e3013ee50f5e"/><file name="update.gif" hash="8342e11f7739fcfa25134707f0536ed6"/></dir><dir name="css"><file name="style.css" hash="77e35507d6f2e748afc08f11f322120d"/></dir></dir><dir name="monitor"><dir name="css"><file name="styles.css" hash="ab8dc36c3c18794064b0ea8b8c8334fb"/></dir></dir></dir></dir></dir></dir></dir><dir name="lib"><dir name="Linfo"><file name="Common.php" hash="3d55bb51d9de7438c044a012ae50175b"/><file name="Linfo.php" hash="d26c95e093e3c4d5eb456c6c5dfa1579"/><dir name="Output"><file name="Html.php" hash="5ec70c500dda56a561d188dd6e908e49"/><file name="Json.php" hash="4616bcc1ddd3eaa312ef2235e7da1586"/><file name="Ncurses.php" hash="60dbe6e0b2eb00dedccc972271a712fa"/><file name="Output.php" hash="34ef640283d567d93300a2b9c107d276"/><file name="Serialized.php" hash="aa749737127da4bb25c941557d1cfb81"/><file name="Xml.php" hash="7fb392ee95df014c30dd52130e9db45c"/></dir><dir name="Exceptions"><file name="FatalException.php" hash="ac7ae108aa403bc300ba9086410cf0a9"/></dir><dir name="Extension"><file name="Apcaccess.php" hash="8e274bd0036006e064c0cd85fbd732a9"/><file name="Cups.php" hash="25bb7dfe794d5ff211c9862615e2192b"/><file name="Dhcpd3_leases.php" hash="40ffcf2c2ec8618ff8155d197c15bbf1"/><file name="Dnsmasq_dhcpd.php" hash="bc751a49a09f06d8e4492f7ddf432cea"/><file name="Extension.php" hash="d09316ce5276805b702fdc1115b4adc3"/><file name="Ipmi.php" hash="5536abf11a4f06e0b91852f5e17b77bc"/><file name="Libvirt.php" hash="889dcd93239aecb42d6f80b2618e87b1"/><file name="Smb.php" hash="d6d4e995bf54fbdfeec0a51f70faec37"/><file name="Soldat.php" hash="bce89097e6540818f153b2df5b71b0b5"/><file name="Transmission.php" hash="e438b16dc2040d8676c7ba2c1448b6ef"/><file name="Truecrypt.php" hash="f4838a69d9eda202a5d64e8bb8ced36c"/><file name="Utorrent.php" hash="14119c01579d58a01f6489a0865855f7"/></dir><dir name="Lang"><file name="de.php" hash="e313cc8346be39d62607278bd986af23"/><file name="en.php" hash="8ee1b778ed29c64e02e3e1f118016f82"/><file name="fi.php" hash="10d10cd954719a7cee69d5bfbf67889c"/><file name="fr.php" hash="6edcf8ee5251dee98ee39f84fdd52647"/><file name="it.php" hash="d65c5225fa3ef16fd2966137c18e83f4"/><file name="pl.php" hash="2d9b92e225acf0461540d1224a0141f5"/><file name="pt.php" hash="9dd24ee347278edc24f589f6e3f12c58"/><file name="zh.php" hash="2f9ae1cfcf4e5a80127200bf9c9d0b8b"/></dir><dir name="OS"><file name="BSDcommon.php" hash="3b6c83b58e56e0a0eac250f70451be5a"/><file name="Darwin.php" hash="fc45b3648d75c96596d8c7a8559d2d74"/><file name="DragonFly.php" hash="c5ffffe8e6899a0f8352c1fd0f763135"/><file name="FreeBSD.php" hash="f07d480ebda610153b5f6d42d0143f37"/><file name="Linux.php" hash="5e36caf50252aa24fab289ae4239a591"/><file name="Minix.php" hash="22c19a5e45c4715cfcb0db1f42fd5793"/><file name="NetBSD.php" hash="f576ac8083757848bbd179420c182aeb"/><file name="OS.php" hash="49f2a6e9b1e3e56815896f0364049bef"/><file name="OpenBSD.php" hash="cd6b1bd659a30465903ebc913382b223"/><file name="SunOS.php" hash="2cfa3e63e51ca1d8928f2f521be26b3d"/><file name="Unixcommon.php" hash="9981cca8d8805302983ebe20dc2ef04d"/><file name="Windows.php" hash="f73cd25acaf3774da31b922ab3287038"/></dir><dir name="Meta"><file name="Errors.php" hash="e614a650fd523918b010b4297c4c2acd"/><file name="Timer.php" hash="ea244a5a388fa8cc470799cbdd96b866"/></dir><dir name="Parsers"><file name="CallExt.php" hash="6a671a39e8debf7e4c950491f45d8ee4"/><file name="Hddtemp.php" hash="3d0007ab7349702042a88f1e9ca23649"/><file name="Hwpci.php" hash="e26d72856736d83470e82916ba78a3ca"/><file name="Mbmon.php" hash="aa3782625c7542059838e475ccb13326"/><file name="Sensord.php" hash="2be994a2c77ba0a35398a6fc96a4c77a"/></dir></dir></dir></target></contents></package>
|
1 |
<?xml version="1.0"?>
|
2 |
+
<package><name>Neklo_Monitor</name><version>1.3.0</version><stability>stable</stability><license>License</license><channel>community</channel><extends></extends><summary>Minor autentication updates</summary><description>Connector for Magento Monitor Application</description><notes>Minor autentication updates</notes><authors><author><name>NEKLO</name><user>NEKLO</user><email>info@neklo.com</email></author></authors><date>2016-10-21</date><time>14:05:20</time><compatible></compatible><dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies><contents><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Neklo_Core.xml" hash="335032ff690c5272626dca9106642680"/><file name="Neklo_Monitor.xml" hash="e93ded9f7368552a843959e953a2bf10"/></dir></dir><dir name="code"><dir name="community"><dir name="Neklo"><dir name="Monitor"><file name="Autoload.php" hash="612c4e0d0a4db5be84c29650655085f6"/><dir name="etc"><file name="adminhtml.xml" hash="897debfe836ca9d58971b44b2232187e"/><file name="config.xml" hash="878363d3011df20afe0882891223844b"/><file name="system.xml" hash="fc590b7341115681f5854164b27e88a2"/></dir><dir name="controllers"><file name="AuthController.php" hash="2d6dafc8d914558a35a538eae5c87090"/><file name="CustomerController.php" hash="798234e7391b8389df96cd1bb4ed1f10"/><file name="DashboardController.php" hash="767a8b778586e2d4069f1db2730d33ea"/><file name="InfoController.php" hash="3e58cb421d2d68dabf79dc4d477f12e4"/><file name="OrderController.php" hash="8b5cab3d0ccac822dcf59b5b973b5335"/><file name="ProductController.php" hash="763b8d16c50d6b4beb2122b046b22f81"/><dir name="State"><file name="CacheController.php" hash="efb77eeae42be795d7618c620270d0d7"/><file name="IndexerController.php" hash="fa23622aabd0f1d40d4d03de692ae0a2"/></dir><dir name="Var"><file name="LogController.php" hash="70de4f1b2aa6c0e0bd0a33f255b1a70e"/><file name="ReportController.php" hash="7c3228d3f8f9b607c8a20d4db58b4127"/></dir><dir name="Report"><file name="SalesController.php" hash="700675ceeb05054ff3be6155d37cd37c"/></dir><dir name="Adminhtml"><dir name="Neklo"><dir name="Monitor"><file name="GatewayController.php" hash="d5977923f94c772619c85a4597eb64a7"/><dir name="Gateway"><file name="AccountController.php" hash="4da0d663f61ab28e87d411da6b0fb97f"/></dir></dir></dir></dir></dir><dir name="Controller"><file name="Abstract.php" hash="d33a8adba985be7e4c29643d147b5ab0"/><dir name="Adminhtml"><file name="Abstract.php" hash="9410b0833b644e43c316fb78cf708352"/></dir></dir><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Account.php" hash="c2b613584d80118d3a50ededb300f9ab"/><dir name="Account"><file name="List.php" hash="341db40e49de3068335b9ff23db867e9"/></dir></dir><dir name="Frontend"><file name="Button.php" hash="82e403960e10158405b82d27b87e842d"/><file name="Label.php" hash="bd831c28818a1b998dda55df056b28b4"/><file name="Status.php" hash="d3a6937c46266c92fb3e56f516658674"/><dir name="Button"><file name="Connect.php" hash="f431ba0939976ee2b9bf0482f1ef602a"/><file name="Disconnect.php" hash="e9fb542961bc987db0b37daed161a8b9"/></dir><dir name="Version"><file name="Current.php" hash="2e4a33ab959b3eac67c1be597915c3fe"/><file name="Last.php" hash="dca8c22ba2d3c56ebd1efd3d77a5e6d7"/></dir></dir></dir></dir></dir></dir><dir name="sql"><dir name="neklo_monitor_setup"><file name="mysql4-install-1.0.0.php" hash="3a5ee59cda3ec27eca737f515eec4a71"/><file name="mysql4-upgrade-1.0.0-1.1.0.php" hash="bba6559d5040c937d775a76df6611b77"/><file name="mysql4-upgrade-1.1.0-1.1.1.php" hash="f3bbc768ae43e1b45009de02c519dcd7"/><file name="mysql4-upgrade-1.1.1-1.1.2.php" hash="0a03caae9eb41f5f8bcf1a2a8476a13a"/><file name="mysql4-upgrade-1.1.2-1.1.3.php" hash="27ea9bdb83ecf08c68a1c9ccc8cb4dac"/><file name="mysql4-upgrade-1.1.3-1.2.0.php" hash="df93eef9daca7e21724f9c045d3852c0"/><file name="mysql4-upgrade-1.2.0-1.2.1.php" hash="ac36e19a977757ee9dc9f31ea5cef017"/><file name="mysql4-upgrade-1.2.1-1.2.2.php" hash="29bfda967402c00336fa82da2023c394"/><file name="mysql4-upgrade-1.2.2-1.3.0.php" hash="eb240bed92e7c7eb6fa886a7cd39ba96"/></dir></dir><dir name="Model"><file name="Account.php" hash="7763d51e51c6d2806ebf1e5ca8b1b100"/><file name="Cron.php" hash="8bc724dbafb6559f5f21b3db48afac46"/><file name="Linfo.php" hash="77af1f86a0379d4d6ed86db3f770f2c8"/><file name="Log.php" hash="6a5bbe530c85f06e314cc5e00d6052bc"/><file name="Minfo.php" hash="e25fae2ac44b659b8887462defba37e0"/><file name="Observer.php" hash="feb98c4f1c6339915744117a9e39e583"/><file name="Report.php" hash="0669543723ff931d6f39420e45a4f2a4"/><dir name="Source"><dir name="System"><dir name="Config"><dir name="Server"><file name="Type.php" hash="f1b060848b920bf5de24a46c0dc71667"/></dir></dir></dir><dir name="Gateway"><dir name="Queue"><file name="Type.php" hash="c0748bfdd4410b54c511a7800537552d"/></dir></dir></dir><dir name="Log"><dir name="Writer"><file name="Stream.php" hash="bb32ba444e49d8dd2b9ea52d774d27eb"/></dir></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="Empty.php" hash="556343bcf15ea8b294a15e77f6662cf8"/></dir></dir></dir><dir name="Cron"><file name="Abstract.php" hash="508681c1b13da56bcb0363e259b061f1"/><file name="Queue.php" hash="ab36c99e0281ca14e41ed4124b8f193a"/><file name="Statistic.php" hash="f4153fe9169b29331552df6a306e6167"/><file name="Var.php" hash="db36797bcbb9a574885b27daf83ceafe"/><dir name="Statistic"><file name="Server.php" hash="ce8a8a8cee40fffb0f01f5aced28503d"/><file name="Store.php" hash="56ad04b0c6213947655ac3351455c768"/></dir></dir><dir name="Resource"><file name="Account.php" hash="7f1a9970b32ff48a1c561f9a7b992f8b"/><file name="Changelog.php" hash="d8dac75d58b85197d3760c16687443f8"/><file name="Log.php" hash="4c885431ab6f1b4834b519878124211e"/><file name="Report.php" hash="4d25e418deac888299b8fbfb242001d8"/><dir name="Log"><file name="Collection.php" hash="5290fa4365904b7f1a3a11c7a63207e2"/></dir><dir name="Account"><file name="Collection.php" hash="946e6fcc94abe9b22ebdb7c73868dd17"/></dir><dir name="Report"><file name="Collection.php" hash="eb070acac562780d067864efd011fe61"/></dir><dir name="Minfo"><file name="Daily.php" hash="29cf48f6a555630474287d561d9ec382"/><dir name="Daily"><file name="ReportsOrderCollection.php" hash="3375349a7f897ad0b83b0e81c7a990ee"/></dir></dir><dir name="Gateway"><file name="Queue.php" hash="5f5c1675c73fc1b5ce40e9cfbea9542a"/><dir name="Queue"><file name="Collection.php" hash="bd857fa79a53887c3eedc27a94ecd0a7"/></dir></dir></dir><dir name="Minfo"><file name="Parser.php" hash="f2e98ace81b2b47a16a86ba64f029942"/></dir><dir name="Linfo"><dir name="Os"><file name="Linux.php" hash="e61e9aceb9723b5c8e72200274b7f6ab"/></dir></dir><dir name="Gateway"><file name="Connector.php" hash="42093f66de16107e5400bace8ec816e4"/><file name="Queue.php" hash="8594ed67522ac6274f777d15baae02be"/></dir></dir><dir name="Helper"><file name="Config.php" hash="6b53a2643c26ea551208c6ba7a67d639"/><file name="Country.php" hash="15176ed5b48639f8c50242b126e9dea4"/><file name="Data.php" hash="a5a4c393c5c87b3e9c71d05e0ae755f5"/><file name="Date.php" hash="0aa9fb8caa33c51ba224bd1336724704"/><file name="Feed.php" hash="d16597a80673f3c83e62655cf6c172a4"/><file name="Flat.php" hash="2b62a8f954c82c8d4ad8a11acc5283c8"/><file name="Header.php" hash="f2b4cdde3184dd179cd6ecdd0b3d884e"/><file name="Product.php" hash="9996bba95c0849923f5d83355e0d9d36"/><file name="Request.php" hash="e59baa31e9f2878482932f6bfa156ac0"/><dir name="Request"><file name="Validator.php" hash="16375fad2da02f6732fefd465a388774"/></dir><dir name="Var"><file name="Report.php" hash="4d9f9dfe7b61785c864c16af46d0c4f3"/></dir></dir></dir><dir name="Core"><dir name="etc"><file name="adminhtml.xml" hash="68b00ad4118462d74b0c0a7126063462"/><file name="config.xml" hash="dba97e16300307cae724d784309ec72d"/><file name="system.xml" hash="f9ee62f79b22584cc6180ec5e8049539"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Neklo"><dir name="Core"><file name="ContactController.php" hash="fe735a9c3c0ad9c4ecb88edd009059a9"/><file name="NewsletterController.php" hash="b9342c80bf94c29a463251b1c7b02705"/></dir></dir></dir></dir><dir name="Block"><dir name="System"><file name="Contact.php" hash="a0e89ca48de64bb8526c35598f99802b"/><file name="Extension.php" hash="8cd6609bd4f00bf8a8f5913d20e98e65"/><dir name="Contact"><file name="Header.php" hash="a6c4f8dbf002a0d2f6be0ea37445a562"/><file name="Send.php" hash="333d3059033faa826ef3781946676b16"/><dir name="Send"><file name="Button.php" hash="c94e2ae59246a968d7eb2e89e63485c8"/></dir></dir><dir name="Newsletter"><file name="Subscribe.php" hash="1015b8e49758e40c829667e94bb06220"/><dir name="Subscribe"><file name="Button.php" hash="98162d3c3280bdc3da75c90c45fc9500"/></dir></dir><dir name="Extension"><file name="List.php" hash="0006ff459c6b19de9349fa31c8be6b2b"/></dir></dir></dir><dir name="Model"><file name="Feed.php" hash="b5e0d2343b2c9db1f4d86ca0e8b3a922"/><file name="Observer.php" hash="dfc8c917e3f3882d1d99c734831c6e0b"/><dir name="Source"><file name="Reason.php" hash="02eb3c4cfe3433e5a8194862aef636c4"/><dir name="Subscription"><file name="Type.php" hash="616c3f7e7e4ebe3e42e16d54d159d378"/></dir></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="Empty.php" hash="2af2d53c7c56b9ea4a148a2862da224b"/></dir></dir></dir><dir name="Feed"><file name="Extension.php" hash="1ff201b02db7827df350b11c19902fa2"/></dir></dir><dir name="Helper"><file name="Config.php" hash="42eff18ca97b961e1186a790abcb8690"/><file name="Data.php" hash="5492cb13c72b737d85e9009f0f623336"/><file name="Extension.php" hash="c0c987bd848e5270ec31544460438eab"/></dir></dir></dir></dir></dir><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="neklo"><file name="core.xml" hash="8851b2c111c8e0745fb78af2bb57e6a6"/></dir></dir><dir name="template"><dir name="neklo"><dir name="core"><dir name="system"><dir name="contact"><file name="button.phtml" hash="f7b5f21ddb974aa32c888c29f3057d18"/><file name="header.phtml" hash="3c0a401955a9b2bac799aa65b5bf7a81"/></dir><dir name="extension"><file name="list.phtml" hash="29378800cc0a7488badb2698a02220d7"/></dir><dir name="subscribe"><file name="button.phtml" hash="865b84befba4d00e6a1e4de2b989776e"/></dir></dir></dir><dir name="monitor"><dir name="system"><dir name="config"><dir name="fieldset"><dir name="account"><file name="list.phtml" hash="525f6dc53db85b10a08e5f6e5f72c1d2"/></dir></dir><dir name="button"><file name="connect.phtml" hash="a7d0b4b1b4cde53980218474a47e20f3"/><file name="disconnect.phtml" hash="eb8e7fd2b95eb717e83caced03255468"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="locale"><dir name="en_US"><file name="Neklo_Core.csv" hash="c6abfbb8be878de9c02339e2ecfc4e16"/></dir></dir></dir><dir name="skin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="neklo"><dir name="core"><dir name="images"><file name="ok.gif" hash="a38bc2ee6e116e39c6e2e3013ee50f5e"/><file name="update.gif" hash="8342e11f7739fcfa25134707f0536ed6"/></dir><dir name="css"><file name="style.css" hash="77e35507d6f2e748afc08f11f322120d"/></dir></dir><dir name="monitor"><dir name="css"><file name="styles.css" hash="8ee4eae666b3a2ba5beb6aa940264171"/></dir></dir></dir></dir></dir></dir></dir><dir name="lib"><dir name="Linfo"><file name="Common.php" hash="3d55bb51d9de7438c044a012ae50175b"/><file name="Linfo.php" hash="d26c95e093e3c4d5eb456c6c5dfa1579"/><dir name="Output"><file name="Html.php" hash="5ec70c500dda56a561d188dd6e908e49"/><file name="Json.php" hash="4616bcc1ddd3eaa312ef2235e7da1586"/><file name="Ncurses.php" hash="60dbe6e0b2eb00dedccc972271a712fa"/><file name="Output.php" hash="34ef640283d567d93300a2b9c107d276"/><file name="Serialized.php" hash="aa749737127da4bb25c941557d1cfb81"/><file name="Xml.php" hash="7fb392ee95df014c30dd52130e9db45c"/></dir><dir name="Exceptions"><file name="FatalException.php" hash="ac7ae108aa403bc300ba9086410cf0a9"/></dir><dir name="Extension"><file name="Apcaccess.php" hash="8e274bd0036006e064c0cd85fbd732a9"/><file name="Cups.php" hash="25bb7dfe794d5ff211c9862615e2192b"/><file name="Dhcpd3_leases.php" hash="40ffcf2c2ec8618ff8155d197c15bbf1"/><file name="Dnsmasq_dhcpd.php" hash="bc751a49a09f06d8e4492f7ddf432cea"/><file name="Extension.php" hash="d09316ce5276805b702fdc1115b4adc3"/><file name="Ipmi.php" hash="5536abf11a4f06e0b91852f5e17b77bc"/><file name="Libvirt.php" hash="889dcd93239aecb42d6f80b2618e87b1"/><file name="Smb.php" hash="d6d4e995bf54fbdfeec0a51f70faec37"/><file name="Soldat.php" hash="bce89097e6540818f153b2df5b71b0b5"/><file name="Transmission.php" hash="e438b16dc2040d8676c7ba2c1448b6ef"/><file name="Truecrypt.php" hash="f4838a69d9eda202a5d64e8bb8ced36c"/><file name="Utorrent.php" hash="14119c01579d58a01f6489a0865855f7"/></dir><dir name="Lang"><file name="de.php" hash="e313cc8346be39d62607278bd986af23"/><file name="en.php" hash="8ee1b778ed29c64e02e3e1f118016f82"/><file name="fi.php" hash="10d10cd954719a7cee69d5bfbf67889c"/><file name="fr.php" hash="6edcf8ee5251dee98ee39f84fdd52647"/><file name="it.php" hash="d65c5225fa3ef16fd2966137c18e83f4"/><file name="pl.php" hash="2d9b92e225acf0461540d1224a0141f5"/><file name="pt.php" hash="9dd24ee347278edc24f589f6e3f12c58"/><file name="zh.php" hash="2f9ae1cfcf4e5a80127200bf9c9d0b8b"/></dir><dir name="OS"><file name="BSDcommon.php" hash="3b6c83b58e56e0a0eac250f70451be5a"/><file name="Darwin.php" hash="fc45b3648d75c96596d8c7a8559d2d74"/><file name="DragonFly.php" hash="c5ffffe8e6899a0f8352c1fd0f763135"/><file name="FreeBSD.php" hash="f07d480ebda610153b5f6d42d0143f37"/><file name="Linux.php" hash="5e36caf50252aa24fab289ae4239a591"/><file name="Minix.php" hash="22c19a5e45c4715cfcb0db1f42fd5793"/><file name="NetBSD.php" hash="f576ac8083757848bbd179420c182aeb"/><file name="OS.php" hash="49f2a6e9b1e3e56815896f0364049bef"/><file name="OpenBSD.php" hash="cd6b1bd659a30465903ebc913382b223"/><file name="SunOS.php" hash="2cfa3e63e51ca1d8928f2f521be26b3d"/><file name="Unixcommon.php" hash="9981cca8d8805302983ebe20dc2ef04d"/><file name="Windows.php" hash="f73cd25acaf3774da31b922ab3287038"/></dir><dir name="Meta"><file name="Errors.php" hash="e614a650fd523918b010b4297c4c2acd"/><file name="Timer.php" hash="ea244a5a388fa8cc470799cbdd96b866"/></dir><dir name="Parsers"><file name="CallExt.php" hash="6a671a39e8debf7e4c950491f45d8ee4"/><file name="Hddtemp.php" hash="3d0007ab7349702042a88f1e9ca23649"/><file name="Hwpci.php" hash="e26d72856736d83470e82916ba78a3ca"/><file name="Mbmon.php" hash="aa3782625c7542059838e475ccb13326"/><file name="Sensord.php" hash="2be994a2c77ba0a35398a6fc96a4c77a"/></dir></dir></dir></target></contents></package>
|
skin/adminhtml/default/default/neklo/monitor/css/styles.css
CHANGED
@@ -3,4 +3,32 @@
|
|
3 |
}
|
4 |
.gateway_status.error {
|
5 |
color:#FF0000;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
}
|
3 |
}
|
4 |
.gateway_status.error {
|
5 |
color:#FF0000;
|
6 |
+
}
|
7 |
+
|
8 |
+
.neklo-monitor-message-conteiner {
|
9 |
+
text-align: center;
|
10 |
+
}
|
11 |
+
|
12 |
+
.neklo-monitor-account-message {
|
13 |
+
font-weight: bold;
|
14 |
+
}
|
15 |
+
.neklo-monitor-account-message.success {
|
16 |
+
color:#008000;
|
17 |
+
}
|
18 |
+
.neklo-monitor-account-message.error {
|
19 |
+
color:#FF0000;
|
20 |
+
}
|
21 |
+
|
22 |
+
.account-actions {
|
23 |
+
text-align: right;
|
24 |
+
}
|
25 |
+
|
26 |
+
.action-button {
|
27 |
+
display: inline-block;
|
28 |
+
}
|
29 |
+
|
30 |
+
.input-disabled {
|
31 |
+
border: none;
|
32 |
+
background-color: #FFFFFF;
|
33 |
+
color: #000000;
|
34 |
}
|