Version Notes
The update includes a number of all-new reports, improved sales forecast algorithm and the ability to search and view order and customer data. Here is the full list of new features:
- Ability to search and view all clients and orders by name, email or ID
- Displays sales stats as profit or revenue
- Sales by country report
- Items per order report (IPO)
- Average order value report (AOV)
- Last orders with items on the dashboard
- Improved sales forecast algorithm
Download this release
Release Info
| Developer | AW_Core_Team |
| Extension | AW_Onpulse |
| Version | 2.0.0 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.16 to 2.0.0
- app/code/local/AW/Onpulse/Block/System/Config/Form/Fieldset/Onpulse/Access.php +18 -0
- app/code/local/AW/Onpulse/Block/System/Config/Form/Fieldset/Onpulse/Settings.php +0 -12
- app/code/local/AW/Onpulse/Helper/Data.php +137 -90
- app/code/local/AW/Onpulse/Model/Aggregator.php +9 -8
- app/code/local/AW/Onpulse/Model/Aggregator/Component.php +6 -6
- app/code/local/AW/Onpulse/Model/Aggregator/Components/Customer.php +69 -38
- app/code/local/AW/Onpulse/Model/Aggregator/Components/Order.php +115 -40
- app/code/local/AW/Onpulse/Model/Aggregator/Components/Statistics.php +609 -300
- app/code/local/AW/Onpulse/Model/Credentials.php +92 -90
- app/code/local/AW/Onpulse/Model/Source/OrderStatus.php +12 -0
- app/code/local/AW/Onpulse/Model/Source/ProfitRevenue.php +23 -0
- app/code/local/AW/Onpulse/controllers/Adminhtml/ConfigController.php +20 -0
- app/code/local/AW/Onpulse/controllers/IndexController.php +92 -51
- app/code/local/AW/Onpulse/etc/config.xml +14 -2
- app/code/local/AW/Onpulse/etc/system.xml +40 -17
- app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-install-1.0.0.php +5 -1
- app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.0-1.0.1.php +0 -1
- app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.0-1.0.14.php +5 -0
- app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.1-1.0.2.php +0 -1
- app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.10-1.0.11.php +0 -1
- app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.11-1.0.12.php +0 -1
- app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.12-1.0.13.php +0 -1
- app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.13-1.0.14.php +0 -1
- app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.14-1.0.15.php +7 -2
- app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.14-1.0.16.php +0 -3
- app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.15-1.0.16.php +0 -2
- app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.15-1.0.17.php +5 -0
- app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.17-2.0.0.php +8 -0
- app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.2-1.0.3.php +0 -1
- app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.3-1.0.4.php +0 -1
- app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.4-1.0.5.php +0 -1
- app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.5-1.0.6.php +0 -1
- app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.6-1.0.7.php +0 -1
- app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.7-1.0.8.php +0 -1
- app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.8-1.0.9.php +0 -1
- app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.9-1.0.10.php +0 -1
- app/design/adminhtml/default/default/layout/aw_onpulse.xml +11 -11
- app/design/adminhtml/default/default/template/aw_onpulse/access.phtml +118 -0
- app/design/adminhtml/default/default/template/aw_onpulse/settings.phtml +0 -155
- app/locale/en_US/AW_Onpulse.csv +17 -13
- package.xml +14 -8
app/code/local/AW/Onpulse/Block/System/Config/Form/Fieldset/Onpulse/Access.php
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class AW_Onpulse_Block_System_Config_Form_Fieldset_Onpulse_Access
|
| 4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
| 5 |
+
{
|
| 6 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
| 7 |
+
{
|
| 8 |
+
$html = $this->_getHeaderHtml($element);
|
| 9 |
+
$html .= $this->setTemplate('aw_onpulse/access.phtml')->_toHtml();
|
| 10 |
+
$html .= $this->_getFooterHtml($element);
|
| 11 |
+
return $html;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
public function getGenerateUrl()
|
| 15 |
+
{
|
| 16 |
+
return $this->getUrl('awonpulse_admin/adminhtml_config/generate', array('section' => 'awonpulse'));
|
| 17 |
+
}
|
| 18 |
+
}
|
app/code/local/AW/Onpulse/Block/System/Config/Form/Fieldset/Onpulse/Settings.php
DELETED
|
@@ -1,12 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
class AW_Onpulse_Block_System_Config_Form_Fieldset_Onpulse_Settings extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
| 4 |
-
{
|
| 5 |
-
public function render(Varien_Data_Form_Element_Abstract $element)
|
| 6 |
-
{
|
| 7 |
-
$html = $this->_getHeaderHtml($element);
|
| 8 |
-
$html .=$this->setTemplate('aw_onpulse/settings.phtml')->_toHtml();
|
| 9 |
-
$html .= $this->_getFooterHtml($element);
|
| 10 |
-
return $html;
|
| 11 |
-
}
|
| 12 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/AW/Onpulse/Helper/Data.php
CHANGED
|
@@ -18,26 +18,35 @@ class AW_Onpulse_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 18 |
|
| 19 |
protected static $_platform = -1;
|
| 20 |
|
|
|
|
|
|
|
| 21 |
/**
|
| 22 |
* Checks which edition is used
|
|
|
|
| 23 |
* @return int
|
| 24 |
*/
|
| 25 |
public static function getPlatform()
|
| 26 |
{
|
| 27 |
if (self::$_platform == -1) {
|
| 28 |
-
$pathToClaim = BP . DS . "app" . DS . "etc" . DS . "modules" . DS . self::ENTERPRISE_DETECT_COMPANY . "_"
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
self::$_platform = self::CE_PLATFORM;
|
| 33 |
} else {
|
| 34 |
-
$_xml = @simplexml_load_file($pathToEEConfig,'SimpleXMLElement', LIBXML_NOCDATA);
|
| 35 |
-
if(!$_xml===
|
| 36 |
$package = (string)$_xml->default->design->package->name;
|
| 37 |
$theme = (string)$_xml->install->design->theme->default;
|
| 38 |
$skin = (string)$_xml->stores->admin->design->theme->skin;
|
| 39 |
-
$
|
| 40 |
-
|
|
|
|
|
|
|
| 41 |
self::$_platform = self::PE_PLATFORM;
|
| 42 |
return self::$_platform;
|
| 43 |
}
|
|
@@ -49,23 +58,22 @@ class AW_Onpulse_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 49 |
}
|
| 50 |
|
| 51 |
|
| 52 |
-
|
| 53 |
public function getPriceFormat($price)
|
| 54 |
{
|
| 55 |
$price = sprintf("%01.2f", $price);
|
| 56 |
return $price;
|
| 57 |
}
|
| 58 |
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
if(version_compare(Mage::getVersion(),'1.4.1','<')) {
|
| 63 |
$data = htmlspecialchars($data);
|
| 64 |
} else {
|
| 65 |
$data = parent::escapeHtml($data);
|
| 66 |
}
|
| 67 |
return $data;
|
| 68 |
}
|
|
|
|
| 69 |
private function _getItemOptions($item)
|
| 70 |
{
|
| 71 |
$result = array();
|
|
@@ -83,31 +91,31 @@ class AW_Onpulse_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 83 |
return $result;
|
| 84 |
}
|
| 85 |
|
| 86 |
-
private function
|
| 87 |
{
|
| 88 |
-
|
| 89 |
-
if ($customer->getData("default_{$addresType}")) {
|
| 90 |
-
|
| 91 |
//Prevent Notice if can't find country name by code
|
| 92 |
-
$country = $customer->getData("{$
|
| 93 |
-
if (isset($this->_countries[$customer->getData("{$
|
| 94 |
-
$country = $this->_countries[$customer->getData("{$
|
| 95 |
}
|
| 96 |
return array(
|
| 97 |
-
'first_name' => $this->escapeHtml($customer->getData("{$
|
| 98 |
-
'last_name'
|
| 99 |
-
'postcode'
|
| 100 |
-
'city'
|
| 101 |
-
'street'
|
| 102 |
-
'telephone'
|
| 103 |
-
|
| 104 |
-
|
|
|
|
|
|
|
| 105 |
);
|
| 106 |
}
|
| 107 |
return array();
|
| 108 |
}
|
| 109 |
|
| 110 |
-
private function
|
| 111 |
{
|
| 112 |
//Prevent Notice if can't find country name by code
|
| 113 |
$country = $order->getData("country_id");
|
|
@@ -116,39 +124,45 @@ class AW_Onpulse_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 116 |
}
|
| 117 |
return array(
|
| 118 |
'first_name' => $this->escapeHtml($order->getData("firstname")),
|
| 119 |
-
'last_name'
|
| 120 |
-
'postcode'
|
| 121 |
-
'city'
|
| 122 |
-
'street'
|
| 123 |
-
'telephone'
|
| 124 |
-
'region'
|
| 125 |
-
'country'
|
| 126 |
);
|
| 127 |
}
|
| 128 |
|
| 129 |
private function _getCustomersRecentOrders($customer)
|
| 130 |
{
|
| 131 |
-
if(version_compare(Mage::getVersion(),'1.4.1','
|
| 132 |
-
$orderCollection=Mage::getModel(
|
|
|
|
|
|
|
| 133 |
} else {
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
|
|
|
| 139 |
}
|
| 140 |
-
$orderCollection
|
| 141 |
-
->
|
|
|
|
|
|
|
| 142 |
return $orderCollection;
|
| 143 |
}
|
| 144 |
|
| 145 |
private function _getProductsArrayFromOrder($order)
|
| 146 |
{
|
| 147 |
$products = array();
|
| 148 |
-
|
| 149 |
foreach ($order->getItemsCollection() as $item) {
|
| 150 |
$product = array();
|
| 151 |
-
if ($item->getParentItem())
|
|
|
|
|
|
|
| 152 |
if ($_options = $this->_getItemOptions($item)) {
|
| 153 |
foreach ($_options as $_option) {
|
| 154 |
$product['options'][$_option['label']] = $_option['value'];
|
|
@@ -165,25 +179,22 @@ class AW_Onpulse_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 165 |
|
| 166 |
public function processOutput($data)
|
| 167 |
{
|
| 168 |
-
$this->dateTimeFormat = Mage::app()->getLocale()->getDateTimeFormat(
|
|
|
|
|
|
|
| 169 |
$clients = $data->getData('clients');
|
| 170 |
$orders = $data->getData('orders');
|
| 171 |
$dashboard = $data->getData('dashboard');
|
| 172 |
$processedClients = array();
|
| 173 |
-
$processedDashboardClients = array();
|
| 174 |
$processedOrders = array();
|
| 175 |
foreach (Mage::helper('directory')->getCountryCollection() as $country) {
|
| 176 |
$this->_countries[$country->getId()] = $country->getName();
|
| 177 |
}
|
| 178 |
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
}
|
| 184 |
-
|
| 185 |
-
if($orders->getSize())
|
| 186 |
-
foreach($orders as $order) {
|
| 187 |
$processedOrders[] = $this->processOrderToArray($order);
|
| 188 |
}
|
| 189 |
|
|
@@ -200,58 +211,84 @@ class AW_Onpulse_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 200 |
$processedDashboardClientsYesterday[] = $this->processCustomerToArray($customer, true);
|
| 201 |
}
|
| 202 |
}
|
| 203 |
-
$dashboard['customers']['today_customers']['registered'] = count(
|
| 204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
|
| 206 |
return array(
|
| 207 |
'connector_version' => (string)Mage::getConfig()->getNode()->modules->AW_Onpulse->version,
|
| 208 |
-
'price_format'
|
| 209 |
-
'clients'
|
| 210 |
-
'orders'
|
| 211 |
-
'dashboard'
|
| 212 |
-
'storename'
|
| 213 |
-
'curSymbol'
|
|
|
|
|
|
|
| 214 |
);
|
| 215 |
}
|
| 216 |
|
| 217 |
|
| 218 |
public function processOrderToArray($order)
|
| 219 |
{
|
| 220 |
-
|
| 221 |
$customer = '';
|
| 222 |
if ($order->getCustomerId()) {
|
| 223 |
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
| 224 |
-
if ($customer)
|
| 225 |
$customer = $this->processCustomerToArray($customer);
|
|
|
|
| 226 |
}
|
| 227 |
-
if(!$order->getGiftCardsAmount()) {
|
| 228 |
$order->setGiftCardsAmount(0);
|
| 229 |
}
|
| 230 |
|
| 231 |
$orderInfo = array(
|
| 232 |
-
'increment_id'
|
| 233 |
-
'creation_date'
|
|
|
|
|
|
|
| 234 |
'customer_firstname' => $this->escapeHtml($order->getCustomerFirstname()),
|
| 235 |
-
'customer_lastname'
|
| 236 |
-
'customer_email'
|
| 237 |
-
'status_code'
|
| 238 |
-
'status'
|
| 239 |
-
'subtotal'
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
'
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
|
| 247 |
//-----------------------------------------------------
|
| 248 |
-
'items'
|
| 249 |
-
'customer'
|
| 250 |
-
'billing'
|
|
|
|
|
|
|
| 251 |
);
|
| 252 |
|
| 253 |
if (!$order->getIsVirtual()) {
|
| 254 |
-
$orderInfo['shipping'] = $this->
|
|
|
|
|
|
|
| 255 |
}
|
| 256 |
|
| 257 |
return $orderInfo;
|
|
@@ -267,24 +304,34 @@ class AW_Onpulse_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 267 |
$client['last_name'] = $this->escapeHtml($customer->getLastname());
|
| 268 |
$client['email'] = $customer->getEmail();
|
| 269 |
//$client['date_registered'] = $customer->getCreatedAt();
|
| 270 |
-
$client['date_registered'] = Mage::app()->getLocale()->date(
|
|
|
|
|
|
|
| 271 |
|
| 272 |
$client['country'] = '';
|
| 273 |
if ($customer->getData('billing_country_id')) {
|
| 274 |
-
$client['country'] = $this->_countries[$customer->getData(
|
|
|
|
|
|
|
| 275 |
}
|
| 276 |
|
| 277 |
$client['phone'] = '';
|
| 278 |
if ($customer->getData('billing_telephone')) {
|
| 279 |
-
$client['phone'] = $this->escapeHtml(
|
|
|
|
|
|
|
| 280 |
}
|
| 281 |
|
| 282 |
if ($additional) {
|
| 283 |
// Format billing address data
|
| 284 |
-
$client['billing'] = $this->
|
|
|
|
|
|
|
| 285 |
|
| 286 |
// Format shipping address data
|
| 287 |
-
$client['shipping'] = $this->
|
|
|
|
|
|
|
| 288 |
|
| 289 |
$orders = $this->_getCustomersRecentOrders($customer);
|
| 290 |
$customerOrders = array();
|
| 18 |
|
| 19 |
protected static $_platform = -1;
|
| 20 |
|
| 21 |
+
private $_countries = array();
|
| 22 |
+
|
| 23 |
/**
|
| 24 |
* Checks which edition is used
|
| 25 |
+
*
|
| 26 |
* @return int
|
| 27 |
*/
|
| 28 |
public static function getPlatform()
|
| 29 |
{
|
| 30 |
if (self::$_platform == -1) {
|
| 31 |
+
$pathToClaim = BP . DS . "app" . DS . "etc" . DS . "modules" . DS . self::ENTERPRISE_DETECT_COMPANY . "_"
|
| 32 |
+
. self::ENTERPRISE_DETECT_EXTENSION . ".xml"
|
| 33 |
+
;
|
| 34 |
+
$pathToEEConfig = BP . DS . "app" . DS . "code" . DS . "core" . DS
|
| 35 |
+
. self::ENTERPRISE_DETECT_COMPANY . DS . self::ENTERPRISE_DETECT_EXTENSION . DS . "etc" . DS
|
| 36 |
+
. "config.xml"
|
| 37 |
+
;
|
| 38 |
+
if (!file_exists($pathToClaim) || !file_exists($pathToEEConfig)) {
|
| 39 |
self::$_platform = self::CE_PLATFORM;
|
| 40 |
} else {
|
| 41 |
+
$_xml = @simplexml_load_file($pathToEEConfig, 'SimpleXMLElement', LIBXML_NOCDATA);
|
| 42 |
+
if (!$_xml === false) {
|
| 43 |
$package = (string)$_xml->default->design->package->name;
|
| 44 |
$theme = (string)$_xml->install->design->theme->default;
|
| 45 |
$skin = (string)$_xml->stores->admin->design->theme->skin;
|
| 46 |
+
$isProfessional = ($package == self::PROFESSIONAL_DESIGN_NAME)
|
| 47 |
+
&& ($theme == self::PROFESSIONAL_DESIGN_NAME) && ($skin == self::PROFESSIONAL_DESIGN_NAME)
|
| 48 |
+
;
|
| 49 |
+
if ($isProfessional) {
|
| 50 |
self::$_platform = self::PE_PLATFORM;
|
| 51 |
return self::$_platform;
|
| 52 |
}
|
| 58 |
}
|
| 59 |
|
| 60 |
|
|
|
|
| 61 |
public function getPriceFormat($price)
|
| 62 |
{
|
| 63 |
$price = sprintf("%01.2f", $price);
|
| 64 |
return $price;
|
| 65 |
}
|
| 66 |
|
| 67 |
+
public function escapeHtml($data, $allowedTags = null)
|
| 68 |
+
{
|
| 69 |
+
if (version_compare(Mage::getVersion(), '1.4.1', '<')) {
|
|
|
|
| 70 |
$data = htmlspecialchars($data);
|
| 71 |
} else {
|
| 72 |
$data = parent::escapeHtml($data);
|
| 73 |
}
|
| 74 |
return $data;
|
| 75 |
}
|
| 76 |
+
|
| 77 |
private function _getItemOptions($item)
|
| 78 |
{
|
| 79 |
$result = array();
|
| 91 |
return $result;
|
| 92 |
}
|
| 93 |
|
| 94 |
+
private function _getAddressInfoArray($customer, $addressType = 'billing')
|
| 95 |
{
|
| 96 |
+
if ($customer->getData("default_{$addressType}")) {
|
|
|
|
|
|
|
| 97 |
//Prevent Notice if can't find country name by code
|
| 98 |
+
$country = $customer->getData("{$addressType}_country_id");
|
| 99 |
+
if (isset($this->_countries[$customer->getData("{$addressType}_country_id")])) {
|
| 100 |
+
$country = $this->_countries[$customer->getData("{$addressType}_country_id")];
|
| 101 |
}
|
| 102 |
return array(
|
| 103 |
+
'first_name' => $this->escapeHtml($customer->getData("{$addressType}_firstname")),
|
| 104 |
+
'last_name' => $this->escapeHtml($customer->getData("{$addressType}_lastname")),
|
| 105 |
+
'postcode' => $this->escapeHtml($customer->getData("{$addressType}_postcode")),
|
| 106 |
+
'city' => $this->escapeHtml($customer->getData("{$addressType}_city")),
|
| 107 |
+
'street' => $this->escapeHtml($customer->getData("{$addressType}_street")),
|
| 108 |
+
'telephone' => $this->escapeHtml(
|
| 109 |
+
$this->escapeHtml($customer->getData("{$addressType}_telephone"))
|
| 110 |
+
),
|
| 111 |
+
'region' => $this->escapeHtml($customer->getData("{$addressType}_region")),
|
| 112 |
+
'country' => $this->escapeHtml($country),
|
| 113 |
);
|
| 114 |
}
|
| 115 |
return array();
|
| 116 |
}
|
| 117 |
|
| 118 |
+
private function _getAddressInfoFromOrderToArray($order)
|
| 119 |
{
|
| 120 |
//Prevent Notice if can't find country name by code
|
| 121 |
$country = $order->getData("country_id");
|
| 124 |
}
|
| 125 |
return array(
|
| 126 |
'first_name' => $this->escapeHtml($order->getData("firstname")),
|
| 127 |
+
'last_name' => $this->escapeHtml($order->getData("lastname")),
|
| 128 |
+
'postcode' => $this->escapeHtml($order->getData("postcode")),
|
| 129 |
+
'city' => $this->escapeHtml($order->getData("city")),
|
| 130 |
+
'street' => $this->escapeHtml($order->getData("street")),
|
| 131 |
+
'telephone' => $this->escapeHtml($order->getData("telephone")),
|
| 132 |
+
'region' => $this->escapeHtml($order->getData("region")),
|
| 133 |
+
'country' => $this->escapeHtml($country),
|
| 134 |
);
|
| 135 |
}
|
| 136 |
|
| 137 |
private function _getCustomersRecentOrders($customer)
|
| 138 |
{
|
| 139 |
+
if (version_compare(Mage::getVersion(), '1.4.1.0', '<=')) {
|
| 140 |
+
$orderCollection = Mage::getModel(
|
| 141 |
+
'awonpulse/aggregator_components_order'
|
| 142 |
+
)->getCollectionForOldMagento();
|
| 143 |
} else {
|
| 144 |
+
/** @var $orderCollection Mage_Sales_Model_Resource_Order_Collection */
|
| 145 |
+
$orderCollection = Mage::getModel('sales/order')->getCollection();
|
| 146 |
+
$orderCollection->addAddressFields()
|
| 147 |
+
->addAttributeToSelect('*')
|
| 148 |
+
->addOrder('entity_id', 'DESC')
|
| 149 |
+
;
|
| 150 |
}
|
| 151 |
+
$orderCollection
|
| 152 |
+
->addAttributeToFilter('main_table.customer_id', array('eq' => $customer->getId()))
|
| 153 |
+
->setPageSize(self::RECENT_ORDERS_COUNT)
|
| 154 |
+
;
|
| 155 |
return $orderCollection;
|
| 156 |
}
|
| 157 |
|
| 158 |
private function _getProductsArrayFromOrder($order)
|
| 159 |
{
|
| 160 |
$products = array();
|
|
|
|
| 161 |
foreach ($order->getItemsCollection() as $item) {
|
| 162 |
$product = array();
|
| 163 |
+
if ($item->getParentItem()) {
|
| 164 |
+
continue;
|
| 165 |
+
}
|
| 166 |
if ($_options = $this->_getItemOptions($item)) {
|
| 167 |
foreach ($_options as $_option) {
|
| 168 |
$product['options'][$_option['label']] = $_option['value'];
|
| 179 |
|
| 180 |
public function processOutput($data)
|
| 181 |
{
|
| 182 |
+
$this->dateTimeFormat = Mage::app()->getLocale()->getDateTimeFormat(
|
| 183 |
+
Mage_Core_Model_Locale::FORMAT_TYPE_SHORT
|
| 184 |
+
);
|
| 185 |
$clients = $data->getData('clients');
|
| 186 |
$orders = $data->getData('orders');
|
| 187 |
$dashboard = $data->getData('dashboard');
|
| 188 |
$processedClients = array();
|
|
|
|
| 189 |
$processedOrders = array();
|
| 190 |
foreach (Mage::helper('directory')->getCountryCollection() as $country) {
|
| 191 |
$this->_countries[$country->getId()] = $country->getName();
|
| 192 |
}
|
| 193 |
|
| 194 |
+
foreach ($clients as $customer) {
|
| 195 |
+
$processedClients[] = $this->processCustomerToArray($customer, true);
|
| 196 |
+
}
|
| 197 |
+
foreach ($orders as $order) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
$processedOrders[] = $this->processOrderToArray($order);
|
| 199 |
}
|
| 200 |
|
| 211 |
$processedDashboardClientsYesterday[] = $this->processCustomerToArray($customer, true);
|
| 212 |
}
|
| 213 |
}
|
| 214 |
+
$dashboard['customers']['today_customers']['registered'] = count(
|
| 215 |
+
$processedDashboardClientsToday
|
| 216 |
+
);
|
| 217 |
+
$dashboard['customers']['yesterday_customers']['registered'] = count(
|
| 218 |
+
$processedDashboardClientsYesterday
|
| 219 |
+
);
|
| 220 |
|
| 221 |
return array(
|
| 222 |
'connector_version' => (string)Mage::getConfig()->getNode()->modules->AW_Onpulse->version,
|
| 223 |
+
'price_format' => Mage::app()->getLocale()->getJsPriceFormat(),
|
| 224 |
+
'clients' => $processedClients,
|
| 225 |
+
'orders' => $processedOrders,
|
| 226 |
+
'dashboard' => $dashboard,
|
| 227 |
+
'storename' => strip_tags(Mage::getStoreConfig('general/store_information/name')),
|
| 228 |
+
'curSymbol' => Mage::app()->getLocale()->currency(
|
| 229 |
+
Mage::app()->getStore()->getBaseCurrencyCode()
|
| 230 |
+
)->getSymbol(),
|
| 231 |
);
|
| 232 |
}
|
| 233 |
|
| 234 |
|
| 235 |
public function processOrderToArray($order)
|
| 236 |
{
|
|
|
|
| 237 |
$customer = '';
|
| 238 |
if ($order->getCustomerId()) {
|
| 239 |
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
| 240 |
+
if ($customer) {
|
| 241 |
$customer = $this->processCustomerToArray($customer);
|
| 242 |
+
}
|
| 243 |
}
|
| 244 |
+
if (!$order->getGiftCardsAmount()) {
|
| 245 |
$order->setGiftCardsAmount(0);
|
| 246 |
}
|
| 247 |
|
| 248 |
$orderInfo = array(
|
| 249 |
+
'increment_id' => $order->getIncrementId(),
|
| 250 |
+
'creation_date' => $order->getCreatedAtFormated($this->dateTimeFormat)->toString(
|
| 251 |
+
$this->dateTimeFormat
|
| 252 |
+
),
|
| 253 |
'customer_firstname' => $this->escapeHtml($order->getCustomerFirstname()),
|
| 254 |
+
'customer_lastname' => $this->escapeHtml($order->getCustomerLastname()),
|
| 255 |
+
'customer_email' => $order->getCustomerEmail(),
|
| 256 |
+
'status_code' => $order->getStatus(),
|
| 257 |
+
'status' => htmlspecialchars($order->getStatusLabel()),
|
| 258 |
+
'subtotal' => $this->getPriceFormat(
|
| 259 |
+
$order->getBaseSubtotal()
|
| 260 |
+
),
|
| 261 |
+
'discount' => $this->getPriceFormat(
|
| 262 |
+
$order->getBaseDiscountAmount()
|
| 263 |
+
),
|
| 264 |
+
'grand_total' => $this->getPriceFormat(
|
| 265 |
+
$order->getBaseGrandTotal()
|
| 266 |
+
),
|
| 267 |
+
'shipping_amount' => $this->getPriceFormat(
|
| 268 |
+
$order->getBaseShippingAmount()
|
| 269 |
+
),
|
| 270 |
+
'tax' => $this->getPriceFormat(
|
| 271 |
+
$order->getBaseTaxAmount()
|
| 272 |
+
),
|
| 273 |
+
'gift_cards_amount' => -$this->getPriceFormat(
|
| 274 |
+
$order->getGiftCardsAmount()
|
| 275 |
+
),
|
| 276 |
+
'currency' => Mage::app()->getLocale()->currency(
|
| 277 |
+
Mage::app()->getStore()->getBaseCurrencyCode()
|
| 278 |
+
)->getSymbol(),
|
| 279 |
|
| 280 |
//-----------------------------------------------------
|
| 281 |
+
'items' => $this->_getProductsArrayFromOrder($order),
|
| 282 |
+
'customer' => $customer,
|
| 283 |
+
'billing' => $this->_getAddressInfoFromOrderToArray(
|
| 284 |
+
$order->getBillingAddress()
|
| 285 |
+
),
|
| 286 |
);
|
| 287 |
|
| 288 |
if (!$order->getIsVirtual()) {
|
| 289 |
+
$orderInfo['shipping'] = $this->_getAddressInfoFromOrderToArray(
|
| 290 |
+
$order->getShippingAddress()
|
| 291 |
+
);
|
| 292 |
}
|
| 293 |
|
| 294 |
return $orderInfo;
|
| 304 |
$client['last_name'] = $this->escapeHtml($customer->getLastname());
|
| 305 |
$client['email'] = $customer->getEmail();
|
| 306 |
//$client['date_registered'] = $customer->getCreatedAt();
|
| 307 |
+
$client['date_registered'] = Mage::app()->getLocale()->date(
|
| 308 |
+
$customer->getCreatedAt()
|
| 309 |
+
)->toString($this->dateTimeFormat);
|
| 310 |
|
| 311 |
$client['country'] = '';
|
| 312 |
if ($customer->getData('billing_country_id')) {
|
| 313 |
+
$client['country'] = $this->_countries[$customer->getData(
|
| 314 |
+
'billing_country_id'
|
| 315 |
+
)];
|
| 316 |
}
|
| 317 |
|
| 318 |
$client['phone'] = '';
|
| 319 |
if ($customer->getData('billing_telephone')) {
|
| 320 |
+
$client['phone'] = $this->escapeHtml(
|
| 321 |
+
$customer->getData('billing_telephone')
|
| 322 |
+
);
|
| 323 |
}
|
| 324 |
|
| 325 |
if ($additional) {
|
| 326 |
// Format billing address data
|
| 327 |
+
$client['billing'] = $this->_getAddressInfoArray(
|
| 328 |
+
$customer, 'billing'
|
| 329 |
+
);
|
| 330 |
|
| 331 |
// Format shipping address data
|
| 332 |
+
$client['shipping'] = $this->_getAddressInfoArray(
|
| 333 |
+
$customer, 'shipping'
|
| 334 |
+
);
|
| 335 |
|
| 336 |
$orders = $this->_getCustomersRecentOrders($customer);
|
| 337 |
$customerOrders = array();
|
app/code/local/AW/Onpulse/Model/Aggregator.php
CHANGED
|
@@ -1,9 +1,10 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
class AW_Onpulse_Model_Aggregator extends Mage_Core_Model_Abstract
|
| 4 |
-
{
|
| 5 |
-
public function Aggregate()
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
| 9 |
}
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class AW_Onpulse_Model_Aggregator extends Mage_Core_Model_Abstract
|
| 4 |
+
{
|
| 5 |
+
public function Aggregate()
|
| 6 |
+
{
|
| 7 |
+
Mage::dispatchEvent('onpulse_aggregate_data', array('aggregator' => $this));
|
| 8 |
+
return $this;
|
| 9 |
+
}
|
| 10 |
}
|
app/code/local/AW/Onpulse/Model/Aggregator/Component.php
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
abstract class AW_Onpulse_Model_Aggregator_Component extends Mage_Core_Model_Abstract
|
| 4 |
-
{
|
| 5 |
-
public function pushData($event){}
|
| 6 |
-
}
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
abstract class AW_Onpulse_Model_Aggregator_Component extends Mage_Core_Model_Abstract
|
| 4 |
+
{
|
| 5 |
+
public function pushData($event = null){}
|
| 6 |
+
}
|
app/code/local/AW/Onpulse/Model/Aggregator/Components/Customer.php
CHANGED
|
@@ -1,38 +1,69 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
class AW_Onpulse_Model_Aggregator_Components_Customer extends AW_Onpulse_Model_Aggregator_Component
|
| 4 |
-
{
|
| 5 |
-
const COUNT_CUSTOMERS =
|
| 6 |
-
|
| 7 |
-
public function pushData($event = null)
|
| 8 |
-
{
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
$
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
->
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
->
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class AW_Onpulse_Model_Aggregator_Components_Customer extends AW_Onpulse_Model_Aggregator_Component
|
| 4 |
+
{
|
| 5 |
+
const COUNT_CUSTOMERS = 30;
|
| 6 |
+
|
| 7 |
+
public function pushData($event = null)
|
| 8 |
+
{
|
| 9 |
+
$customerCollection = $this->_getCustomerCollection();
|
| 10 |
+
$aggregator = $event->getEvent()->getAggregator();
|
| 11 |
+
$aggregator->setData('clients', $customerCollection->load());
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
public function pushSearchedData($aggregator, $query)
|
| 15 |
+
{
|
| 16 |
+
$customerCollection = $this->_getCustomerCollection();
|
| 17 |
+
if (strpos($query, '@') !== FALSE) {
|
| 18 |
+
$customerCollection->addAttributeToFilter('email', array('like' => '%' . $query . '%'));
|
| 19 |
+
} else {
|
| 20 |
+
$countryOptionArray = Mage::helper('directory')->getCountryCollection()->toOptionArray(false);
|
| 21 |
+
$countryResultIdList = array();
|
| 22 |
+
foreach ($countryOptionArray as $option) {
|
| 23 |
+
if (stripos($option['label'], $query) !== FALSE) {
|
| 24 |
+
$countryResultIdList[] = $option['value'];
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
$customerCollection->addAttributeToFilter(array(
|
| 28 |
+
array('attribute' => 'email', 'like' => '%' . $query . '%'),
|
| 29 |
+
array('attribute' => 'firstname', 'like' => '%' . $query . '%'),
|
| 30 |
+
array('attribute' => 'lastname', 'like' => '%' . $query . '%'),
|
| 31 |
+
array('attribute' => 'billing_postcode', 'like' => '%' . $query . '%'),
|
| 32 |
+
array('attribute' => 'billing_country_id', 'in' => $countryResultIdList)
|
| 33 |
+
));
|
| 34 |
+
}
|
| 35 |
+
$aggregator->setData('clients', $customerCollection->load());
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* @return Mage_Customer_Model_Resource_Customer_Collection
|
| 40 |
+
*/
|
| 41 |
+
protected function _getCustomerCollection()
|
| 42 |
+
{
|
| 43 |
+
/** @var $customerCollection Mage_Customer_Model_Resource_Customer_Collection */
|
| 44 |
+
$customerCollection = Mage::getModel('customer/customer')->getCollection()
|
| 45 |
+
->setPageSize(self::COUNT_CUSTOMERS)
|
| 46 |
+
->addNameToSelect()
|
| 47 |
+
->addAttributeToSelect('email')
|
| 48 |
+
->addAttributeToSelect('created_at')
|
| 49 |
+
->joinAttribute('billing_firstname', 'customer_address/firstname', 'default_billing', null, 'left')
|
| 50 |
+
->joinAttribute('billing_lastname', 'customer_address/lastname', 'default_billing', null, 'left')
|
| 51 |
+
->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
|
| 52 |
+
->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
|
| 53 |
+
->joinAttribute('billing_street', 'customer_address/street', 'default_billing', null, 'left')
|
| 54 |
+
->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
|
| 55 |
+
->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
|
| 56 |
+
->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left')
|
| 57 |
+
->joinAttribute('shipping_firstname', 'customer_address/firstname', 'default_shipping', null, 'left')
|
| 58 |
+
->joinAttribute('shipping_lastname', 'customer_address/lastname', 'default_shipping', null, 'left')
|
| 59 |
+
->joinAttribute('shipping_postcode', 'customer_address/postcode', 'default_shipping', null, 'left')
|
| 60 |
+
->joinAttribute('shipping_city', 'customer_address/city', 'default_shipping', null, 'left')
|
| 61 |
+
->joinAttribute('shipping_street', 'customer_address/street', 'default_shipping', null, 'left')
|
| 62 |
+
->joinAttribute('shipping_telephone', 'customer_address/telephone', 'default_shipping', null, 'left')
|
| 63 |
+
->joinAttribute('shipping_region', 'customer_address/region', 'default_shipping', null, 'left')
|
| 64 |
+
->joinAttribute('shipping_country_id', 'customer_address/country_id', 'default_shipping', null, 'left')
|
| 65 |
+
;
|
| 66 |
+
$customerCollection->getSelect()->order('entity_id DESC');
|
| 67 |
+
return $customerCollection;
|
| 68 |
+
}
|
| 69 |
+
}
|
app/code/local/AW/Onpulse/Model/Aggregator/Components/Order.php
CHANGED
|
@@ -1,40 +1,115 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
class AW_Onpulse_Model_Aggregator_Components_Order extends AW_Onpulse_Model_Aggregator_Component
|
| 4 |
-
{
|
| 5 |
-
const
|
| 6 |
-
|
| 7 |
-
public function
|
| 8 |
-
{
|
| 9 |
-
$collection = Mage::getResourceModel('sales/order_collection')
|
| 10 |
-
->addAttributeToSelect('*')
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
$
|
| 37 |
-
|
| 38 |
-
$aggregator->setData('orders', $orderCollection->load());
|
| 39 |
-
}
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class AW_Onpulse_Model_Aggregator_Components_Order extends AW_Onpulse_Model_Aggregator_Component
|
| 4 |
+
{
|
| 5 |
+
const COUNT_ORDERS = 30;
|
| 6 |
+
|
| 7 |
+
public function getCollectionForOldMagento()
|
| 8 |
+
{
|
| 9 |
+
$collection = Mage::getResourceModel('sales/order_collection')
|
| 10 |
+
->addAttributeToSelect('*')
|
| 11 |
+
;
|
| 12 |
+
$collection = $this->_addAddressFields($collection);
|
| 13 |
+
if (!method_exists(get_class($collection), 'addExpressionFieldToSelect')) {
|
| 14 |
+
$collection
|
| 15 |
+
->getSelect()
|
| 16 |
+
->columns(array('billing_name' => 'CONCAT(billing_o_a.firstname, " ",billing_o_a.lastname)'))
|
| 17 |
+
->columns(array('shipping_name' => 'CONCAT(shipping_o_a.firstname, " ",shipping_o_a.lastname)'))
|
| 18 |
+
;
|
| 19 |
+
} else {
|
| 20 |
+
$collection
|
| 21 |
+
->_addExpressionFieldToSelect('billing_name',
|
| 22 |
+
'CONCAT({{billing_firstname}}, " ", {{billing_lastname}})',
|
| 23 |
+
array('billing_firstname', 'billing_lastname')
|
| 24 |
+
)
|
| 25 |
+
->_addExpressionFieldToSelect('shipping_name',
|
| 26 |
+
'CONCAT({{shipping_firstname}}, " ", {{shipping_lastname}})',
|
| 27 |
+
array('shipping_firstname', 'shipping_lastname')
|
| 28 |
+
)
|
| 29 |
+
;
|
| 30 |
+
}
|
| 31 |
+
return $collection;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
public function pushData($event = null)
|
| 35 |
+
{
|
| 36 |
+
$orderCollection = $this->_getOrderCollection();
|
| 37 |
+
$aggregator = $event->getEvent()->getAggregator();
|
| 38 |
+
$aggregator->setData('orders', $orderCollection->load());
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
public function pushSearchedData($aggregator, $query)
|
| 42 |
+
{
|
| 43 |
+
/** @var Mage_Sales_Model_Mysql4_Order_Collection $orderCollection */
|
| 44 |
+
$orderCollection = $this->_getOrderCollection();
|
| 45 |
+
|
| 46 |
+
if (strpos($query, '/') !== FALSE) {
|
| 47 |
+
$date = new Zend_Date($query, 'dd/MM/YYYY');
|
| 48 |
+
$orderCollection->addAttributeToSearchFilter(
|
| 49 |
+
'created_at', array('like' => $date->toString('YYYY-MM-dd') . '%')
|
| 50 |
+
);
|
| 51 |
+
} else if (strpos($query, '#') !== FALSE) {
|
| 52 |
+
$orderCollection->addAttributeToSearchFilter(
|
| 53 |
+
'increment_id', array('like' => str_replace('#', '', $query) . '%')
|
| 54 |
+
);
|
| 55 |
+
} else if (is_numeric($query) !== FALSE) {
|
| 56 |
+
$orderCollection->addAttributeToSearchFilter('increment_id', array('like' => '%' . $query . '%'));
|
| 57 |
+
} else if (strpos($query, '@') !== FALSE) {
|
| 58 |
+
$orderCollection->addAttributeToSearchFilter('customer_email', array('like' => '%' . $query . '%'));
|
| 59 |
+
} else {
|
| 60 |
+
$orderCollection
|
| 61 |
+
->addFieldToSearchFilter('customer_firstname', array('like' => '%' . $query . '%'))
|
| 62 |
+
->addFieldToSearchFilter('customer_lastname', array('like' => '%' . $query . '%'));
|
| 63 |
+
;
|
| 64 |
+
}
|
| 65 |
+
$aggregator->setData('orders', $orderCollection->load());
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
protected function _getOrderCollection()
|
| 69 |
+
{
|
| 70 |
+
if (version_compare(Mage::getVersion(), '1.4.1.0', '<=')) {
|
| 71 |
+
$orderCollection = $this->getCollectionForOldMagento();
|
| 72 |
+
$orderCollection
|
| 73 |
+
->addOrder('entity_id', 'DESC')
|
| 74 |
+
->setPageSize(self::COUNT_ORDERS);
|
| 75 |
+
} else {
|
| 76 |
+
$orderCollection = Mage::getModel('sales/order')->getCollection()
|
| 77 |
+
->addAddressFields()
|
| 78 |
+
->addAttributeToSelect('*')
|
| 79 |
+
->addOrder('entity_id', 'DESC')
|
| 80 |
+
->setPageSize(self::COUNT_ORDERS);
|
| 81 |
+
}
|
| 82 |
+
return $orderCollection;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
protected function _addAddressFields($collection)
|
| 86 |
+
{
|
| 87 |
+
$billingAliasName = 'billing_o_a';
|
| 88 |
+
$shippingAliasName = 'shipping_o_a';
|
| 89 |
+
$joinTable = $collection->getTable('sales/order_address');
|
| 90 |
+
$collection
|
| 91 |
+
->getSelect()
|
| 92 |
+
->joinLeft(
|
| 93 |
+
array($billingAliasName => $joinTable),
|
| 94 |
+
"(main_table.entity_id = $billingAliasName.parent_id AND $billingAliasName.address_type = 'billing')",
|
| 95 |
+
array(
|
| 96 |
+
$billingAliasName . '.firstname',
|
| 97 |
+
$billingAliasName . '.lastname',
|
| 98 |
+
$billingAliasName . '.telephone',
|
| 99 |
+
$billingAliasName . '.postcode'
|
| 100 |
+
)
|
| 101 |
+
)
|
| 102 |
+
->joinLeft(
|
| 103 |
+
array($shippingAliasName => $joinTable),
|
| 104 |
+
"(main_table.entity_id = $shippingAliasName.parent_id AND $shippingAliasName.address_type = 'shipping')",
|
| 105 |
+
array(
|
| 106 |
+
$shippingAliasName . '.firstname',
|
| 107 |
+
$shippingAliasName . '.lastname',
|
| 108 |
+
$shippingAliasName . '.telephone',
|
| 109 |
+
$shippingAliasName . '.postcode'
|
| 110 |
+
)
|
| 111 |
+
)
|
| 112 |
+
;
|
| 113 |
+
return $collection;
|
| 114 |
+
}
|
| 115 |
+
}
|
app/code/local/AW/Onpulse/Model/Aggregator/Components/Statistics.php
CHANGED
|
@@ -1,300 +1,609 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
class AW_Onpulse_Model_Aggregator_Components_Statistics extends AW_Onpulse_Model_Aggregator_Component
|
| 4 |
-
{
|
| 5 |
-
/**
|
| 6 |
-
* How much last registered customers is to display
|
| 7 |
-
*/
|
| 8 |
-
const COUNT_CUSTOMERS = 5;
|
| 9 |
-
|
| 10 |
-
const MYSQL_DATE_FORMAT = 'Y-d-m';
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
$
|
| 20 |
-
$now
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
$dateObj->
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
$dateObj
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
$
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
$
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
$
|
| 102 |
-
$
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
$
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
$
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
$
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
$
|
| 233 |
-
|
| 234 |
-
$
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
$
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
$
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class AW_Onpulse_Model_Aggregator_Components_Statistics extends AW_Onpulse_Model_Aggregator_Component
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* How much last registered customers is to display
|
| 7 |
+
*/
|
| 8 |
+
const COUNT_CUSTOMERS = 5;
|
| 9 |
+
|
| 10 |
+
const MYSQL_DATE_FORMAT = 'Y-d-m';
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* @return Zend_Date
|
| 14 |
+
*/
|
| 15 |
+
private function _getShiftedDate()
|
| 16 |
+
{
|
| 17 |
+
$timeShift = Mage::app()->getLocale()->date()->get(Zend_Date::TIMEZONE_SECS);
|
| 18 |
+
$now = date(self::MYSQL_DATE_FORMAT, time() + $timeShift);
|
| 19 |
+
$now = new Zend_Date($now);
|
| 20 |
+
return $now;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
* @return Zend_Date
|
| 25 |
+
*/
|
| 26 |
+
private function _getCurrentDate()
|
| 27 |
+
{
|
| 28 |
+
$now = Mage::app()->getLocale()->date();
|
| 29 |
+
$dateObj = Mage::app()->getLocale()->date(null, null, Mage::app()->getLocale()->getDefaultLocale(), false);
|
| 30 |
+
|
| 31 |
+
//set default timezone for store (admin)
|
| 32 |
+
$dateObj->setTimezone(Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE));
|
| 33 |
+
|
| 34 |
+
//set begining of day
|
| 35 |
+
$dateObj->setHour(00);
|
| 36 |
+
$dateObj->setMinute(00);
|
| 37 |
+
$dateObj->setSecond(00);
|
| 38 |
+
|
| 39 |
+
//set date with applying timezone of store
|
| 40 |
+
$dateObj->set($now, Zend_Date::DATE_SHORT, Mage::app()->getLocale()->getDefaultLocale());
|
| 41 |
+
|
| 42 |
+
//convert store date to default date in UTC timezone without DST
|
| 43 |
+
$dateObj->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE);
|
| 44 |
+
|
| 45 |
+
return $dateObj;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* @param $event
|
| 50 |
+
*/
|
| 51 |
+
public function pushData($event = null)
|
| 52 |
+
{
|
| 53 |
+
$aggregator = $event->getEvent()->getAggregator();
|
| 54 |
+
$dashboard = array();
|
| 55 |
+
$today = $this->_getCurrentDate();
|
| 56 |
+
|
| 57 |
+
//Load sales revenue
|
| 58 |
+
$dashboard['sales'] = $this->_getSales(clone $today);
|
| 59 |
+
|
| 60 |
+
//Load last orders
|
| 61 |
+
$dashboard['orders'] = $this->_getOrders(clone $today);
|
| 62 |
+
|
| 63 |
+
//Load last customer registrations
|
| 64 |
+
$dashboard['customers'] = $this->_getCustomers(clone $today);
|
| 65 |
+
|
| 66 |
+
//Load last orders
|
| 67 |
+
$dashboard['last_orders'] = $this->_getLastOrders(clone $today);
|
| 68 |
+
|
| 69 |
+
//Load best selling products
|
| 70 |
+
$dashboard['bestsellers'] = $this->_getBestsellers(clone $today);
|
| 71 |
+
|
| 72 |
+
//Load sales grouped by country
|
| 73 |
+
$dashboard['sales_by_country'] = $this->_getSalesByCountry(clone $today);
|
| 74 |
+
|
| 75 |
+
//Load items per order revenue
|
| 76 |
+
$dashboard['items_per_order'] = $this->_getItemsPerOrder(clone $today);
|
| 77 |
+
|
| 78 |
+
//Load average order value
|
| 79 |
+
$dashboard['average_order_value'] = $this->_getAverageOrderValue(clone $today);
|
| 80 |
+
|
| 81 |
+
//Load signups
|
| 82 |
+
$dashboard['signups'] = $this->_getSignups(clone $today);
|
| 83 |
+
|
| 84 |
+
$aggregator->setData('dashboard', $dashboard);
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
/**
|
| 88 |
+
* @param Zend_Date $date
|
| 89 |
+
*
|
| 90 |
+
* @return array
|
| 91 |
+
*/
|
| 92 |
+
private function _getByers(Zend_Date $date) {
|
| 93 |
+
/** @var $todayRegistered Mage_Customer_Model_Resource_Customer_Collection */
|
| 94 |
+
$todayRegistered = Mage::getModel('customer/customer')->getCollection();
|
| 95 |
+
$todayRegistered->addAttributeToFilter('created_at', array(
|
| 96 |
+
'from' => $date->toString(Varien_Date::DATETIME_INTERNAL_FORMAT),
|
| 97 |
+
'to' => $date->addDay(1)->toString(Varien_Date::DATETIME_INTERNAL_FORMAT)
|
| 98 |
+
));
|
| 99 |
+
$todayRegistered->addAttributeToSelect('*');
|
| 100 |
+
|
| 101 |
+
$date->addDay(-1);
|
| 102 |
+
/* @var $collection Mage_Reports_Model_Mysql4_Order_Collection */
|
| 103 |
+
$customerArray = array();
|
| 104 |
+
$todayOrders = Mage::getModel('sales/order')->getCollection();
|
| 105 |
+
$todayOrders->addAttributeToFilter('created_at', array(
|
| 106 |
+
'from' => $date->toString(Varien_Date::DATETIME_INTERNAL_FORMAT),
|
| 107 |
+
'to' => $date->addDay(1)->toString(Varien_Date::DATETIME_INTERNAL_FORMAT)
|
| 108 |
+
));
|
| 109 |
+
foreach ($todayOrders as $order) {
|
| 110 |
+
if ($order->getCustomerId()){
|
| 111 |
+
$customerArray[] = $order->getCustomerId();
|
| 112 |
+
}
|
| 113 |
+
}
|
| 114 |
+
$customerArray = array_unique($customerArray);
|
| 115 |
+
$buyers = count($customerArray);
|
| 116 |
+
return array(
|
| 117 |
+
'buyers'=>$buyers,
|
| 118 |
+
'registered'=>$todayRegistered,
|
| 119 |
+
);
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
/**
|
| 123 |
+
* @param Zend_Date $date
|
| 124 |
+
*
|
| 125 |
+
* @return array
|
| 126 |
+
*/
|
| 127 |
+
private function _getCustomers(Zend_Date $date)
|
| 128 |
+
{
|
| 129 |
+
//collect online visitors
|
| 130 |
+
$online = Mage::getModel('log/visitor_online')
|
| 131 |
+
->prepare()
|
| 132 |
+
->getCollection()->addFieldToFilter('remote_addr',array('neq'=>Mage::helper('core/http')->getRemoteAddr(true)))->getSize();
|
| 133 |
+
$todayCustomers = $this->_getByers($date);
|
| 134 |
+
$yesterdayCustomers = $this->_getByers($date->addDay(-2));
|
| 135 |
+
|
| 136 |
+
return array('online_visistors' => $online, 'today_customers' => $todayCustomers, 'yesterday_customers' => $yesterdayCustomers);
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
/**
|
| 140 |
+
* @param Zend_Date $date
|
| 141 |
+
*
|
| 142 |
+
* @return array
|
| 143 |
+
*/
|
| 144 |
+
private function _getBestsellers(Zend_Date $date)
|
| 145 |
+
{
|
| 146 |
+
$orderstatus = explode(',', Mage::getStoreConfig('awonpulse/general/ordersstatus',Mage::app()->getDefaultStoreView()->getId()));
|
| 147 |
+
if (count($orderstatus)==0){
|
| 148 |
+
$orderstatus = array(Mage_Sales_Model_Order::STATE_COMPLETE);
|
| 149 |
+
}
|
| 150 |
+
//Collect all orders for last N days
|
| 151 |
+
/** @var $orders Mage_Sales_Model_Resource_Order_Collection */
|
| 152 |
+
$orders = Mage::getResourceModel('sales/order_collection');
|
| 153 |
+
$orders->addAttributeToFilter('created_at', array(
|
| 154 |
+
'from' => $date->addDay(-15)->toString(Varien_Date::DATETIME_INTERNAL_FORMAT)
|
| 155 |
+
))->addAttributeToFilter('status', array('in' => $orderstatus));
|
| 156 |
+
|
| 157 |
+
$orderIds = Mage::getSingleton('core/resource')->getConnection('sales_read')->query($orders->getSelect()->resetJoinLeft())->fetchAll(PDO::FETCH_COLUMN,0);
|
| 158 |
+
unset($orders);
|
| 159 |
+
|
| 160 |
+
$orders = Mage::getModel('sales/order_item')->getCollection()
|
| 161 |
+
->addFieldToFilter('order_id',array('in'=>$orderIds))
|
| 162 |
+
->addFieldToFilter('parent_item_id', array('null'=> true));
|
| 163 |
+
$orders = Mage::getSingleton('core/resource')->getConnection('sales_read')->query($orders->getSelect()->resetJoinLeft())->fetchAll();
|
| 164 |
+
|
| 165 |
+
$items = array();
|
| 166 |
+
|
| 167 |
+
/** @var $order Mage_Sales_Model_Order */
|
| 168 |
+
foreach ($orders as $orderItem) {
|
| 169 |
+
$key = array_key_exists($orderItem['product_id'], $items);
|
| 170 |
+
if ($key === false) {
|
| 171 |
+
$items[$orderItem['product_id']] = array(
|
| 172 |
+
'name' => Mage::helper('awonpulse')->escapeHtml($orderItem['name']),
|
| 173 |
+
'qty' => 0,
|
| 174 |
+
'amount' => 0
|
| 175 |
+
);
|
| 176 |
+
}
|
| 177 |
+
$items[$orderItem['product_id']]['qty'] += $orderItem['qty_ordered'];
|
| 178 |
+
$items[$orderItem['product_id']]['amount'] += Mage::helper('awonpulse')->getPriceFormat(
|
| 179 |
+
$orderItem['base_row_total'] - $orderItem['base_discount_invoiced']
|
| 180 |
+
);
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
if(count($items) > 0) {
|
| 184 |
+
foreach ($items as $id => $row) {
|
| 185 |
+
$name[$id] = $row['name'];
|
| 186 |
+
$qty[$id] = $row['qty'];
|
| 187 |
+
}
|
| 188 |
+
array_multisort($qty, SORT_DESC, $name, SORT_ASC, $items);
|
| 189 |
+
}
|
| 190 |
+
return $items;
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
/**
|
| 195 |
+
* @param Zend_Date $date
|
| 196 |
+
*
|
| 197 |
+
* @return array
|
| 198 |
+
*/
|
| 199 |
+
private function _getOrders(Zend_Date $date)
|
| 200 |
+
{
|
| 201 |
+
|
| 202 |
+
//collect yesterday orders count
|
| 203 |
+
$ordersstatus = Mage::getStoreConfig('awonpulse/general/ordersstatus',Mage::app()->getDefaultStoreView()->getId());
|
| 204 |
+
$ordersstatus = explode(',', $ordersstatus);
|
| 205 |
+
if (count($ordersstatus)==0){
|
| 206 |
+
$ordersstatus = array(Mage_Sales_Model_Order::STATE_COMPLETE);
|
| 207 |
+
}
|
| 208 |
+
/** @var $yesterdayOrders Mage_Sales_Model_Resource_Order_Collection */
|
| 209 |
+
$yesterdayOrders = Mage::getResourceModel('sales/order_collection');
|
| 210 |
+
|
| 211 |
+
$yesterdayOrders->addAttributeToFilter('created_at', array(
|
| 212 |
+
'from' => $date->addDay(-1)->toString(Varien_Date::DATETIME_INTERNAL_FORMAT),
|
| 213 |
+
'to'=>$date->addDay(1)->toString(Varien_Date::DATETIME_INTERNAL_FORMAT)
|
| 214 |
+
))->addAttributeToSelect('*')
|
| 215 |
+
->addAttributeToFilter('status', array('in' => $ordersstatus));
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
//collect today orders count
|
| 219 |
+
|
| 220 |
+
/** @var $yesterdayOrders Mage_Sales_Model_Resource_Order_Collection */
|
| 221 |
+
$todayOrders = Mage::getResourceModel('sales/order_collection');
|
| 222 |
+
$todayOrders->addAttributeToFilter('created_at', array('from' => $date->toString(Varien_Date::DATETIME_INTERNAL_FORMAT)))
|
| 223 |
+
->addAttributeToSelect('*')
|
| 224 |
+
->addAttributeToFilter('status', array('in' => $ordersstatus));
|
| 225 |
+
|
| 226 |
+
//collect max, min, average orders
|
| 227 |
+
$order = array();
|
| 228 |
+
if ($todayOrders->getSize()) {
|
| 229 |
+
$order['max'] = 0;
|
| 230 |
+
$order['min'] = 999999999999999;
|
| 231 |
+
$order['average'] = 0;
|
| 232 |
+
$ordersSum = 0;
|
| 233 |
+
|
| 234 |
+
foreach ($todayOrders as $item) {
|
| 235 |
+
|
| 236 |
+
if ($item->getBaseGrandTotal() > $order['max']) {
|
| 237 |
+
$order['max'] = Mage::helper('awonpulse')->getPriceFormat($item->getBaseGrandTotal());
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
if ($item->getBaseGrandTotal() < $order['min']) {
|
| 241 |
+
$order['min'] = Mage::helper('awonpulse')->getPriceFormat($item->getBaseGrandTotal());
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
$ordersSum += Mage::helper('awonpulse')->getPriceFormat($item->getBaseGrandTotal());
|
| 245 |
+
|
| 246 |
+
}
|
| 247 |
+
$order['average'] = Mage::helper('awonpulse')->getPriceFormat($ordersSum / $todayOrders->getSize());
|
| 248 |
+
} else {
|
| 249 |
+
$order['max'] = 0;
|
| 250 |
+
$order['min'] = 0;
|
| 251 |
+
$order['average'] = 0;
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
return array('yesterday_orders' => $yesterdayOrders->getSize(), 'today_orders' => $todayOrders->getSize(), 'orders_totals' => $order);
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
/**
|
| 258 |
+
* @param Zend_Date $date
|
| 259 |
+
*
|
| 260 |
+
* @return array
|
| 261 |
+
*/
|
| 262 |
+
private function _getSales(Zend_Date $date)
|
| 263 |
+
{
|
| 264 |
+
$orderStatus = Mage::getStoreConfig('awonpulse/general/ordersstatus', Mage::app()->getDefaultStoreView()->getId());
|
| 265 |
+
$orderStatus = explode(',', $orderStatus);
|
| 266 |
+
if (count($orderStatus)==0){
|
| 267 |
+
$orderStatus = array(Mage_Sales_Model_Order::STATE_COMPLETE);
|
| 268 |
+
}
|
| 269 |
+
$salesStatisticUnit = Mage::getStoreConfig(
|
| 270 |
+
'awonpulse/general/show_sales_statistics_as', Mage::app()->getDefaultStoreView()->getId()
|
| 271 |
+
);
|
| 272 |
+
$shiftedDate = $this->_getShiftedDate();
|
| 273 |
+
$date->addDay(1);
|
| 274 |
+
$shiftedDate->addDay(1);
|
| 275 |
+
$copyDate = clone $date;
|
| 276 |
+
$revenue = array();
|
| 277 |
+
for ($i = 0; $i < 15; $i++) {
|
| 278 |
+
/** @var $yesterdayOrders Mage_Sales_Model_Resource_Order_Collection */
|
| 279 |
+
$orders = Mage::getModel('sales/order')->getCollection();
|
| 280 |
+
$orders->addAttributeToFilter('created_at',
|
| 281 |
+
array(
|
| 282 |
+
'from' => $date->addDay(-1)->toString(Varien_Date::DATETIME_INTERNAL_FORMAT),
|
| 283 |
+
'to' => $date->addDay(1)->toString(Varien_Date::DATETIME_INTERNAL_FORMAT)
|
| 284 |
+
)
|
| 285 |
+
)->addAttributeToSelect('*')
|
| 286 |
+
->addAttributeToFilter('status', array('in' => $orderStatus))
|
| 287 |
+
;
|
| 288 |
+
$date->addDay(-1);
|
| 289 |
+
$shiftedDate->addDay(-1);
|
| 290 |
+
$revenue[$i]['revenue'] = 0;
|
| 291 |
+
$revenue[$i]['date'] = $shiftedDate->toString(Varien_Date::DATE_INTERNAL_FORMAT);
|
| 292 |
+
if ($orders->getSize() > 0) {
|
| 293 |
+
foreach ($orders as $order) {
|
| 294 |
+
if ($salesStatisticUnit == AW_Onpulse_Model_Source_ProfitRevenue::PROFIT_VALUE) {
|
| 295 |
+
$baseTotalCost = 0;
|
| 296 |
+
foreach ($order->getItemsCollection() as $item) {
|
| 297 |
+
$baseTotalCost += $item->getBaseCost();
|
| 298 |
+
}
|
| 299 |
+
$revenue[$i]['revenue'] += $order->getBaseSubtotal() - $baseTotalCost;
|
| 300 |
+
} else {
|
| 301 |
+
$revenue[$i]['revenue'] += $order->getBaseGrandTotal();
|
| 302 |
+
}
|
| 303 |
+
}
|
| 304 |
+
}
|
| 305 |
+
}
|
| 306 |
+
/** @var $copyDate Zend_Date */
|
| 307 |
+
$daysFrom1st = $copyDate->get(Zend_Date::DAY);
|
| 308 |
+
$startDate = clone $copyDate;
|
| 309 |
+
$orders = Mage::getModel('sales/order')->getCollection();
|
| 310 |
+
$orders->addAttributeToFilter('created_at', array('from' => $startDate->addDay(-($daysFrom1st))->toString(Varien_Date::DATETIME_INTERNAL_FORMAT)))
|
| 311 |
+
->addAttributeToSelect('*')
|
| 312 |
+
->addAttributeToFilter('status', array('in' => $orderStatus));
|
| 313 |
+
$thisMonthSoFar = array();
|
| 314 |
+
foreach($orders as $order){
|
| 315 |
+
if ($salesStatisticUnit == AW_Onpulse_Model_Source_ProfitRevenue::PROFIT_VALUE) {
|
| 316 |
+
$baseTotalCost = 0;
|
| 317 |
+
foreach ($order->getItemsCollection() as $item) {
|
| 318 |
+
$baseTotalCost += $item->getBaseCost();
|
| 319 |
+
}
|
| 320 |
+
$thisMonthSoFar[] = $order->getBaseSubtotal() - $baseTotalCost;
|
| 321 |
+
} else {
|
| 322 |
+
$thisMonthSoFar[] = $order->getBaseGrandTotal();
|
| 323 |
+
}
|
| 324 |
+
}
|
| 325 |
+
$thisMonthAvg = array_sum($thisMonthSoFar) /($daysFrom1st);
|
| 326 |
+
|
| 327 |
+
$weekendConfigStr = Mage::getStoreConfig('general/locale/weekend', Mage::app()->getDefaultStoreView()->getId());
|
| 328 |
+
$weekdayConfig = array();
|
| 329 |
+
if (strlen($weekendConfigStr) > 0) {
|
| 330 |
+
$weekdayConfig = explode(',', $weekendConfigStr);
|
| 331 |
+
}
|
| 332 |
+
$workDayList = array();
|
| 333 |
+
$weekendDayList = array();
|
| 334 |
+
$workDayLeft = 0;
|
| 335 |
+
$weekendDayLeft = 0;
|
| 336 |
+
$copyDate->subDay(intval($date->get(Zend_Date::DAY_SHORT)) - 1);
|
| 337 |
+
for ($i = 0; $i < $copyDate->get(Zend_Date::MONTH_DAYS); $i++) {
|
| 338 |
+
$weekdayDigit = intval($date->get(Zend_Date::WEEKDAY_DIGIT));//from Sunday to Saturday -> from 0 to 6;
|
| 339 |
+
$isWeekday = in_array($weekdayDigit, $weekdayConfig);
|
| 340 |
+
if (array_key_exists($i, $thisMonthSoFar)) {
|
| 341 |
+
if ($isWeekday) {
|
| 342 |
+
$weekendDayList[] = $thisMonthSoFar[$i];
|
| 343 |
+
} else {
|
| 344 |
+
$workDayList[] = $thisMonthSoFar[$i];
|
| 345 |
+
}
|
| 346 |
+
} else {
|
| 347 |
+
$isWeekday?$weekendDayLeft++:$workDayLeft++;
|
| 348 |
+
}
|
| 349 |
+
$copyDate->addDay(1);
|
| 350 |
+
}
|
| 351 |
+
$workMedian = $this->_getMedianFromArray($workDayList);
|
| 352 |
+
$weekendMedian = $this->_getMedianFromArray($weekendDayList);
|
| 353 |
+
$thisMonthForecast = array_sum($thisMonthSoFar) + $workMedian * $workDayLeft + $weekendMedian * $workDayLeft;
|
| 354 |
+
|
| 355 |
+
$thisMonth = array();
|
| 356 |
+
$thisMonth['thisMonthSoFar'] = Mage::helper('awonpulse')->getPriceFormat(array_sum($thisMonthSoFar));
|
| 357 |
+
$thisMonth['thisMonthAvg'] = Mage::helper('awonpulse')->getPriceFormat($thisMonthAvg);
|
| 358 |
+
$thisMonth['thisMonthForecast'] = Mage::helper('awonpulse')->getPriceFormat($thisMonthForecast);
|
| 359 |
+
|
| 360 |
+
return array('revenue'=>$revenue, 'thisMonth'=>$thisMonth);
|
| 361 |
+
}
|
| 362 |
+
|
| 363 |
+
/**
|
| 364 |
+
* @param Zend_Date $date
|
| 365 |
+
*
|
| 366 |
+
* @return array
|
| 367 |
+
*/
|
| 368 |
+
private function _getLastOrders(Zend_Date $date)
|
| 369 |
+
{
|
| 370 |
+
$orderCollection = Mage::getModel('sales/order')->getCollection()
|
| 371 |
+
->addAddressFields()
|
| 372 |
+
->addAttributeToSelect('*')
|
| 373 |
+
->addOrder('entity_id', 'DESC')
|
| 374 |
+
->setPageSize(3)
|
| 375 |
+
;
|
| 376 |
+
$processedOrders = array();
|
| 377 |
+
foreach ($orderCollection as $order) {
|
| 378 |
+
$processedOrders[] = Mage::helper('awonpulse')->processOrderToArray($order);
|
| 379 |
+
}
|
| 380 |
+
return $processedOrders;
|
| 381 |
+
}
|
| 382 |
+
|
| 383 |
+
/**
|
| 384 |
+
* @param Zend_Date $date
|
| 385 |
+
*
|
| 386 |
+
* @return array
|
| 387 |
+
*/
|
| 388 |
+
private function _getItemsPerOrder(Zend_Date $date)
|
| 389 |
+
{
|
| 390 |
+
$orderStatus = Mage::getStoreConfig(
|
| 391 |
+
'awonpulse/general/ordersstatus', Mage::app()->getDefaultStoreView()->getId()
|
| 392 |
+
);
|
| 393 |
+
$orderStatus = explode(',', $orderStatus);
|
| 394 |
+
if (count($orderStatus)==0){
|
| 395 |
+
$orderStatus = array(Mage_Sales_Model_Order::STATE_COMPLETE);
|
| 396 |
+
}
|
| 397 |
+
$shiftedDate = $this->_getShiftedDate();
|
| 398 |
+
$date->addDay(1);
|
| 399 |
+
$shiftedDate->addDay(1);
|
| 400 |
+
$copyDate = clone $date;
|
| 401 |
+
$numberDaysInMonth = $copyDate->get(Zend_Date::MONTH_DAYS);
|
| 402 |
+
$revenue = array();
|
| 403 |
+
$thisMonthAvgList = array();
|
| 404 |
+
for ($i = 0; $i < 15; $i++) {
|
| 405 |
+
/** @var $yesterdayOrders Mage_Sales_Model_Resource_Order_Collection */
|
| 406 |
+
$orders = Mage::getModel('sales/order')->getCollection();
|
| 407 |
+
$orders->addAttributeToFilter(
|
| 408 |
+
'created_at',
|
| 409 |
+
array(
|
| 410 |
+
'from' => $date->addDay(-1)->toString(Varien_Date::DATETIME_INTERNAL_FORMAT),
|
| 411 |
+
'to' => $date->addDay(1)->toString(Varien_Date::DATETIME_INTERNAL_FORMAT)
|
| 412 |
+
)
|
| 413 |
+
)->addAttributeToSelect('*')
|
| 414 |
+
->addAttributeToFilter('status', array('in' => $orderStatus))
|
| 415 |
+
;
|
| 416 |
+
$date->addDay(-1);
|
| 417 |
+
$shiftedDate->addDay(-1);
|
| 418 |
+
$revenue[$i]['revenue'] = 0;
|
| 419 |
+
$revenue[$i]['date'] = $shiftedDate->toString(Varien_Date::DATE_INTERNAL_FORMAT);
|
| 420 |
+
foreach($orders as $order){
|
| 421 |
+
$revenue[$i]['revenue'] += $order->getTotalItemCount();
|
| 422 |
+
}
|
| 423 |
+
$thisMonthAvgList[] = $revenue[$i]['revenue'];
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
$thisMonthAvg = 0;
|
| 427 |
+
if (count($thisMonthAvgList) > 0) {
|
| 428 |
+
$thisMonthAvg = array_sum($thisMonthAvgList) / count($thisMonthAvgList);
|
| 429 |
+
}
|
| 430 |
+
$thisMonth = array();
|
| 431 |
+
$thisMonth['thisMonthAvg'] = Mage::helper('awonpulse')->getPriceFormat($thisMonthAvg);
|
| 432 |
+
return array('revenue' => $revenue, 'thisMonth' => $thisMonth);
|
| 433 |
+
}
|
| 434 |
+
|
| 435 |
+
/**
|
| 436 |
+
* @param Zend_Date $date
|
| 437 |
+
*
|
| 438 |
+
* @return array
|
| 439 |
+
*/
|
| 440 |
+
private function _getAverageOrderValue(Zend_Date $date)
|
| 441 |
+
{
|
| 442 |
+
$orderStatus = Mage::getStoreConfig(
|
| 443 |
+
'awonpulse/general/ordersstatus', Mage::app()->getDefaultStoreView()->getId()
|
| 444 |
+
);
|
| 445 |
+
$orderStatus = explode(',', $orderStatus);
|
| 446 |
+
if (count($orderStatus)==0){
|
| 447 |
+
$orderStatus = array(Mage_Sales_Model_Order::STATE_COMPLETE);
|
| 448 |
+
}
|
| 449 |
+
$shiftedDate = $this->_getShiftedDate();
|
| 450 |
+
$date->addDay(1);
|
| 451 |
+
$shiftedDate->addDay(1);
|
| 452 |
+
$copyDate = clone $date;
|
| 453 |
+
$numberDaysInMonth = $copyDate->get(Zend_Date::MONTH_DAYS);
|
| 454 |
+
$revenue = array();
|
| 455 |
+
$thisMonthAvgList = array();
|
| 456 |
+
for ($i = 0; $i < 15; $i++) {
|
| 457 |
+
/** @var $yesterdayOrders Mage_Sales_Model_Resource_Order_Collection */
|
| 458 |
+
$orders = Mage::getModel('sales/order')->getCollection();
|
| 459 |
+
$orders->addAttributeToFilter(
|
| 460 |
+
'created_at',
|
| 461 |
+
array(
|
| 462 |
+
'from' => $date->addDay(-1)->toString(Varien_Date::DATETIME_INTERNAL_FORMAT),
|
| 463 |
+
'to' => $date->addDay(1)->toString(Varien_Date::DATETIME_INTERNAL_FORMAT)
|
| 464 |
+
)
|
| 465 |
+
)->addAttributeToSelect('*')
|
| 466 |
+
->addAttributeToFilter('status', array('in' => $orderStatus))
|
| 467 |
+
;
|
| 468 |
+
$date->addDay(-1);
|
| 469 |
+
$shiftedDate->addDay(-1);
|
| 470 |
+
$revenue[$i]['revenue']=0;
|
| 471 |
+
$revenue[$i]['date']=$shiftedDate->toString(Varien_Date::DATE_INTERNAL_FORMAT);
|
| 472 |
+
if($orders->getSize() > 0) {
|
| 473 |
+
foreach($orders as $order){
|
| 474 |
+
$revenue[$i]['revenue'] += $order->getBaseGrandTotal();
|
| 475 |
+
}
|
| 476 |
+
$revenue[$i]['revenue'] /= $orders->getSize();
|
| 477 |
+
}
|
| 478 |
+
$thisMonthAvgList[] = $revenue[$i]['revenue'];
|
| 479 |
+
}
|
| 480 |
+
|
| 481 |
+
$thisMonthAvg = 0;
|
| 482 |
+
if (count($thisMonthAvgList) > 0) {
|
| 483 |
+
$thisMonthAvg = array_sum($thisMonthAvgList) / count($thisMonthAvgList);
|
| 484 |
+
}
|
| 485 |
+
$thisMonth = array();
|
| 486 |
+
$thisMonth['thisMonthAvg'] = Mage::helper('awonpulse')->getPriceFormat($thisMonthAvg);
|
| 487 |
+
return array('revenue' => $revenue, 'thisMonth' => $thisMonth);
|
| 488 |
+
}
|
| 489 |
+
|
| 490 |
+
/**
|
| 491 |
+
* @param Zend_Date $date
|
| 492 |
+
*
|
| 493 |
+
* @return array
|
| 494 |
+
*/
|
| 495 |
+
private function _getSalesByCountry(Zend_Date $date)
|
| 496 |
+
{
|
| 497 |
+
$orderStatus = explode(
|
| 498 |
+
',', Mage::getStoreConfig('awonpulse/general/ordersstatus', Mage::app()->getDefaultStoreView()->getId())
|
| 499 |
+
);
|
| 500 |
+
if (count($orderStatus) == 0) {
|
| 501 |
+
$orderStatus = array(Mage_Sales_Model_Order::STATE_COMPLETE);
|
| 502 |
+
}
|
| 503 |
+
/** @var $orders Mage_Sales_Model_Resource_Order_Collection */
|
| 504 |
+
$orderCollection = Mage::getResourceModel('sales/order_collection');
|
| 505 |
+
$orderCollection
|
| 506 |
+
->addAttributeToFilter(
|
| 507 |
+
'created_at', array('from' => $date->addDay(-15)->toString(Varien_Date::DATETIME_INTERNAL_FORMAT))
|
| 508 |
+
)
|
| 509 |
+
->addAttributeToFilter('status', array('in' => $orderStatus))
|
| 510 |
+
;
|
| 511 |
+
//join billing address to order
|
| 512 |
+
$billingAliasName = 'billing_o_a';
|
| 513 |
+
$orderCollection->getSelect()->joinLeft(
|
| 514 |
+
array($billingAliasName => $orderCollection->getTable('sales/order_address')),
|
| 515 |
+
"(main_table.entity_id = {$billingAliasName}.parent_id"
|
| 516 |
+
. " AND {$billingAliasName}.address_type = 'billing')",
|
| 517 |
+
array(
|
| 518 |
+
'country_id' => $billingAliasName . '.country_id',
|
| 519 |
+
)
|
| 520 |
+
);
|
| 521 |
+
|
| 522 |
+
$countryOptionArray = Mage::helper('directory')->getCountryCollection()->toOptionArray(false);
|
| 523 |
+
$countryOptionHash = array();
|
| 524 |
+
foreach ($countryOptionArray as $option) {
|
| 525 |
+
$countryOptionHash[$option['value']] = $option['label'];
|
| 526 |
+
}
|
| 527 |
+
$result = array();
|
| 528 |
+
foreach ($orderCollection as $order) {
|
| 529 |
+
/** @var $order Mage_Sales_Model_Order */
|
| 530 |
+
$countryCode = $order->getData('country_id');
|
| 531 |
+
$item = array(
|
| 532 |
+
'country_label' => $countryOptionHash[$countryCode],
|
| 533 |
+
'qty' => 1,
|
| 534 |
+
'amount' => Mage::helper('awonpulse')->getPriceFormat($order->getBaseGrandTotal())
|
| 535 |
+
);
|
| 536 |
+
if (array_key_exists($countryCode, $result)) {
|
| 537 |
+
$item['qty'] += $result[$countryCode]['qty'];
|
| 538 |
+
$item['amount'] += $result[$countryCode]['amount'];
|
| 539 |
+
}
|
| 540 |
+
$result[$countryCode] = $item;
|
| 541 |
+
}
|
| 542 |
+
|
| 543 |
+
if(count($result) > 0) {
|
| 544 |
+
$name = array();
|
| 545 |
+
$qty = array();
|
| 546 |
+
foreach ($result as $key => $row) {
|
| 547 |
+
$name[$key] = $row['country_label'];
|
| 548 |
+
$qty[$key] = $row['qty'];
|
| 549 |
+
}
|
| 550 |
+
array_multisort($qty, SORT_DESC, $name, SORT_ASC, $result);
|
| 551 |
+
}
|
| 552 |
+
return array_values($result);
|
| 553 |
+
}
|
| 554 |
+
|
| 555 |
+
/**
|
| 556 |
+
* @param Zend_Date $date
|
| 557 |
+
*
|
| 558 |
+
* @return array
|
| 559 |
+
*/
|
| 560 |
+
private function _getSignups(Zend_Date $date)
|
| 561 |
+
{
|
| 562 |
+
$shiftedDate = $this->_getShiftedDate();
|
| 563 |
+
$date->addDay(1);
|
| 564 |
+
$shiftedDate->addDay(1);
|
| 565 |
+
$copyDate = clone $date;
|
| 566 |
+
$numberDaysInMonth = $copyDate->get(Zend_Date::MONTH_DAYS);
|
| 567 |
+
$data = array();
|
| 568 |
+
$thisMonthAvgList = array();
|
| 569 |
+
for ($i = 0; $i < 15; $i++) {
|
| 570 |
+
$customers = Mage::getModel('customer/customer')->getCollection();
|
| 571 |
+
$customers->addAttributeToFilter(
|
| 572 |
+
'created_at',
|
| 573 |
+
array(
|
| 574 |
+
'from' => $date->addDay(-1)->toString(Varien_Date::DATETIME_INTERNAL_FORMAT),
|
| 575 |
+
'to' => $date->addDay(1)->toString(Varien_Date::DATETIME_INTERNAL_FORMAT)
|
| 576 |
+
)
|
| 577 |
+
)->addAttributeToSelect('*');
|
| 578 |
+
$date->addDay(-1);
|
| 579 |
+
$shiftedDate->addDay(-1);
|
| 580 |
+
$data[$i]['data'] = $customers->getSize();
|
| 581 |
+
$data[$i]['date'] = $shiftedDate->toString(Varien_Date::DATE_INTERNAL_FORMAT);
|
| 582 |
+
$thisMonthAvgList[] = $data[$i]['data'];
|
| 583 |
+
}
|
| 584 |
+
|
| 585 |
+
$thisMonthAvg = array_sum($thisMonthAvgList) / count($thisMonthAvgList);
|
| 586 |
+
$thisMonth = array();
|
| 587 |
+
$thisMonth['thisMonthAvg'] = Mage::helper('awonpulse')->getPriceFormat($thisMonthAvg);
|
| 588 |
+
return array('data' => $data, 'thisMonth' => $thisMonth);
|
| 589 |
+
}
|
| 590 |
+
|
| 591 |
+
/**
|
| 592 |
+
* @param array $data
|
| 593 |
+
*
|
| 594 |
+
* @return float
|
| 595 |
+
*/
|
| 596 |
+
private function _getMedianFromArray($data)
|
| 597 |
+
{
|
| 598 |
+
if (count($data) === 0) {
|
| 599 |
+
return 0;
|
| 600 |
+
}
|
| 601 |
+
sort($data);
|
| 602 |
+
$dataCount = count($data);
|
| 603 |
+
$middleValue = (int)floor($dataCount / 2);
|
| 604 |
+
if ($dataCount % 2 === 1) {
|
| 605 |
+
return floatval($data[$middleValue]);
|
| 606 |
+
}
|
| 607 |
+
return ($data[$middleValue - 1] + $data[$middleValue]) / 2;
|
| 608 |
+
}
|
| 609 |
+
}
|
app/code/local/AW/Onpulse/Model/Credentials.php
CHANGED
|
@@ -1,91 +1,93 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
class AW_Onpulse_Model_Credentials extends Mage_Core_Model_Abstract
|
| 4 |
-
{
|
| 5 |
-
private $key = null;
|
| 6 |
-
private $hash = null;
|
| 7 |
-
private $qrhash = null;
|
| 8 |
-
private $ddl = null;
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
private function _updateURLRedirectEE($idPath,$oldRequestPath, $requestPath)
|
| 12 |
-
{
|
| 13 |
-
$keyRewrite = Mage::getModel('enterprise_urlrewrite/redirect')->loadByRequestPath($oldRequestPath, 0);
|
| 14 |
-
$keyRewrite
|
| 15 |
-
->setOptions()
|
| 16 |
-
->setIdPath($idPath)
|
| 17 |
-
->setTargetPath('awonpulse')
|
| 18 |
-
->setIdentifier($requestPath)
|
| 19 |
-
->save();
|
| 20 |
-
}
|
| 21 |
-
|
| 22 |
-
private function _updateURLRewrite($idPath,$requestPath)
|
| 23 |
-
{
|
| 24 |
-
if(!$requestPath) {
|
| 25 |
-
return;
|
| 26 |
-
}
|
| 27 |
-
$keyRewrite = Mage::getModel('core/url_rewrite')->loadByIdPath($idPath);
|
| 28 |
-
$oldRequestPath = $keyRewrite->getRequestPath();
|
| 29 |
-
$defaultStore = Mage::app()->getStore()->getId();
|
| 30 |
-
if(Mage::app()->getDefaultStoreView() !== null) {
|
| 31 |
-
$defaultStore = Mage::app()->getDefaultStoreView()->getId();
|
| 32 |
-
}
|
| 33 |
-
if(AW_Onpulse_Helper_Data::getPlatform() == AW_Onpulse_Helper_Data::EE_PLATFORM
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
->
|
| 40 |
-
->
|
| 41 |
-
->
|
| 42 |
-
->
|
| 43 |
-
->
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
)
|
| 58 |
-
Mage::
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
)
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
'
|
| 80 |
-
'
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
$this->
|
| 90 |
-
|
|
|
|
|
|
|
| 91 |
}
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class AW_Onpulse_Model_Credentials extends Mage_Core_Model_Abstract
|
| 4 |
+
{
|
| 5 |
+
private $key = null;
|
| 6 |
+
private $hash = null;
|
| 7 |
+
private $qrhash = null;
|
| 8 |
+
private $ddl = null;
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
private function _updateURLRedirectEE($idPath,$oldRequestPath, $requestPath)
|
| 12 |
+
{
|
| 13 |
+
$keyRewrite = Mage::getModel('enterprise_urlrewrite/redirect')->loadByRequestPath($oldRequestPath, 0);
|
| 14 |
+
$keyRewrite
|
| 15 |
+
->setOptions()
|
| 16 |
+
->setIdPath($idPath)
|
| 17 |
+
->setTargetPath('awonpulse')
|
| 18 |
+
->setIdentifier($requestPath)
|
| 19 |
+
->save();
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
private function _updateURLRewrite($idPath,$requestPath)
|
| 23 |
+
{
|
| 24 |
+
if(!$requestPath) {
|
| 25 |
+
return;
|
| 26 |
+
}
|
| 27 |
+
$keyRewrite = Mage::getModel('core/url_rewrite')->loadByIdPath($idPath);
|
| 28 |
+
$oldRequestPath = $keyRewrite->getRequestPath();
|
| 29 |
+
$defaultStore = Mage::app()->getStore()->getId();
|
| 30 |
+
if(Mage::app()->getDefaultStoreView() !== null) {
|
| 31 |
+
$defaultStore = Mage::app()->getDefaultStoreView()->getId();
|
| 32 |
+
}
|
| 33 |
+
if(AW_Onpulse_Helper_Data::getPlatform() == AW_Onpulse_Helper_Data::EE_PLATFORM
|
| 34 |
+
&& version_compare(Mage::getVersion(), '1.13.0.0', '>=')
|
| 35 |
+
) {
|
| 36 |
+
$this->_updateURLRedirectEE($idPath,$oldRequestPath, $requestPath);
|
| 37 |
+
}
|
| 38 |
+
$keyRewrite
|
| 39 |
+
->setIsSystem(0)
|
| 40 |
+
->setStoreId($defaultStore)
|
| 41 |
+
->setOptions('')
|
| 42 |
+
->setIdPath($idPath)
|
| 43 |
+
->setTargetPath('awonpulse')
|
| 44 |
+
->setRequestPath($requestPath)
|
| 45 |
+
->save();
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
public function readConfig()
|
| 49 |
+
{
|
| 50 |
+
|
| 51 |
+
$defaultStore = Mage::app()->getStore()->getId();
|
| 52 |
+
if(Mage::app()->getDefaultStoreView() !== null) {
|
| 53 |
+
$defaultStore = Mage::app()->getDefaultStoreView()->getId();
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
if ((!Mage::getStoreConfig('awonpulse/access/credurlkey', $defaultStore))
|
| 58 |
+
&& (!Mage::getStoreConfig('awonpulse/access/credhash', $defaultStore))
|
| 59 |
+
) {
|
| 60 |
+
Mage::app()->setUpdateMode(false);
|
| 61 |
+
Mage::app()->init('','store');
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
//Read configuration
|
| 65 |
+
if ((Mage::getStoreConfig('awonpulse/access/credurlkey', $defaultStore))
|
| 66 |
+
&& (Mage::getStoreConfig('awonpulse/access/credhash', $defaultStore))
|
| 67 |
+
) {
|
| 68 |
+
$this->hash = Mage::getStoreConfig(
|
| 69 |
+
'awonpulse/access/credhash', $defaultStore
|
| 70 |
+
);
|
| 71 |
+
$this->ddl = Mage::getStoreConfig('awonpulse/general/ddl', $defaultStore);
|
| 72 |
+
$this->key = Mage::getStoreConfig(
|
| 73 |
+
'awonpulse/access/credurlkey', $defaultStore
|
| 74 |
+
);
|
| 75 |
+
$this->qrhash = md5($this->key . $this->hash);
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
return array(
|
| 79 |
+
'hash' => $this->hash,
|
| 80 |
+
'key' => $this->key,
|
| 81 |
+
'qrhash' => $this->qrhash,
|
| 82 |
+
'ddl' => $this->ddl
|
| 83 |
+
);
|
| 84 |
+
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
public function updateSettings($observer)
|
| 88 |
+
{
|
| 89 |
+
$this->readConfig();
|
| 90 |
+
$this->_updateURLRewrite('onpulse/qrhash',$this->qrhash);
|
| 91 |
+
$this->_updateURLRewrite('onpulse/key',$this->key);
|
| 92 |
+
}
|
| 93 |
}
|
app/code/local/AW/Onpulse/Model/Source/OrderStatus.php
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class AW_Onpulse_Model_Source_OrderStatus
|
| 4 |
+
extends Mage_Adminhtml_Model_System_Config_Source_Order_Status
|
| 5 |
+
{
|
| 6 |
+
public function toOptionArray()
|
| 7 |
+
{
|
| 8 |
+
$options = parent::toOptionArray();
|
| 9 |
+
array_shift($options);
|
| 10 |
+
return $options;
|
| 11 |
+
}
|
| 12 |
+
}
|
app/code/local/AW/Onpulse/Model/Source/ProfitRevenue.php
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class AW_Onpulse_Model_Source_ProfitRevenue
|
| 4 |
+
{
|
| 5 |
+
const REVENUE_VALUE = 0;
|
| 6 |
+
const PROFIT_VALUE = 1;
|
| 7 |
+
const REVENUE_LABEL = 'Revenue';
|
| 8 |
+
const PROFIT_LABEL = 'Profit';
|
| 9 |
+
|
| 10 |
+
public function toOptionArray()
|
| 11 |
+
{
|
| 12 |
+
return array(
|
| 13 |
+
array(
|
| 14 |
+
'value' => self::REVENUE_VALUE,
|
| 15 |
+
'label' => Mage::helper('awonpulse')->__('Revenue'),
|
| 16 |
+
),
|
| 17 |
+
array(
|
| 18 |
+
'value' => self::PROFIT_VALUE,
|
| 19 |
+
'label' => Mage::helper('awonpulse')->__('Profit'),
|
| 20 |
+
),
|
| 21 |
+
);
|
| 22 |
+
}
|
| 23 |
+
}
|
app/code/local/AW/Onpulse/controllers/Adminhtml/ConfigController.php
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
include_once("app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php");
|
| 4 |
+
class AW_Onpulse_Adminhtml_ConfigController extends Mage_Adminhtml_System_ConfigController
|
| 5 |
+
{
|
| 6 |
+
public function generateAction()
|
| 7 |
+
{
|
| 8 |
+
$this->saveAction();
|
| 9 |
+
$session = Mage::getSingleton('adminhtml/session');
|
| 10 |
+
$lastSessionMessage = $session->getMessages()->getLastAddedMessage();
|
| 11 |
+
if (null === $lastSessionMessage) {
|
| 12 |
+
return;
|
| 13 |
+
}
|
| 14 |
+
if ($lastSessionMessage->getType() !== 'success') {
|
| 15 |
+
return;
|
| 16 |
+
}
|
| 17 |
+
$session->getMessages()->clear();
|
| 18 |
+
$session->addSuccess(Mage::helper('awonpulse')->__('New login credentials has been generated.'));
|
| 19 |
+
}
|
| 20 |
+
}
|
app/code/local/AW/Onpulse/controllers/IndexController.php
CHANGED
|
@@ -1,52 +1,93 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
protected
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
$
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
}
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class AW_Onpulse_IndexController extends Mage_Core_Controller_Front_Action
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
protected $_accessDeniedAlias = 'awonpulse';
|
| 7 |
+
protected $_config = array();
|
| 8 |
+
|
| 9 |
+
protected function _isAllowed()
|
| 10 |
+
{
|
| 11 |
+
//if strpos gives boolean result it means what alias is denied
|
| 12 |
+
return is_bool(
|
| 13 |
+
strpos(
|
| 14 |
+
$this->getRequest()->getRequestString(),
|
| 15 |
+
$this->_accessDeniedAlias
|
| 16 |
+
)
|
| 17 |
+
);
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
protected function _isAllowedByDirectLink()
|
| 21 |
+
{
|
| 22 |
+
if ($this->_config['ddl']) {
|
| 23 |
+
return false;
|
| 24 |
+
}
|
| 25 |
+
//if strpos gives non boolean result it means what qrhash in url - OK
|
| 26 |
+
return !is_bool(
|
| 27 |
+
strpos(
|
| 28 |
+
$this->getRequest()->getRequestString(),
|
| 29 |
+
$this->_config['qrhash']
|
| 30 |
+
)
|
| 31 |
+
);
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
protected function _isAllowedByKeyHash()
|
| 35 |
+
{
|
| 36 |
+
$key = $this->getRequest()->getParam('key');
|
| 37 |
+
return $key && $key == $this->_config['hash'];
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
public function indexAction()
|
| 41 |
+
{
|
| 42 |
+
if (!$this->_isAllowed()) {
|
| 43 |
+
$this->_forward('noRoute');
|
| 44 |
+
return $this;
|
| 45 |
+
}
|
| 46 |
+
$this->_config = Mage::getModel('awonpulse/credentials')->readConfig();
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
//First of all check Direct link login by QR code
|
| 50 |
+
$noRouteFlag = !$this->_isAllowedByDirectLink();
|
| 51 |
+
|
| 52 |
+
//Second step: check login by key and hash
|
| 53 |
+
if ($noRouteFlag) {
|
| 54 |
+
$noRouteFlag = !$this->_isAllowedByKeyHash();
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
if ($noRouteFlag) {
|
| 58 |
+
$this->_forward('noRoute');
|
| 59 |
+
return $this;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
$type = $this->getRequest()->getParam('type', null);
|
| 63 |
+
if ($type === "search") {
|
| 64 |
+
return $this->_search();
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
$aggregator = Mage::getSingleton('awonpulse/aggregator')->Aggregate();
|
| 68 |
+
$output = Mage::helper('awonpulse')->processOutput($aggregator);
|
| 69 |
+
return $this->getResponse()->setBody(serialize($output));
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
protected function _search()
|
| 73 |
+
{
|
| 74 |
+
$query = $this->getRequest()->getParam('query', null);
|
| 75 |
+
$entity = $this->getRequest()->getParam('entity', null);
|
| 76 |
+
if (null === $query || null === $entity) {
|
| 77 |
+
$this->_forward('noRoute');
|
| 78 |
+
return $this;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
$aggregator = Mage::getSingleton('awonpulse/aggregator')->Aggregate();
|
| 82 |
+
switch($entity) {
|
| 83 |
+
case 'customer':
|
| 84 |
+
Mage::getModel('awonpulse/aggregator_components_customer')->pushSearchedData($aggregator, $query);
|
| 85 |
+
break;
|
| 86 |
+
case 'order':
|
| 87 |
+
Mage::getModel('awonpulse/aggregator_components_order')->pushSearchedData($aggregator, $query);
|
| 88 |
+
break;
|
| 89 |
+
}
|
| 90 |
+
$output = Mage::helper('awonpulse')->processOutput($aggregator);
|
| 91 |
+
return $this->getResponse()->setBody(serialize($output));
|
| 92 |
+
}
|
| 93 |
}
|
app/code/local/AW/Onpulse/etc/config.xml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
<config>
|
| 3 |
<modules>
|
| 4 |
<AW_Onpulse>
|
| 5 |
-
<version>
|
| 6 |
</AW_Onpulse>
|
| 7 |
</modules>
|
| 8 |
<global>
|
|
@@ -101,7 +101,7 @@
|
|
| 101 |
<config>
|
| 102 |
<children>
|
| 103 |
<awonpulse>
|
| 104 |
-
<title>aheadWorks -
|
| 105 |
</awonpulse>
|
| 106 |
</children>
|
| 107 |
</config>
|
|
@@ -112,6 +112,17 @@
|
|
| 112 |
</resources>
|
| 113 |
</acl>
|
| 114 |
</adminhtml>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
<frontend>
|
| 116 |
<routers>
|
| 117 |
<awonpulse>
|
|
@@ -128,6 +139,7 @@
|
|
| 128 |
<general>
|
| 129 |
<ddl>0</ddl>
|
| 130 |
<ordersstatus>complete</ordersstatus>
|
|
|
|
| 131 |
</general>
|
| 132 |
</awonpulse>
|
| 133 |
</default>
|
| 2 |
<config>
|
| 3 |
<modules>
|
| 4 |
<AW_Onpulse>
|
| 5 |
+
<version>2.0.0</version>
|
| 6 |
</AW_Onpulse>
|
| 7 |
</modules>
|
| 8 |
<global>
|
| 101 |
<config>
|
| 102 |
<children>
|
| 103 |
<awonpulse>
|
| 104 |
+
<title>aheadWorks - OnPulse</title>
|
| 105 |
</awonpulse>
|
| 106 |
</children>
|
| 107 |
</config>
|
| 112 |
</resources>
|
| 113 |
</acl>
|
| 114 |
</adminhtml>
|
| 115 |
+
<admin>
|
| 116 |
+
<routers>
|
| 117 |
+
<awonpulse_admin>
|
| 118 |
+
<use>admin</use>
|
| 119 |
+
<args>
|
| 120 |
+
<module>AW_Onpulse</module>
|
| 121 |
+
<frontName>awonpulse_admin</frontName>
|
| 122 |
+
</args>
|
| 123 |
+
</awonpulse_admin>
|
| 124 |
+
</routers>
|
| 125 |
+
</admin>
|
| 126 |
<frontend>
|
| 127 |
<routers>
|
| 128 |
<awonpulse>
|
| 139 |
<general>
|
| 140 |
<ddl>0</ddl>
|
| 141 |
<ordersstatus>complete</ordersstatus>
|
| 142 |
+
<show_sales_statistics_as>0</show_sales_statistics_as>
|
| 143 |
</general>
|
| 144 |
</awonpulse>
|
| 145 |
</default>
|
app/code/local/AW/Onpulse/etc/system.xml
CHANGED
|
@@ -8,7 +8,7 @@
|
|
| 8 |
</tabs>
|
| 9 |
<sections>
|
| 10 |
<awonpulse translate="label" module="awonpulse">
|
| 11 |
-
<label>
|
| 12 |
<tab>awall</tab>
|
| 13 |
<frontend_type>text</frontend_type>
|
| 14 |
<sort_order>99</sort_order>
|
|
@@ -18,40 +18,63 @@
|
|
| 18 |
<groups>
|
| 19 |
<general translate="label">
|
| 20 |
<label>General</label>
|
| 21 |
-
<
|
| 22 |
-
<frontend_model>awonpulse/system_config_form_fieldset_onpulse_settings</frontend_model>
|
| 23 |
-
<sort_order>2</sort_order>
|
| 24 |
<show_in_default>1</show_in_default>
|
| 25 |
<show_in_website>1</show_in_website>
|
| 26 |
<show_in_store>1</show_in_store>
|
| 27 |
<fields>
|
| 28 |
-
<
|
| 29 |
-
<
|
| 30 |
-
<
|
| 31 |
-
<
|
| 32 |
-
<show_in_store>1</show_in_store>
|
| 33 |
-
</credurlkey>
|
| 34 |
-
<credhash>
|
| 35 |
-
<frontend_type>text</frontend_type>
|
| 36 |
<show_in_default>1</show_in_default>
|
| 37 |
<show_in_website>1</show_in_website>
|
| 38 |
<show_in_store>1</show_in_store>
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
| 41 |
<frontend_type>select</frontend_type>
|
| 42 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 43 |
<show_in_default>1</show_in_default>
|
| 44 |
<show_in_website>1</show_in_website>
|
| 45 |
<show_in_store>1</show_in_store>
|
|
|
|
| 46 |
</ddl>
|
| 47 |
-
<
|
| 48 |
-
<
|
|
|
|
|
|
|
| 49 |
<show_in_default>1</show_in_default>
|
| 50 |
<show_in_website>1</show_in_website>
|
| 51 |
<show_in_store>1</show_in_store>
|
| 52 |
-
|
|
|
|
| 53 |
</fields>
|
| 54 |
</general>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
</groups>
|
| 56 |
</awonpulse>
|
| 57 |
</sections>
|
| 8 |
</tabs>
|
| 9 |
<sections>
|
| 10 |
<awonpulse translate="label" module="awonpulse">
|
| 11 |
+
<label>OnPulse</label>
|
| 12 |
<tab>awall</tab>
|
| 13 |
<frontend_type>text</frontend_type>
|
| 14 |
<sort_order>99</sort_order>
|
| 18 |
<groups>
|
| 19 |
<general translate="label">
|
| 20 |
<label>General</label>
|
| 21 |
+
<sort_order>1</sort_order>
|
|
|
|
|
|
|
| 22 |
<show_in_default>1</show_in_default>
|
| 23 |
<show_in_website>1</show_in_website>
|
| 24 |
<show_in_store>1</show_in_store>
|
| 25 |
<fields>
|
| 26 |
+
<ordersstatus translate="label">
|
| 27 |
+
<label>Show Statistic for Orders with Statuses</label>
|
| 28 |
+
<frontend_type>multiselect</frontend_type>
|
| 29 |
+
<source_model>awonpulse/source_orderStatus</source_model>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
<show_in_default>1</show_in_default>
|
| 31 |
<show_in_website>1</show_in_website>
|
| 32 |
<show_in_store>1</show_in_store>
|
| 33 |
+
<sort_order>10</sort_order>
|
| 34 |
+
</ordersstatus>
|
| 35 |
+
<ddl translate="label">
|
| 36 |
+
<label>Disable Direct Login Link</label>
|
| 37 |
<frontend_type>select</frontend_type>
|
| 38 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 39 |
<show_in_default>1</show_in_default>
|
| 40 |
<show_in_website>1</show_in_website>
|
| 41 |
<show_in_store>1</show_in_store>
|
| 42 |
+
<sort_order>20</sort_order>
|
| 43 |
</ddl>
|
| 44 |
+
<show_sales_statistics_as translate="label">
|
| 45 |
+
<label>Show Sales Statistics As</label>
|
| 46 |
+
<frontend_type>select</frontend_type>
|
| 47 |
+
<source_model>awonpulse/source_profitRevenue</source_model>
|
| 48 |
<show_in_default>1</show_in_default>
|
| 49 |
<show_in_website>1</show_in_website>
|
| 50 |
<show_in_store>1</show_in_store>
|
| 51 |
+
<sort_order>30</sort_order>
|
| 52 |
+
</show_sales_statistics_as>
|
| 53 |
</fields>
|
| 54 |
</general>
|
| 55 |
+
<access translate="label">
|
| 56 |
+
<label>Access</label>
|
| 57 |
+
<frontend_type>text</frontend_type>
|
| 58 |
+
<frontend_model>awonpulse/system_config_form_fieldset_onpulse_access</frontend_model>
|
| 59 |
+
<sort_order>10</sort_order>
|
| 60 |
+
<show_in_default>1</show_in_default>
|
| 61 |
+
<show_in_website>1</show_in_website>
|
| 62 |
+
<show_in_store>1</show_in_store>
|
| 63 |
+
<fields>
|
| 64 |
+
<credurlkey>
|
| 65 |
+
<frontend_type>text</frontend_type>
|
| 66 |
+
<show_in_default>1</show_in_default>
|
| 67 |
+
<show_in_website>1</show_in_website>
|
| 68 |
+
<show_in_store>1</show_in_store>
|
| 69 |
+
</credurlkey>
|
| 70 |
+
<credhash>
|
| 71 |
+
<frontend_type>text</frontend_type>
|
| 72 |
+
<show_in_default>1</show_in_default>
|
| 73 |
+
<show_in_website>1</show_in_website>
|
| 74 |
+
<show_in_store>1</show_in_store>
|
| 75 |
+
</credhash>
|
| 76 |
+
</fields>
|
| 77 |
+
</access>
|
| 78 |
</groups>
|
| 79 |
</awonpulse>
|
| 80 |
</sections>
|
app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-install-1.0.0.php
CHANGED
|
@@ -1 +1,5 @@
|
|
| 1 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
| 3 |
+
$installer = $this;
|
| 4 |
+
$installer = $this->startSetup();
|
| 5 |
+
$installer->endSetup();
|
app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.0-1.0.1.php
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
<?php
|
|
|
app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.0-1.0.14.php
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
| 3 |
+
$installer = $this;
|
| 4 |
+
$installer = $this->startSetup();
|
| 5 |
+
$installer->endSetup();
|
app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.1-1.0.2.php
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
<?php
|
|
|
app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.10-1.0.11.php
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
<?php
|
|
|
app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.11-1.0.12.php
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
<?php
|
|
|
app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.12-1.0.13.php
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
<?php
|
|
|
app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.13-1.0.14.php
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
<?php
|
|
|
app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.14-1.0.15.php
CHANGED
|
@@ -1,2 +1,7 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
| 3 |
+
$installer = $this;
|
| 4 |
+
$installer = $this->startSetup();
|
| 5 |
+
Mage::getModel('awonpulse/credentials')->updateSettings(null);
|
| 6 |
+
$installer->endSetup();
|
| 7 |
+
|
app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.14-1.0.16.php
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
die('yhju');
|
| 3 |
-
Mage::getModel('awonpulse')->updateSettings(null);
|
|
|
|
|
|
|
|
|
app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.15-1.0.16.php
DELETED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
Mage::getModel('awonpulse/credentials')->updateSettings(null);
|
|
|
|
|
|
app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.15-1.0.17.php
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
| 3 |
+
$installer = $this;
|
| 4 |
+
$installer = $this->startSetup();
|
| 5 |
+
$installer->endSetup();
|
app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.17-2.0.0.php
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$installer = $this;
|
| 3 |
+
$installer->startSetup();
|
| 4 |
+
$installer->run("
|
| 5 |
+
UPDATE {$this->getTable('core/config_data')} SET path='awonpulse/access/credurlkey' WHERE path='awonpulse/general/credurlkey';
|
| 6 |
+
UPDATE {$this->getTable('core/config_data')} SET path='awonpulse/access/credhash' WHERE path='awonpulse/general/credhash';
|
| 7 |
+
");
|
| 8 |
+
$installer->endSetup();
|
app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.2-1.0.3.php
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
<?php
|
|
|
app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.3-1.0.4.php
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
<?php
|
|
|
app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.4-1.0.5.php
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
<?php
|
|
|
app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.5-1.0.6.php
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
<?php
|
|
|
app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.6-1.0.7.php
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
<?php
|
|
|
app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.7-1.0.8.php
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
<?php
|
|
|
app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.8-1.0.9.php
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
<?php
|
|
|
app/code/local/AW/Onpulse/sql/awonpulse_setup/mysql4-upgrade-1.0.9-1.0.10.php
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
<?php
|
|
|
app/design/adminhtml/default/default/layout/aw_onpulse.xml
CHANGED
|
@@ -1,12 +1,12 @@
|
|
| 1 |
-
<?xml version="1.0"?>
|
| 2 |
-
<layout>
|
| 3 |
-
<default>
|
| 4 |
-
|
| 5 |
-
</default>
|
| 6 |
-
<adminhtml_system_config_edit>
|
| 7 |
-
<reference name="content">
|
| 8 |
-
<!--<block type="awonpulse/system_config_form_fieldset_onpulse_settings" name="aw_onpulse_settings" template="aw_onpulse/settings.phtml"></block>-->
|
| 9 |
-
</reference>
|
| 10 |
-
</adminhtml_system_config_edit>
|
| 11 |
-
|
| 12 |
</layout>
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<layout>
|
| 3 |
+
<default>
|
| 4 |
+
|
| 5 |
+
</default>
|
| 6 |
+
<adminhtml_system_config_edit>
|
| 7 |
+
<reference name="content">
|
| 8 |
+
<!--<block type="awonpulse/system_config_form_fieldset_onpulse_settings" name="aw_onpulse_settings" template="aw_onpulse/settings.phtml"></block>-->
|
| 9 |
+
</reference>
|
| 10 |
+
</adminhtml_system_config_edit>
|
| 11 |
+
|
| 12 |
</layout>
|
app/design/adminhtml/default/default/template/aw_onpulse/access.phtml
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$directLoginLink = null;
|
| 3 |
+
if ((Mage::getStoreConfig('awonpulse/access/credurlkey', Mage::app()->getDefaultStoreView()->getId())) && (Mage::getStoreConfig('awonpulse/access/credhash',Mage::app()->getDefaultStoreView()->getId()))) {
|
| 4 |
+
$credurlkey = Mage::getStoreConfig('awonpulse/access/credurlkey', Mage::app()->getDefaultStoreView()->getId());
|
| 5 |
+
$credhash = Mage::getStoreConfig('awonpulse/access/credhash', Mage::app()->getDefaultStoreView()->getId());
|
| 6 |
+
$qrsrc = 'http://chart.apis.google.com/chart?chs=250x250&cht=qr&chld=1/1&choe=utf-8&chl=';
|
| 7 |
+
$backUrl = Mage::app()->getDefaultStoreView()->getBaseUrl() . md5($credurlkey . $credhash);
|
| 8 |
+
$qrsrc .= 'http://m.onpulse.info/?qrhash=' . base64_encode($backUrl);
|
| 9 |
+
$directLoginLink = 'http://m.onpulse.info/?qrhash=' . base64_encode($backUrl);
|
| 10 |
+
} else {
|
| 11 |
+
$credurlkey = '';
|
| 12 |
+
$credhash = '';
|
| 13 |
+
$qrsrc = null;
|
| 14 |
+
}
|
| 15 |
+
$isDirectLoginLinkDisabled = !!Mage::getStoreConfig('awonpulse/general/ddl', Mage::app()->getDefaultStoreView()->getId());
|
| 16 |
+
?>
|
| 17 |
+
|
| 18 |
+
<table class="form-list" id="access-fieldset">
|
| 19 |
+
<tbody>
|
| 20 |
+
<tr>
|
| 21 |
+
<td class="label">
|
| 22 |
+
<label><?php echo Mage::helper('awonpulse')->__('URL') ?></label>
|
| 23 |
+
</td>
|
| 24 |
+
<td class="value">
|
| 25 |
+
<input type="hidden" name="groups[access][fields][credurlkey][value]"
|
| 26 |
+
id="urlkey" value="<?php echo $credurlkey;?>"/>
|
| 27 |
+
<input class="input-text" style="width: 100%;" onclick="this.setSelectionRange(0, 9999)" type="text"
|
| 28 |
+
value="<?php echo Mage::app()->getDefaultStoreView()->getBaseUrl() . $credurlkey;?>"/>
|
| 29 |
+
<p class="note">
|
| 30 |
+
<span><?php echo Mage::helper('awonpulse')->__('Your login name to access OnPulse service') ?></span>
|
| 31 |
+
</p>
|
| 32 |
+
</td>
|
| 33 |
+
</tr>
|
| 34 |
+
<tr>
|
| 35 |
+
<td class="label">
|
| 36 |
+
<label><?php echo Mage::helper('awonpulse')->__('Key') ?></label>
|
| 37 |
+
</td>
|
| 38 |
+
<td class="value">
|
| 39 |
+
<input type="hidden" name="groups[access][fields][credhash][value]"
|
| 40 |
+
id="hash" value="<?php echo $credhash;?>"/>
|
| 41 |
+
<input class="input-text" style="width: 100%;" type="text" onclick="this.setSelectionRange(0, 9999)"
|
| 42 |
+
value="<?php echo $credhash;?>"/>
|
| 43 |
+
</td>
|
| 44 |
+
</tr>
|
| 45 |
+
<?php if ($directLoginLink && !$isDirectLoginLinkDisabled) : ?>
|
| 46 |
+
<tr>
|
| 47 |
+
<td class="label">
|
| 48 |
+
<label><?php echo Mage::helper('awonpulse')->__('Direct Login URL') ?></label>
|
| 49 |
+
</td>
|
| 50 |
+
<td style="padding-left: 6px; ">
|
| 51 |
+
<a href="<?php echo $directLoginLink;?>" style="display: block; width: 400px; padding-top: 5px;"
|
| 52 |
+
target="_blank"><?php echo substr($directLoginLink, 0, 60) . '...'; ?></a>
|
| 53 |
+
</td>
|
| 54 |
+
</tr>
|
| 55 |
+
<?php endif; ?>
|
| 56 |
+
<?php if ($qrsrc && !$isDirectLoginLinkDisabled) : ?>
|
| 57 |
+
<tr>
|
| 58 |
+
<td class="label">
|
| 59 |
+
<label><?php echo Mage::helper('awonpulse')->__('Direct Login QR') ?></label>
|
| 60 |
+
</td>
|
| 61 |
+
<td>
|
| 62 |
+
<img src="<?php echo $qrsrc; ?>" style="margin:-10px -30px;">
|
| 63 |
+
</td>
|
| 64 |
+
</tr>
|
| 65 |
+
<?php endif; ?>
|
| 66 |
+
<tr>
|
| 67 |
+
<td>
|
| 68 |
+
</td>
|
| 69 |
+
<td style="padding-left: 6px;">
|
| 70 |
+
<button><?php echo Mage::helper('awonpulse')->__('Generate new credentials') ?></button>
|
| 71 |
+
<p class="note">
|
| 72 |
+
<span><?php echo Mage::helper('awonpulse')->__('Each time you reset credentials OnPulse generates new URL, key, direct login and QR code') ?></span>
|
| 73 |
+
</p>
|
| 74 |
+
</td>
|
| 75 |
+
</tr>
|
| 76 |
+
</tbody>
|
| 77 |
+
</table>
|
| 78 |
+
|
| 79 |
+
<script type="text/javascript">
|
| 80 |
+
$$('#access-fieldset button').first().observe('click', function(e){
|
| 81 |
+
key = mkPass(8);
|
| 82 |
+
hash = mkPass(8);
|
| 83 |
+
$('urlkey').setValue(key);
|
| 84 |
+
$('hash').setValue(hash);
|
| 85 |
+
var el = new Element('form');
|
| 86 |
+
el.setStyle({display: 'none'});
|
| 87 |
+
el.setAttribute('action', <?php echo Zend_Json::encode($this->getGenerateUrl());?>);
|
| 88 |
+
el.setAttribute('method', 'post');
|
| 89 |
+
el.innerHTML += $$('#config_edit_form input[name=form_key]').first().outerHTML;
|
| 90 |
+
el.innerHTML += ($('access-fieldset').innerHTML);
|
| 91 |
+
document.body.appendChild(el);
|
| 92 |
+
el.submit();
|
| 93 |
+
Event.stop(e);
|
| 94 |
+
});
|
| 95 |
+
|
| 96 |
+
function mtRand(min, max) {
|
| 97 |
+
var range = max - min + 1;
|
| 98 |
+
return Math.floor(Math.random() * range) + min;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
function mkPass(len) {
|
| 102 |
+
len = 8;
|
| 103 |
+
var pass = '';
|
| 104 |
+
var rnd = 0;
|
| 105 |
+
var c = '';
|
| 106 |
+
for (i = 0; i < len; i++) {
|
| 107 |
+
rnd = mtRand(0, 1); // Латиница или цифры
|
| 108 |
+
if (rnd == 0) {
|
| 109 |
+
c = String.fromCharCode(mtRand(48, 57));
|
| 110 |
+
}
|
| 111 |
+
if (rnd == 1) {
|
| 112 |
+
c = String.fromCharCode(mtRand(97, 122));
|
| 113 |
+
}
|
| 114 |
+
pass += c;
|
| 115 |
+
}
|
| 116 |
+
return pass;
|
| 117 |
+
}
|
| 118 |
+
</script>
|
app/design/adminhtml/default/default/template/aw_onpulse/settings.phtml
DELETED
|
@@ -1,155 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
$directLoginLink = null;
|
| 3 |
-
$ddl = Mage::getStoreConfig('awonpulse/general/ddl',Mage::app()->getDefaultStoreView()->getId());
|
| 4 |
-
$ordersStatusCollection = Mage::getSingleton('sales/order_config')->getStatuses();
|
| 5 |
-
$ordersstatus = Mage::getStoreConfig('awonpulse/general/ordersstatus',Mage::app()->getDefaultStoreView()->getId());
|
| 6 |
-
$ordersstatus = explode(',', $ordersstatus);
|
| 7 |
-
$size = count($ordersStatusCollection);
|
| 8 |
-
|
| 9 |
-
if ((Mage::getStoreConfig('awonpulse/general/credurlkey',Mage::app()->getDefaultStoreView()->getId())) && (Mage::getStoreConfig('awonpulse/general/credhash',Mage::app()->getDefaultStoreView()->getId()))) {
|
| 10 |
-
$credurlkey = Mage::getStoreConfig('awonpulse/general/credurlkey',Mage::app()->getDefaultStoreView()->getId());
|
| 11 |
-
$credhash = Mage::getStoreConfig('awonpulse/general/credhash',Mage::app()->getDefaultStoreView()->getId());
|
| 12 |
-
$qrsrc = 'http://chart.apis.google.com/chart?chs=250x250&cht=qr&chld=1/1&choe=utf-8&chl=';
|
| 13 |
-
$backUrl = Mage::app()->getDefaultStoreView()->getBaseUrl() . md5($credurlkey . $credhash);
|
| 14 |
-
$qrsrc .= 'http://m.onpulse.info/?qrhash=' . base64_encode($backUrl);
|
| 15 |
-
$directLoginLink = 'http://m.onpulse.info/?qrhash=' . base64_encode($backUrl);
|
| 16 |
-
} else {
|
| 17 |
-
$credurlkey = '';
|
| 18 |
-
$credhash = '';
|
| 19 |
-
$qrsrc = null;
|
| 20 |
-
}
|
| 21 |
-
?>
|
| 22 |
-
|
| 23 |
-
<table class="form-list">
|
| 24 |
-
<tbody>
|
| 25 |
-
<form method="post">
|
| 26 |
-
<tr>
|
| 27 |
-
<td class="label">
|
| 28 |
-
<label><?php echo Mage::helper('awonpulse')->__('URL') ?></label>
|
| 29 |
-
</td>
|
| 30 |
-
<td class="value">
|
| 31 |
-
<input class="input-text" style="width: 600px;" onclick="this.select()" type="text" readonly="readonly"
|
| 32 |
-
name="groups[general][fields][credurlkey][value]" id="urlkey"
|
| 33 |
-
value="<?php echo Mage::app()->getDefaultStoreView()->getBaseUrl() . $credurlkey;?>">
|
| 34 |
-
|
| 35 |
-
<p class="note">
|
| 36 |
-
<span><?php echo Mage::helper('awonpulse')->__('Your login name to access OnPulse service') ?></span>
|
| 37 |
-
</p>
|
| 38 |
-
</td>
|
| 39 |
-
</tr>
|
| 40 |
-
<tr>
|
| 41 |
-
<td class="label">
|
| 42 |
-
<label><?php echo Mage::helper('awonpulse')->__('Key') ?></label>
|
| 43 |
-
</td>
|
| 44 |
-
<td class="value">
|
| 45 |
-
<input class="input-text" style="width: 600px;" type="text" onclick="this.select()" readonly="readonly"
|
| 46 |
-
name="groups[general][fields][credhash][value]" id="hash" value="<?php echo $credhash;?>">
|
| 47 |
-
</td>
|
| 48 |
-
</tr>
|
| 49 |
-
<tr>
|
| 50 |
-
<td class="label">
|
| 51 |
-
<label><?php echo Mage::helper('awonpulse')->__('Disable direct login link') ?></label>
|
| 52 |
-
</td>
|
| 53 |
-
<td class="value">
|
| 54 |
-
<select name="groups[general][fields][ddl][value]" id="ddl" autofocus>
|
| 55 |
-
<option <?php if($ddl=="1") echo "selected" ?> value="1"><?php echo Mage::helper('awonpulse')->__('Yes') ?></option>
|
| 56 |
-
<option <?php if($ddl=="0") echo "selected" ?> value="0"><?php echo Mage::helper('awonpulse')->__('No') ?></option>
|
| 57 |
-
</select>
|
| 58 |
-
</td>
|
| 59 |
-
</tr>
|
| 60 |
-
<?php if ($directLoginLink) : ?>
|
| 61 |
-
<tr>
|
| 62 |
-
<td class="label">
|
| 63 |
-
<label><?php echo Mage::helper('awonpulse')->__('Direct login URL') ?></label>
|
| 64 |
-
</td>
|
| 65 |
-
<td style="padding-left: 6px; ">
|
| 66 |
-
<a href="<?php echo $directLoginLink;?>" style="display: block; width: 600px; padding-top: 5px;"
|
| 67 |
-
target="_blank"><?php echo substr($directLoginLink, 0, 80) . '...'; ?></a>
|
| 68 |
-
</td>
|
| 69 |
-
</tr>
|
| 70 |
-
<?php endif; ?>
|
| 71 |
-
<?php if ($qrsrc) : ?>
|
| 72 |
-
<tr>
|
| 73 |
-
<td class="label">
|
| 74 |
-
<label><?php echo Mage::helper('awonpulse')->__('Direct login QR') ?></label>
|
| 75 |
-
</td>
|
| 76 |
-
<td>
|
| 77 |
-
<br/> <img src="<?php echo $qrsrc; ?>">
|
| 78 |
-
</td>
|
| 79 |
-
</tr>
|
| 80 |
-
<?php endif; ?>
|
| 81 |
-
|
| 82 |
-
<tr>
|
| 83 |
-
<td class="label">
|
| 84 |
-
<label><?php echo Mage::helper('awonpulse')->__('Show statistic for orders with statuses') ?></label>
|
| 85 |
-
</td>
|
| 86 |
-
<td class="value">
|
| 87 |
-
<select multiple name="groups[general][fields][ordersstatus][value][]" id="ordersstatus" size="<?php echo $size?>">
|
| 88 |
-
<?php foreach ($ordersStatusCollection as $storeOrderStatus => $statusLabel): ?>
|
| 89 |
-
<?php
|
| 90 |
-
if (in_array($storeOrderStatus,$ordersstatus)){
|
| 91 |
-
$selected = "selected";
|
| 92 |
-
} else {
|
| 93 |
-
$selected = "";
|
| 94 |
-
}
|
| 95 |
-
?>
|
| 96 |
-
<option <?php echo $selected; ?> value="<?php echo $storeOrderStatus; ?>"><?php echo $statusLabel; ?></option>
|
| 97 |
-
<?php endforeach;?>
|
| 98 |
-
</select>
|
| 99 |
-
</td>
|
| 100 |
-
</tr>
|
| 101 |
-
<tr>
|
| 102 |
-
<td>
|
| 103 |
-
</td>
|
| 104 |
-
<td style="padding-left: 6px; padding-top: 10px;">
|
| 105 |
-
<button onclick="generate(this);"><?php echo Mage::helper('awonpulse')->__('Save and generate new login credentials') ?></button>
|
| 106 |
-
<p class="note">
|
| 107 |
-
<span><?php echo Mage::helper('awonpulse')->__('Each time you reset credentials OnPulse generates new URL, key, direct login and QR code') ?></span>
|
| 108 |
-
</p>
|
| 109 |
-
</td>
|
| 110 |
-
</tr>
|
| 111 |
-
</form>
|
| 112 |
-
</tbody>
|
| 113 |
-
</table>
|
| 114 |
-
|
| 115 |
-
<script type="text/javascript">
|
| 116 |
-
var flagSubmit = false;
|
| 117 |
-
function generate() {
|
| 118 |
-
if (!flagSubmit) {
|
| 119 |
-
key = mkPass(8);
|
| 120 |
-
hash = mkPass(8);
|
| 121 |
-
document.getElementById('urlkey').value = key;
|
| 122 |
-
document.getElementById('hash').value = hash;
|
| 123 |
-
flagSubmit = true;
|
| 124 |
-
}
|
| 125 |
-
}
|
| 126 |
-
|
| 127 |
-
function mtRand(min, max) {
|
| 128 |
-
var range = max - min + 1;
|
| 129 |
-
var n = Math.floor(Math.random() * range) + min;
|
| 130 |
-
return n;
|
| 131 |
-
}
|
| 132 |
-
|
| 133 |
-
function mkPass(len) {
|
| 134 |
-
var len = 8;
|
| 135 |
-
var pass = '';
|
| 136 |
-
var rnd = 0;
|
| 137 |
-
var c = '';
|
| 138 |
-
for (i = 0; i < len; i++) {
|
| 139 |
-
rnd = mtRand(0, 1); // Латиница или цифры
|
| 140 |
-
if (rnd == 0) {
|
| 141 |
-
c = String.fromCharCode(mtRand(48, 57));
|
| 142 |
-
}
|
| 143 |
-
if (rnd == 1) {
|
| 144 |
-
c = String.fromCharCode(mtRand(97, 122));
|
| 145 |
-
}
|
| 146 |
-
pass += c;
|
| 147 |
-
}
|
| 148 |
-
return pass;
|
| 149 |
-
}
|
| 150 |
-
|
| 151 |
-
document.getElementsByClassName('form-buttons')[0].style.display = 'none';
|
| 152 |
-
document.getElementsByClassName('form-buttons')[1].style.display = 'none';
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/locale/en_US/AW_Onpulse.csv
CHANGED
|
@@ -1,13 +1,17 @@
|
|
| 1 |
-
"Hash","Hash"
|
| 2 |
-
"Url key","Url key"
|
| 3 |
-
"URL","URL"
|
| 4 |
-
"Your login name to access OnPulse service","Your login name to access OnPulse service"
|
| 5 |
-
"Key","Key"
|
| 6 |
-
"Direct
|
| 7 |
-
"Direct
|
| 8 |
-
"
|
| 9 |
-
"Each time you reset credentials OnPulse generates new URL, key, direct login and QR code","Each time you reset credentials OnPulse generates new URL, key, direct login and QR code"
|
| 10 |
-
"Disable
|
| 11 |
-
"Yes","Yes"
|
| 12 |
-
"No","No"
|
| 13 |
-
"Show
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"Hash","Hash"
|
| 2 |
+
"Url key","Url key"
|
| 3 |
+
"URL","URL"
|
| 4 |
+
"Your login name to access OnPulse service","Your login name to access OnPulse service"
|
| 5 |
+
"Key","Key"
|
| 6 |
+
"Direct Login URL","Direct Login URL"
|
| 7 |
+
"Direct Login QR","Direct Login QR"
|
| 8 |
+
"Generate new credentials","Generate new credentials"
|
| 9 |
+
"Each time you reset credentials OnPulse generates new URL, key, direct login and QR code","Each time you reset credentials OnPulse generates new URL, key, direct login and QR code"
|
| 10 |
+
"Disable Direct Login Link","Disable Direct Login Link"
|
| 11 |
+
"Yes","Yes"
|
| 12 |
+
"No","No"
|
| 13 |
+
"Show Statistic for Orders with Statuses","Show Statistic for Orders with Statuses"
|
| 14 |
+
"New login credentials has been generated.","New login credentials has been generated."
|
| 15 |
+
"Revenue","Revenue"
|
| 16 |
+
"Profit","Profit"
|
| 17 |
+
"Show Sales Statistics As","Show Sales Statistics As"
|
package.xml
CHANGED
|
@@ -1,19 +1,25 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>AW_Onpulse</name>
|
| 4 |
-
<version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://onpulse.info/TOS.pdf">EULA</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>Mobile administration for Magento</summary>
|
| 10 |
-
<description>OnPulse provides you with an access to your sales statistics, the latest orders, and the clients list through any iOS or Android powered mobile device
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
<authors><author><name>AW_Core_Team</name><user>aheadworks</user><email>no-reply@aheadworks.com</email></author></authors>
|
| 14 |
-
<date>
|
| 15 |
-
<time>
|
| 16 |
-
<contents><target name="
|
| 17 |
<compatible/>
|
| 18 |
-
<dependencies><required><php><min>5.
|
| 19 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>AW_Onpulse</name>
|
| 4 |
+
<version>2.0.0</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://onpulse.info/TOS.pdf">EULA</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>Mobile administration for Magento</summary>
|
| 10 |
+
<description>OnPulse provides you with an access to your sales statistics, the latest orders, and the clients list through any iOS or Android powered mobile device.</description>
|
| 11 |
+
<notes>The update includes a number of all-new reports, improved sales forecast algorithm and the ability to search and view order and customer data. Here is the full list of new features:
|
| 12 |
+
- Ability to search and view all clients and orders by name, email or ID
|
| 13 |
+
- Displays sales stats as profit or revenue
|
| 14 |
+
- Sales by country report
|
| 15 |
+
- Items per order report (IPO)
|
| 16 |
+
- Average order value report (AOV)
|
| 17 |
+
- Last orders with items on the dashboard
|
| 18 |
+
- Improved sales forecast algorithm</notes>
|
| 19 |
<authors><author><name>AW_Core_Team</name><user>aheadworks</user><email>no-reply@aheadworks.com</email></author></authors>
|
| 20 |
+
<date>2015-03-17</date>
|
| 21 |
+
<time>13:21:25</time>
|
| 22 |
+
<contents><target name="mageetc"><dir name="modules"><file name="AW_Onpulse.xml" hash="de39a5ffebb31ee697fbaf56bb1bfb8a"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="aw_onpulse.xml" hash="d09056058d50d23c5c6d23c977dd5597"/></dir><dir name="template"><dir name="aw_onpulse"><file name="access.phtml" hash="83d79128f5e5311afa966d14922e5639"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="AW_Onpulse.csv" hash="4aa10dde01a5cdcd2cf8393dad7c3307"/></dir></target><target name="magelocal"><dir name="AW"><dir name="Onpulse"><dir name="Block"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Fieldset"><dir name="Onpulse"><file name="Access.php" hash="fd13a1db644a64d8c94f3d4a4c6d7209"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="739f1a113831f84b57e340faaf81b0b4"/></dir><dir name="Model"><dir name="Aggregator"><file name="Component.php" hash="f5fad1561e9416e2180915eb27338de0"/><dir name="Components"><file name="Customer.php" hash="154fc0cd3d6f05328297d2c210d074dc"/><file name="Order.php" hash="4d73ae227b6b259268207f9fdea11215"/><file name="Statistics.php" hash="b6c68cb748c294fc2ed506fce8443f86"/></dir></dir><file name="Aggregator.php" hash="25c9afc28898537ba928261ba6039d46"/><file name="Credentials.php" hash="5e47eeda766011b0c62eb3950a266013"/><dir name="Source"><file name="OrderStatus.php" hash="ee2303fe70a4079444f78c9f7f4b26f7"/><file name="ProfitRevenue.php" hash="9d62f0d63ee294a85952a59fe67865b8"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ConfigController.php" hash="c2f131fd09f9bcf903c4a759fcd7a3c4"/></dir><file name="IndexController.php" hash="10fb4c82c9d718b25cbc41b11ba390d5"/></dir><dir name="etc"><file name="config.xml" hash="2ef39dbb27830686ca3042dee1c3d67d"/><file name="system.xml" hash="1208189b11076e1f29a54fce5ea22eeb"/></dir><dir name="sql"><dir name="awonpulse_setup"><file name="mysql4-install-1.0.0.php" hash="f9df2f05fb3189102247b4c6fcee81e9"/><file name="mysql4-upgrade-1.0.0-1.0.14.php" hash="f9df2f05fb3189102247b4c6fcee81e9"/><file name="mysql4-upgrade-1.0.14-1.0.15.php" hash="82ed6ef244e3a14e61846f5dce1c7125"/><file name="mysql4-upgrade-1.0.15-1.0.17.php" hash="f9df2f05fb3189102247b4c6fcee81e9"/><file name="mysql4-upgrade-1.0.17-2.0.0.php" hash="a7ce80bcd8e64c2b7f2a4ee227664680"/></dir></dir></dir></dir></target></contents>
|
| 23 |
<compatible/>
|
| 24 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 25 |
</package>
|
