Version Notes
Release with latest version
Download this release
Release Info
| Developer | Satish Mantri |
| Extension | Osc_Mage_Admin |
| Version | 2.0.0 |
| Comparing to | |
| See all releases | |
Version 2.0.0
- app/code/community/Oscprofessionals/Magemobapp/Block/Order/Totals.php +300 -0
- app/code/community/Oscprofessionals/Magemobapp/Block/Osc.php +12 -0
- app/code/community/Oscprofessionals/Magemobapp/Helper/Data.php +85 -0
- app/code/community/Oscprofessionals/Magemobapp/Model/Customers.php +355 -0
- app/code/community/Oscprofessionals/Magemobapp/Model/Dashboard.php +108 -0
- app/code/community/Oscprofessionals/Magemobapp/Model/Login.php +271 -0
- app/code/community/Oscprofessionals/Magemobapp/Model/Logoff.php +59 -0
- app/code/community/Oscprofessionals/Magemobapp/Model/Notification.php +129 -0
- app/code/community/Oscprofessionals/Magemobapp/Model/Orders.php +304 -0
- app/code/community/Oscprofessionals/Magemobapp/Model/Osc.php +191 -0
- app/code/community/Oscprofessionals/Magemobapp/Model/Sitehealth.php +68 -0
- app/code/community/Oscprofessionals/Magemobapp/Model/Stock.php +182 -0
- app/code/community/Oscprofessionals/Magemobapp/Model/Storeinfo.php +405 -0
- app/code/community/Oscprofessionals/Magemobapp/controllers/IndexController.php +45 -0
- app/code/community/Oscprofessionals/Magemobapp/etc/adminhtml.xml +30 -0
- app/code/community/Oscprofessionals/Magemobapp/etc/config.xml +75 -0
- app/code/community/Oscprofessionals/Magemobapp/etc/system.xml +256 -0
- app/etc/modules/Oscprofessionals_Magemobapp.xml +18 -0
- package.xml +20 -0
app/code/community/Oscprofessionals/Magemobapp/Block/Order/Totals.php
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
*
|
| 4 |
+
* @category Oscprofessionals
|
| 5 |
+
* @package Oscprofessionals_Magemobapp
|
| 6 |
+
* @author Oscprofessionals Team <oscpteam@oscprofessionals.com>
|
| 7 |
+
*/
|
| 8 |
+
class Oscprofessionals_Magemobapp_Block_Order_Totals extends Mage_Sales_Block_Order_Totals {
|
| 9 |
+
/**
|
| 10 |
+
* important can't delete
|
| 11 |
+
*/
|
| 12 |
+
protected $_totals;
|
| 13 |
+
protected $_order = null;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Initialize self totals and children blocks totals before html building
|
| 17 |
+
*
|
| 18 |
+
* @return Mage_Sales_Block_Order_Totals
|
| 19 |
+
*/
|
| 20 |
+
protected function _beforeToHtml()
|
| 21 |
+
{
|
| 22 |
+
$this->_initTotals();
|
| 23 |
+
foreach ($this->getChild() as $child) {
|
| 24 |
+
if (method_exists($child, 'initTotals')) {
|
| 25 |
+
$child->initTotals();
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
return parent::_beforeToHtml();
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* Get order object
|
| 33 |
+
*
|
| 34 |
+
* @return Mage_Sales_Model_Order
|
| 35 |
+
*/
|
| 36 |
+
public function getOrder()
|
| 37 |
+
{
|
| 38 |
+
if ($this->_order === null) {
|
| 39 |
+
if ($this->hasData('order')) {
|
| 40 |
+
$this->_order = $this->_getData('order');
|
| 41 |
+
} elseif (Mage::registry('current_order')) {
|
| 42 |
+
$this->_order = Mage::registry('current_order');
|
| 43 |
+
} elseif ($this->getParentBlock()->getOrder()) {
|
| 44 |
+
$this->_order = $this->getParentBlock()->getOrder();
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
return $this->_order;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
public function setOrder($order)
|
| 51 |
+
{
|
| 52 |
+
$this->_order = $order;
|
| 53 |
+
return $this;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
/**
|
| 57 |
+
* Get totals source object
|
| 58 |
+
*
|
| 59 |
+
* @return Mage_Sales_Model_Order
|
| 60 |
+
*/
|
| 61 |
+
public function getSource()
|
| 62 |
+
{
|
| 63 |
+
return $this->getOrder();
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
/**
|
| 67 |
+
* Initialize order totals array
|
| 68 |
+
*
|
| 69 |
+
* @return Mage_Sales_Block_Order_Totals
|
| 70 |
+
*/
|
| 71 |
+
public function initTotals()
|
| 72 |
+
{
|
| 73 |
+
$source = $this->getSource();
|
| 74 |
+
|
| 75 |
+
$this->_totals = array();
|
| 76 |
+
$this->_totals['subtotal'] = new Varien_Object(array(
|
| 77 |
+
'code' => 'sub total',
|
| 78 |
+
'value' => $source->getSubtotal(),
|
| 79 |
+
'label' => $this->__('Subtotal')
|
| 80 |
+
));
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
/**
|
| 84 |
+
* Add shipping
|
| 85 |
+
*/
|
| 86 |
+
if (!$source->getIsVirtual() && ((float) $source->getShippingAmount() || $source->getShippingDescription()))
|
| 87 |
+
{
|
| 88 |
+
$this->_totals['shipping'] = new Varien_Object(array(
|
| 89 |
+
'code' => 'shipping',
|
| 90 |
+
'field' => 'shipping_amount',
|
| 91 |
+
'value' => $this->getSource()->getShippingAmount(),
|
| 92 |
+
'label' => $this->__('Shipping & Handling')
|
| 93 |
+
));
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
/**
|
| 97 |
+
* Add discount
|
| 98 |
+
*/
|
| 99 |
+
if (((float)$this->getSource()->getDiscountAmount()) != 0) {
|
| 100 |
+
if ($this->getSource()->getDiscountDescription()) {
|
| 101 |
+
$discountLabel = $this->__('Discount (%s)', $source->getDiscountDescription());
|
| 102 |
+
} else {
|
| 103 |
+
$discountLabel = $this->__('Discount');
|
| 104 |
+
}
|
| 105 |
+
$this->_totals['discount'] = new Varien_Object(array(
|
| 106 |
+
'code' => 'discount',
|
| 107 |
+
'field' => 'discount_amount',
|
| 108 |
+
'value' => $source->getDiscountAmount(),
|
| 109 |
+
'label' => $discountLabel
|
| 110 |
+
));
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
/**
|
| 114 |
+
* Add Tax
|
| 115 |
+
*/
|
| 116 |
+
if (((float)$this->getSource()->getTaxAmount()) != 0) {
|
| 117 |
+
|
| 118 |
+
$this->_totals['tax'] = new Varien_Object(array(
|
| 119 |
+
'code' => 'tax',
|
| 120 |
+
'field' => 'tax_amount',
|
| 121 |
+
'value' => $source->getTaxAmount(),
|
| 122 |
+
'label' => 'Tax'
|
| 123 |
+
));
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
$this->_totals['grand_total'] = new Varien_Object(array(
|
| 127 |
+
'code' => 'grand total',
|
| 128 |
+
'field' => 'grand_total',
|
| 129 |
+
'strong'=> true,
|
| 130 |
+
'value' => $source->getGrandTotal(),
|
| 131 |
+
'label' => $this->__('Grand Total')
|
| 132 |
+
));
|
| 133 |
+
|
| 134 |
+
/**
|
| 135 |
+
* Base grandtotal
|
| 136 |
+
*/
|
| 137 |
+
if ($this->getOrder()->isCurrencyDifferent()) {
|
| 138 |
+
$this->_totals['base_grandtotal'] = new Varien_Object(array(
|
| 139 |
+
'code' => 'base_grandtotal',
|
| 140 |
+
'value' => $this->getOrder()->formatBasePrice($source->get()),
|
| 141 |
+
'label' => $this->__('Grand Total to be Charged'),
|
| 142 |
+
'is_formated' => true,
|
| 143 |
+
));
|
| 144 |
+
}
|
| 145 |
+
return $this;
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
/**
|
| 149 |
+
* Add new total to totals array after specific total or before last total by default
|
| 150 |
+
*
|
| 151 |
+
* @param Varien_Object $total
|
| 152 |
+
* @param null|string|last|first $after
|
| 153 |
+
* @return Mage_Sales_Block_Order_Totals
|
| 154 |
+
*/
|
| 155 |
+
public function addTotal(Varien_Object $total, $after=null)
|
| 156 |
+
{
|
| 157 |
+
if ($after !== null && $after != 'last' && $after != 'first') {
|
| 158 |
+
$totals = array();
|
| 159 |
+
$added = false;
|
| 160 |
+
foreach ($this->_totals as $code => $item) {
|
| 161 |
+
$totals[$code] = $item;
|
| 162 |
+
if ($code == $after) {
|
| 163 |
+
$added = true;
|
| 164 |
+
$totals[$total->getCode()] = $total;
|
| 165 |
+
}
|
| 166 |
+
}
|
| 167 |
+
if (!$added) {
|
| 168 |
+
$last = array_pop($totals);
|
| 169 |
+
$totals[$total->getCode()] = $total;
|
| 170 |
+
$totals[$last->getCode()] = $last;
|
| 171 |
+
}
|
| 172 |
+
$this->_totals = $totals;
|
| 173 |
+
} elseif ($after=='last') {
|
| 174 |
+
$this->_totals[$total->getCode()] = $total;
|
| 175 |
+
} elseif ($after=='first') {
|
| 176 |
+
$totals = array($total->getCode()=>$total);
|
| 177 |
+
$this->_totals = array_merge($totals, $this->_totals);
|
| 178 |
+
} else {
|
| 179 |
+
$last = array_pop($this->_totals);
|
| 180 |
+
$this->_totals[$total->getCode()] = $total;
|
| 181 |
+
$this->_totals[$last->getCode()] = $last;
|
| 182 |
+
}
|
| 183 |
+
return $this;
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
/**
|
| 187 |
+
* Add new total to totals array before specific total or after first total by default
|
| 188 |
+
*
|
| 189 |
+
* @param Varien_Object $total
|
| 190 |
+
* @param null|string $after
|
| 191 |
+
* @return Mage_Sales_Block_Order_Totals
|
| 192 |
+
*/
|
| 193 |
+
public function addTotalBefore(Varien_Object $total, $before=null)
|
| 194 |
+
{
|
| 195 |
+
if ($before !== null) {
|
| 196 |
+
if (!is_array($before)) {
|
| 197 |
+
$before = array($before);
|
| 198 |
+
}
|
| 199 |
+
foreach ($before as $beforeTotals) {
|
| 200 |
+
if (isset($this->_totals[$beforeTotals])) {
|
| 201 |
+
$totals = array();
|
| 202 |
+
foreach ($this->_totals as $code => $item) {
|
| 203 |
+
if ($code == $beforeTotals) {
|
| 204 |
+
$totals[$total->getCode()] = $total;
|
| 205 |
+
}
|
| 206 |
+
$totals[$code] = $item;
|
| 207 |
+
}
|
| 208 |
+
$this->_totals = $totals;
|
| 209 |
+
return $this;
|
| 210 |
+
}
|
| 211 |
+
}
|
| 212 |
+
}
|
| 213 |
+
$totals = array();
|
| 214 |
+
$first = array_shift($this->_totals);
|
| 215 |
+
$totals[$first->getCode()] = $first;
|
| 216 |
+
$totals[$total->getCode()] = $total;
|
| 217 |
+
foreach ($this->_totals as $code => $item) {
|
| 218 |
+
$totals[$code] = $item;
|
| 219 |
+
}
|
| 220 |
+
$this->_totals = $totals;
|
| 221 |
+
return $this;
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
/**
|
| 225 |
+
* Get Total object by code
|
| 226 |
+
*
|
| 227 |
+
* @@return Varien_Object
|
| 228 |
+
*/
|
| 229 |
+
public function getTotal($code)
|
| 230 |
+
{
|
| 231 |
+
if (isset($this->_totals[$code])) {
|
| 232 |
+
return $this->_totals[$code];
|
| 233 |
+
}
|
| 234 |
+
return false;
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
/**
|
| 238 |
+
* Delete total by specific
|
| 239 |
+
*
|
| 240 |
+
* @param string $code
|
| 241 |
+
* @return Mage_Sales_Block_Order_Totals
|
| 242 |
+
*/
|
| 243 |
+
public function removeTotal($code)
|
| 244 |
+
{
|
| 245 |
+
unset($this->_totals[$code]);
|
| 246 |
+
return $this;
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
/**
|
| 250 |
+
* Apply sort orders to totals array.
|
| 251 |
+
* Array should have next structure
|
| 252 |
+
* array(
|
| 253 |
+
* $totalCode => $totalSortOrder
|
| 254 |
+
* )
|
| 255 |
+
*
|
| 256 |
+
*
|
| 257 |
+
* @param array $order
|
| 258 |
+
* @return Mage_Sales_Block_Order_Totals
|
| 259 |
+
*/
|
| 260 |
+
public function applySortOrder($order)
|
| 261 |
+
{
|
| 262 |
+
return $this;
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
/**
|
| 266 |
+
* get totals array for visualization
|
| 267 |
+
*
|
| 268 |
+
* @return array
|
| 269 |
+
*/
|
| 270 |
+
public function getTotals($area=null)
|
| 271 |
+
{
|
| 272 |
+
$totals = array();
|
| 273 |
+
if ($area === null) {
|
| 274 |
+
$totals = $this->_totals;
|
| 275 |
+
} else {
|
| 276 |
+
$area = (string)$area;
|
| 277 |
+
foreach ($this->_totals as $total) {
|
| 278 |
+
$totalArea = (string) $total->getArea();
|
| 279 |
+
if ($totalArea == $area) {
|
| 280 |
+
$totals[] = $total;
|
| 281 |
+
}
|
| 282 |
+
}
|
| 283 |
+
}
|
| 284 |
+
return $totals;
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
/**
|
| 288 |
+
* Format total value based on order currency
|
| 289 |
+
*
|
| 290 |
+
* @param Varien_Object $total
|
| 291 |
+
* @return string
|
| 292 |
+
*/
|
| 293 |
+
public function formatValue($total)
|
| 294 |
+
{
|
| 295 |
+
if (!$total->getIsFormated()) {
|
| 296 |
+
return $this->getOrder()->formatPrice($total->getValue());
|
| 297 |
+
}
|
| 298 |
+
return $total->getValue();
|
| 299 |
+
}
|
| 300 |
+
}
|
app/code/community/Oscprofessionals/Magemobapp/Block/Osc.php
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
*
|
| 4 |
+
* @category Oscprofessionals
|
| 5 |
+
* @package Oscprofessionals_Magemobapp
|
| 6 |
+
* @author : Oscprofessionals Team <oscpteam@oscprofessionals.com>
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
//osc block class for call model class file according to action.
|
| 10 |
+
class Oscprofessionals_Magemobapp_Block_Osc extends Mage_Core_Block_Template {
|
| 11 |
+
|
| 12 |
+
}
|
app/code/community/Oscprofessionals/Magemobapp/Helper/Data.php
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
*
|
| 4 |
+
* @category Oscprofessionals
|
| 5 |
+
* @package Oscprofessionals_Magemobapp
|
| 6 |
+
* @author : Oscprofessionals Team <oscpteam@oscprofessionals.com>
|
| 7 |
+
*/
|
| 8 |
+
class Oscprofessionals_Magemobapp_Helper_Data extends Mage_Core_Helper_Abstract
|
| 9 |
+
{
|
| 10 |
+
|
| 11 |
+
//Data reporting days limit from admin setting
|
| 12 |
+
const REPORTING_DAYS = 'magemobapp/settings/reporting_days';
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* get from day with date Filter
|
| 16 |
+
* @param type $filter
|
| 17 |
+
* @return type
|
| 18 |
+
*/
|
| 19 |
+
public function getTodaysDate($daysFilter = null)
|
| 20 |
+
{
|
| 21 |
+
|
| 22 |
+
$fromDate = Mage::app()->getLocale()->date();
|
| 23 |
+
$fromDate->subDate(0);
|
| 24 |
+
$date = gmdate("Y-m-d", $fromDate->getTimestamp());
|
| 25 |
+
return $date;
|
| 26 |
+
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* get last day with date Filter
|
| 32 |
+
* @param type $filter
|
| 33 |
+
* @return type
|
| 34 |
+
*/
|
| 35 |
+
public function getLastWeekDate($daysFilter = null)
|
| 36 |
+
{
|
| 37 |
+
|
| 38 |
+
$fromDate = Mage::app()->getLocale()->date();
|
| 39 |
+
$fromDate->subDate(7);
|
| 40 |
+
$date = gmdate("Y-m-d", $fromDate->getTimestamp());
|
| 41 |
+
return $date;
|
| 42 |
+
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
/**
|
| 47 |
+
* get 1 month Back date for filter
|
| 48 |
+
* @param type $filter
|
| 49 |
+
* @return type
|
| 50 |
+
*/
|
| 51 |
+
public function getMonthBackDate()
|
| 52 |
+
{
|
| 53 |
+
|
| 54 |
+
$currentDate = Mage::app()->getLocale()->date();
|
| 55 |
+
$currentDate->subMonth(1);
|
| 56 |
+
$fromDate = date('Y-m-d H:i:s', strtotime($currentDate));
|
| 57 |
+
|
| 58 |
+
return $fromDate;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* get back date with admin reporting days.
|
| 63 |
+
* @param type $filter
|
| 64 |
+
* @return type
|
| 65 |
+
*/
|
| 66 |
+
public function getReportingDate()
|
| 67 |
+
{
|
| 68 |
+
$reportingDays = Mage::getStoreConfig(self::REPORTING_DAYS);
|
| 69 |
+
$fromDate = Mage::app()->getLocale()->date();
|
| 70 |
+
|
| 71 |
+
if(($reportingDays > 30) || empty($reportingDays)){
|
| 72 |
+
$reportingDays = 30;
|
| 73 |
+
}
|
| 74 |
+
$date = gmdate("Y-m-d", $fromDate->getTimestamp());
|
| 75 |
+
// minus from current date to reporting date
|
| 76 |
+
if($reportingDays > 0){
|
| 77 |
+
$reportingDays = ($reportingDays - 1);
|
| 78 |
+
}else{
|
| 79 |
+
$reportingDays;
|
| 80 |
+
}
|
| 81 |
+
$beforeDate = "-".$reportingDays.'days';
|
| 82 |
+
$date = date('Y-m-d', strtotime($beforeDate, strtotime($date)));
|
| 83 |
+
return $date;
|
| 84 |
+
}
|
| 85 |
+
}
|
app/code/community/Oscprofessionals/Magemobapp/Model/Customers.php
ADDED
|
@@ -0,0 +1,355 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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essionals_Magemobapp_Model_Customers extends Mage_Core_Model_Abstract
|
| 9 |
+
{
|
| 10 |
+
protected $_dataArray;
|
| 11 |
+
public $days = '';
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* @return json array
|
| 15 |
+
* @return customers info (array)
|
| 16 |
+
*/
|
| 17 |
+
public function oscIndex($params)
|
| 18 |
+
{
|
| 19 |
+
|
| 20 |
+
return $this->getCustomerInfo($params['customer_id']);
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
* Get store customer Count
|
| 25 |
+
* @return (string) count
|
| 26 |
+
*/
|
| 27 |
+
public function customerCount($days = '')
|
| 28 |
+
{
|
| 29 |
+
|
| 30 |
+
switch ($days) {
|
| 31 |
+
case "today":
|
| 32 |
+
//get Todays Date
|
| 33 |
+
$fromDate = Mage::helper('magemobapp')->getTodaysDate();
|
| 34 |
+
break;
|
| 35 |
+
case "lastWeek":
|
| 36 |
+
//get 1 week Back date
|
| 37 |
+
$fromDate = Mage::helper('magemobapp')->getLastWeekDate();
|
| 38 |
+
break;
|
| 39 |
+
case "lastMonth":
|
| 40 |
+
//get 1 month Back date
|
| 41 |
+
$fromDate = Mage::helper('magemobapp')->getMonthBackDate();
|
| 42 |
+
break;
|
| 43 |
+
default:
|
| 44 |
+
//get reporting date
|
| 45 |
+
$fromDate = Mage::helper('magemobapp')->getReportingDate();
|
| 46 |
+
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
//store Id
|
| 50 |
+
$storeId = Mage::getModel('magemobapp/storeinfo')->getStoreId();
|
| 51 |
+
|
| 52 |
+
$customersCollection = Mage::getModel('customer/customer')->getCollection()->addAttributeToFilter('created_at', array(
|
| 53 |
+
'from' => $fromDate
|
| 54 |
+
));
|
| 55 |
+
|
| 56 |
+
$customersCount = 0;
|
| 57 |
+
if ($storeId != 0) {
|
| 58 |
+
$customersCollection->addAttributeToFilter('store_id', $storeId);
|
| 59 |
+
}
|
| 60 |
+
$customersCount = $customersCollection->count(); //customers count
|
| 61 |
+
|
| 62 |
+
return $customersCount;
|
| 63 |
+
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
/**
|
| 68 |
+
* Get order info
|
| 69 |
+
* @return customers info (array)
|
| 70 |
+
*/
|
| 71 |
+
public function getCustomerList()
|
| 72 |
+
{
|
| 73 |
+
|
| 74 |
+
//get store ID
|
| 75 |
+
$storeId = Mage::getModel('magemobapp/storeinfo')->getStoreId();
|
| 76 |
+
|
| 77 |
+
//reporting date
|
| 78 |
+
$fromDate = Mage::helper('magemobapp')->getReportingDate();
|
| 79 |
+
|
| 80 |
+
$customerCollection = Mage::getModel('customer/customer')->getCollection()->addAttributeToFilter('created_at', array(
|
| 81 |
+
'from' => $fromDate
|
| 82 |
+
))->addAttributeToSort('created_at', 'desc');
|
| 83 |
+
$customerCollection->addAttributeToSelect(array(
|
| 84 |
+
'firstname',
|
| 85 |
+
'lastname'
|
| 86 |
+
));
|
| 87 |
+
|
| 88 |
+
if ($storeId != 0) {
|
| 89 |
+
$customerCollection->addAttributeToFilter('store_id', $storeId); //fill store
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
foreach ($customerCollection as $_customer) {
|
| 93 |
+
$customer = Mage::getModel('customer/customer')->load($_customer->getId()); //insert cust ID
|
| 94 |
+
foreach ($customer->getAddresses() as $address) {
|
| 95 |
+
$telephone = $address->getTelephone();
|
| 96 |
+
$countryCode = $address->getCountryId();
|
| 97 |
+
$countryName = Mage::app()->getLocale()->getCountryTranslation($countryCode);
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
//get order commection with customer ID
|
| 101 |
+
$orderCount = $this->getCustomerTotalOrder($_customer->getId());
|
| 102 |
+
|
| 103 |
+
$this->_dataArray[] = array(
|
| 104 |
+
'customer_id' => $_customer->getId(),
|
| 105 |
+
'customer_name' => $_customer->getName(),
|
| 106 |
+
'customer_email' => $_customer->getEmail(),
|
| 107 |
+
'customer_total_order' => $orderCount,
|
| 108 |
+
'customer_phone_no' => $telephone,
|
| 109 |
+
'customer_location' => $countryName,
|
| 110 |
+
'customer_registration_date' => $_customer->getCreatedAt()
|
| 111 |
+
);
|
| 112 |
+
}
|
| 113 |
+
return $this->_dataArray;
|
| 114 |
+
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
/**
|
| 119 |
+
* Get customer info
|
| 120 |
+
* @return customer info (array)
|
| 121 |
+
*/
|
| 122 |
+
public function getCustomerInfo($customerId = null)
|
| 123 |
+
{
|
| 124 |
+
$telephone = '';
|
| 125 |
+
$countryName = '';
|
| 126 |
+
|
| 127 |
+
$customer = Mage::getModel('customer/customer')->load($customerId); //insert cust ID
|
| 128 |
+
$customerData = $customer->getData();
|
| 129 |
+
|
| 130 |
+
//get order commection with customer ID
|
| 131 |
+
$orderCount = $this->getCustomerTotalOrder($customer->getId());
|
| 132 |
+
|
| 133 |
+
//get customer created_date
|
| 134 |
+
$createdAt = $customer->getCreatedAt();
|
| 135 |
+
$createdAt = Mage::helper('core')->formatDate($createdAt, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
|
| 136 |
+
|
| 137 |
+
//get customer total sales
|
| 138 |
+
$customerTotalsSale = $this->getLifetimeSales($customer->getId());
|
| 139 |
+
|
| 140 |
+
$customerOrderData = $this->getCustomersOrders($customer->getId());
|
| 141 |
+
|
| 142 |
+
//customer address object
|
| 143 |
+
$addressData = Mage::getModel('customer/address')->load($customer->getDefaultBilling());
|
| 144 |
+
|
| 145 |
+
// "long" country name
|
| 146 |
+
$country_id = $addressData->getCountryId();
|
| 147 |
+
$address = $addressData['street'] . ",";
|
| 148 |
+
$address .= $addressData->getCity() . ",";
|
| 149 |
+
$region = $addressData->getRegion();
|
| 150 |
+
|
| 151 |
+
if (!empty($region)) {
|
| 152 |
+
$address .= $region . ",";
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
$address .= $addressData->getPostcode() . ",";
|
| 156 |
+
$address .= Mage::app()->getLocale()->getCountryTranslation($country_id);
|
| 157 |
+
|
| 158 |
+
foreach ($customer->getAddresses() as $customerAddress) {
|
| 159 |
+
$telephone = $customerAddress->getTelephone();
|
| 160 |
+
$countryCode = $customerAddress->getCountryId();
|
| 161 |
+
$countryName = Mage::app()->getLocale()->getCountryTranslation($countryCode);
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
$this->_dataArray = array(
|
| 165 |
+
'customer_id' => $customer->getId(),
|
| 166 |
+
'customer_name' => $customer->getName(),
|
| 167 |
+
'customer_email' => $customer->getEmail(),
|
| 168 |
+
'customer_total_order' => $orderCount,
|
| 169 |
+
'customer_phone_no' => $telephone,
|
| 170 |
+
'customer_location' => $countryName,
|
| 171 |
+
'customer_registration_date' => $createdAt,
|
| 172 |
+
'customer_billing_address' => $address,
|
| 173 |
+
'customer_total_sale' => Mage::helper('core')->currency($customerTotalsSale, true, false), //customer sales with currency;
|
| 174 |
+
'customer_orders' => $customerOrderData
|
| 175 |
+
);
|
| 176 |
+
//return customer info data
|
| 177 |
+
return $this->_dataArray;
|
| 178 |
+
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
/**
|
| 182 |
+
* get customer total order count
|
| 183 |
+
* @param type $customer_id
|
| 184 |
+
* @return customer order count
|
| 185 |
+
*/
|
| 186 |
+
public function getCustomerTotalOrder($customerId)
|
| 187 |
+
{
|
| 188 |
+
|
| 189 |
+
//get store ID
|
| 190 |
+
$storeId = Mage::getModel('magemobapp/storeinfo')->getStoreId();
|
| 191 |
+
|
| 192 |
+
$orders = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('customer_id', $customerId);
|
| 193 |
+
|
| 194 |
+
if ($storeId != 0) {
|
| 195 |
+
$orders->addAttributeToFilter('store_id', $storeId); //fill store
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
$orderCount = $orders->count(); //orders count
|
| 199 |
+
|
| 200 |
+
return $orderCount;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
/**
|
| 205 |
+
* get life time sales value of customer info
|
| 206 |
+
* @param type $customerId
|
| 207 |
+
* @return customer Life Time sale
|
| 208 |
+
*/
|
| 209 |
+
public function getLifetimeSales($customerId)
|
| 210 |
+
{
|
| 211 |
+
|
| 212 |
+
$collection = Mage::getResourceModel('sales/order_collection');
|
| 213 |
+
|
| 214 |
+
$collection->addAttributeToFilter('customer_id', $customerId);
|
| 215 |
+
|
| 216 |
+
//fetch data
|
| 217 |
+
$collection->getSelect()->reset(Zend_Db_Select::COLUMNS)->columns(array(
|
| 218 |
+
'total' => 'SUM(base_grand_total)'
|
| 219 |
+
))->group("{$this->mainTable}.customer_id");
|
| 220 |
+
$first_item = $collection->getFirstItem();
|
| 221 |
+
|
| 222 |
+
return $first_item->getData('total');
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
/**
|
| 227 |
+
* get orders details from customer ID
|
| 228 |
+
* @param type $customerId
|
| 229 |
+
* @return customer order Data
|
| 230 |
+
*/
|
| 231 |
+
public function getCustomersOrders($customerId)
|
| 232 |
+
{
|
| 233 |
+
$dir = '';
|
| 234 |
+
$collection = Mage::getModel("sales/order")->getCollection()->addFieldToFilter('customer_id', $customerId);
|
| 235 |
+
$reverseDir = ($dir == 'DESC') ? 'ASC' : 'DESC';
|
| 236 |
+
$collection->getSelect()->order('created_at ' . $reverseDir);
|
| 237 |
+
|
| 238 |
+
foreach ($collection as $_customerData) {
|
| 239 |
+
$this->_dataArray[] = array(
|
| 240 |
+
'order_id' => $_customerData->getId(),
|
| 241 |
+
'increment_id' => $_customerData->getIncrementId(),
|
| 242 |
+
'order_date' => $_customerData->getCreatedAt(),
|
| 243 |
+
'order_status' => $_customerData->getStatus(),
|
| 244 |
+
'order_total' => Mage::helper('core')->currency($_customerData->getGrandTotal(), true, false)
|
| 245 |
+
);
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
return $this->_dataArray;
|
| 249 |
+
|
| 250 |
+
}
|
| 251 |
+
|
| 252 |
+
/**
|
| 253 |
+
* Get Online visitors
|
| 254 |
+
* @return onlinevisitors (array)
|
| 255 |
+
*/
|
| 256 |
+
public function getOnlineCustomers()
|
| 257 |
+
{
|
| 258 |
+
|
| 259 |
+
$params['store'] = Mage::getModel('magemobapp/storeinfo')->getStoreId();
|
| 260 |
+
$returning = 0;
|
| 261 |
+
$new = 0;
|
| 262 |
+
$total = 0;
|
| 263 |
+
|
| 264 |
+
$storeId = '';
|
| 265 |
+
if (isset($params['store']) && $params['store'] != '') {
|
| 266 |
+
$storeId = $params['store'];
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
$customers = Mage::getModel('log/visitor_online')->getCollection();
|
| 270 |
+
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 271 |
+
$visitorTable = $read->getTableName('log_visitor');
|
| 272 |
+
$table = 'main_table';
|
| 273 |
+
$customers->getSelect()->joinInner(array(
|
| 274 |
+
'lvt' => $visitorTable
|
| 275 |
+
), "lvt.visitor_id = {$table}.visitor_id", array(
|
| 276 |
+
'last_visit_at',
|
| 277 |
+
'store_id'
|
| 278 |
+
));
|
| 279 |
+
|
| 280 |
+
$customers->addFieldToFilter('store_id', $storeId);
|
| 281 |
+
|
| 282 |
+
|
| 283 |
+
$onlineStatus = array();
|
| 284 |
+
foreach ($customers as $val) {
|
| 285 |
+
$onlinestatus = $val->toArray();
|
| 286 |
+
if ($onlinestatus['visitor_type'] == 'c') {
|
| 287 |
+
$returning++;
|
| 288 |
+
}
|
| 289 |
+
if ($onlinestatus['visitor_type'] == 'v') {
|
| 290 |
+
$new++;
|
| 291 |
+
}
|
| 292 |
+
$total++;
|
| 293 |
+
|
| 294 |
+
}
|
| 295 |
+
$output = array(
|
| 296 |
+
'new_customer' => $new,
|
| 297 |
+
'returnig_customer' => $returning,
|
| 298 |
+
'total_customer' => $total
|
| 299 |
+
);
|
| 300 |
+
return $output;
|
| 301 |
+
|
| 302 |
+
|
| 303 |
+
}
|
| 304 |
+
/**
|
| 305 |
+
* Get Abandoned Customers
|
| 306 |
+
* @return Abandoned Customers (array)
|
| 307 |
+
*/
|
| 308 |
+
public function getAbandonedCustomersList($params)
|
| 309 |
+
{
|
| 310 |
+
$fromDate = Mage::helper('magemobapp')->getReportingDate();
|
| 311 |
+
$collection = Mage::getResourceModel('reports/quote_collection');
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
$storeIds = '';
|
| 315 |
+
$dir = '';
|
| 316 |
+
if (isset($params['store']) && $params['store'] != '') {
|
| 317 |
+
$storeIds = Mage::getModel('magemobapp/storeinfo')->getStoreIds($params['store']);
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
$reverseDir = ($dir == 'DESC') ? 'ASC' : 'DESC';
|
| 321 |
+
$collection->getSelect()->where('main_table.created_at>=?',$fromDate)->order('main_table.created_at ' . $reverseDir);
|
| 322 |
+
|
| 323 |
+
$collection->prepareForAbandonedReport($storeIds);
|
| 324 |
+
|
| 325 |
+
$cartCollection = $collection->load()->toArray();
|
| 326 |
+
|
| 327 |
+
|
| 328 |
+
$result = array();
|
| 329 |
+
foreach ($cartCollection['items'] as $key => $val) {
|
| 330 |
+
$result[$key]['entity_id'] = $cartCollection['items'][$key]['entity_id'];
|
| 331 |
+
$result[$key]['store_id'] = $cartCollection['items'][$key]['store_id'];
|
| 332 |
+
$result[$key]['created_at'] = $cartCollection['items'][$key]['created_at'];
|
| 333 |
+
$result[$key]['items_count'] = $cartCollection['items'][$key]['items_count'];
|
| 334 |
+
$result[$key]['customer_firstname'] = $cartCollection['items'][$key]['customer_firstname'];
|
| 335 |
+
$result[$key]['customer_lastname'] = $cartCollection['items'][$key]['customer_lastname'];
|
| 336 |
+
$result[$key]['customer_email'] = $cartCollection['items'][$key]['customer_email'];
|
| 337 |
+
$result[$key]['customer_is_guest'] = $cartCollection['items'][$key]['customer_is_guest'];
|
| 338 |
+
$result[$key]['grand_total'] = Mage::helper('core')->currency($cartCollection['items'][$key]['grand_total'], true, false);
|
| 339 |
+
$result[$key]['remote_ip'] = $cartCollection['items'][$key]['remote_ip'];
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
return $result;
|
| 343 |
+
}
|
| 344 |
+
/**
|
| 345 |
+
* Get count Abandoned Customers
|
| 346 |
+
* @return Abandoned Customers count
|
| 347 |
+
*/
|
| 348 |
+
public function getCountAbandonedCustomers()
|
| 349 |
+
{
|
| 350 |
+
$params['store'] = Mage::getModel('magemobapp/storeinfo')->getStoreId();
|
| 351 |
+
$abandonedcart = $this->getAbandonedCustomersList($params);
|
| 352 |
+
$abandonedcartCount = count($abandonedcart);
|
| 353 |
+
return $abandonedcartCount;
|
| 354 |
+
}
|
| 355 |
+
}
|
app/code/community/Oscprofessionals/Magemobapp/Model/Dashboard.php
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
*
|
| 4 |
+
* @category Oscprofessionals
|
| 5 |
+
* @package Oscprofessionals_Magemobapp
|
| 6 |
+
* @author Oscprofessionals Team <oscpteam@oscprofessionals.com>
|
| 7 |
+
*/
|
| 8 |
+
class Oscprofessionals_Magemobapp_Model_Dashboard extends Mage_Core_Model_Abstract
|
| 9 |
+
{
|
| 10 |
+
protected $_dataArray;
|
| 11 |
+
public $days;
|
| 12 |
+
|
| 13 |
+
//Data reporting days limit from admin setting
|
| 14 |
+
const REPORTING_DAYS = 'magemobapp/settings/reporting_days';
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* @return json array
|
| 18 |
+
* @return dashboard info.
|
| 19 |
+
*/
|
| 20 |
+
public function oscIndex()
|
| 21 |
+
{
|
| 22 |
+
|
| 23 |
+
return array(
|
| 24 |
+
'last_update_time' => date('Y-m-d H:i:s'),
|
| 25 |
+
'dashboard' => $this->getDashboardInfo()
|
| 26 |
+
);
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* Get dashboard info
|
| 31 |
+
* @return dashboard info (array)
|
| 32 |
+
*/
|
| 33 |
+
function getDashboardInfo()
|
| 34 |
+
{
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
//get order Model
|
| 38 |
+
$order = Mage::getModel('magemobapp/orders');
|
| 39 |
+
|
| 40 |
+
//get customers Model
|
| 41 |
+
$customers = Mage::getModel('magemobapp/customers');
|
| 42 |
+
|
| 43 |
+
//Recent order count with date filter from order class
|
| 44 |
+
$newOrdercount = $order->orderCount('today');
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
//get all order count
|
| 48 |
+
$orderCount = $order->orderCount('');
|
| 49 |
+
|
| 50 |
+
//get customers count
|
| 51 |
+
$newCustomersCount = $customers->customerCount('today');
|
| 52 |
+
|
| 53 |
+
//get all customer count
|
| 54 |
+
$customerCount = $customers->customerCount();
|
| 55 |
+
|
| 56 |
+
//get count stock alert
|
| 57 |
+
$stockAlertCount = Mage::getModel('magemobapp/stock')->getCountStockAlert();
|
| 58 |
+
|
| 59 |
+
//get online customer(visitors) count
|
| 60 |
+
$onlinestatusCount = Mage::getModel('magemobapp/customers')->getOnlineCustomers();
|
| 61 |
+
|
| 62 |
+
//get abandoned cart customer count
|
| 63 |
+
$abandonedcartCount = Mage::getModel('magemobapp/customers')->getCountAbandonedCustomers();
|
| 64 |
+
|
| 65 |
+
//get store total sales
|
| 66 |
+
$salesTotal = $order->todaysSalesTotal();
|
| 67 |
+
$neworder_enabled = Mage::getStoreConfig('magemobapp/dashboard/neworder_enabled');
|
| 68 |
+
$allorder_enabled = Mage::getStoreConfig('magemobapp/dashboard/allorder_enabled');
|
| 69 |
+
$newcustomers_enabled = Mage::getStoreConfig('magemobapp/dashboard/newcustomers_enabled');
|
| 70 |
+
$allcustomers_enabled = Mage::getStoreConfig('magemobapp/dashboard/allcustomers_enabled');
|
| 71 |
+
$stockalert_enabled = Mage::getStoreConfig('magemobapp/dashboard/stockalert_enabled');
|
| 72 |
+
$todayssales_enabled = Mage::getStoreConfig('magemobapp/dashboard/todayssales_enabled');
|
| 73 |
+
$reportingdays_enabled = Mage::getStoreConfig('magemobapp/dashboard/reportingdays_enabled');
|
| 74 |
+
$online_enabled = Mage::getStoreConfig('magemobapp/dashboard/online_enabled');
|
| 75 |
+
$abandonedcart_enabled = Mage::getStoreConfig('magemobapp/dashboard/abandonedcart_enabled');
|
| 76 |
+
|
| 77 |
+
if ($neworder_enabled == 1) {
|
| 78 |
+
$finalArr['new_order'] = $newOrdercount;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
if ($allorder_enabled == 1) {
|
| 82 |
+
$finalArr['all_orders'] = $orderCount;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
if ($newcustomers_enabled == 1) {
|
| 86 |
+
$finalArr['new_customers'] = $newCustomersCount;
|
| 87 |
+
}
|
| 88 |
+
if ($allcustomers_enabled == 1) {
|
| 89 |
+
$finalArr['all_customers'] = $customerCount;
|
| 90 |
+
}
|
| 91 |
+
if ($stockalert_enabled == 1) {
|
| 92 |
+
$finalArr['stock_alert'] = $stockAlertCount;
|
| 93 |
+
}
|
| 94 |
+
if ($todayssales_enabled == 1) {
|
| 95 |
+
$finalArr['today_sales'] = $salesTotal;
|
| 96 |
+
}
|
| 97 |
+
if ($online_enabled == 1) {
|
| 98 |
+
$finalArr['online_customers'] = $onlinestatusCount;
|
| 99 |
+
}
|
| 100 |
+
if ($abandonedcart_enabled == 1) {
|
| 101 |
+
$finalArr['abandoned_cart'] = $abandonedcartCount;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
$this->_dataArray = $finalArr;
|
| 105 |
+
return $this->_dataArray;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
}
|
app/code/community/Oscprofessionals/Magemobapp/Model/Login.php
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
*
|
| 4 |
+
* @category Oscprofessionals
|
| 5 |
+
* @package Oscprofessionals_Magemobapp
|
| 6 |
+
* @author Oscprofessionals Team <oscpteam@oscprofessionals.com>
|
| 7 |
+
*/
|
| 8 |
+
class Oscprofessionals_Magemobapp_Model_Login
|
| 9 |
+
{
|
| 10 |
+
|
| 11 |
+
protected $_helper;
|
| 12 |
+
protected $_dataArray;
|
| 13 |
+
|
| 14 |
+
public function __construct()
|
| 15 |
+
{
|
| 16 |
+
$this->_helper = Mage::helper('magemobapp');
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* login process
|
| 22 |
+
* @param usename and password
|
| 23 |
+
* @return sucess login Data
|
| 24 |
+
*/
|
| 25 |
+
public function login($username, $password)
|
| 26 |
+
{
|
| 27 |
+
$username = base64_decode($username);
|
| 28 |
+
$password = base64_decode($password);
|
| 29 |
+
|
| 30 |
+
$tmpUser = '';
|
| 31 |
+
for ($i = 0; $i < strlen($username); $i++) {
|
| 32 |
+
if ($i % 2 == 0) {
|
| 33 |
+
$tmpUser .= $username[$i];
|
| 34 |
+
}
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
$username = $tmpUser;
|
| 38 |
+
$tmpPass = '';
|
| 39 |
+
for ($i = 0; $i < strlen($password); $i++) {
|
| 40 |
+
if ($i % 2 == 0) {
|
| 41 |
+
$tmpPass .= $password[$i];
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
$password = $tmpPass;
|
| 46 |
+
$session = Mage::getSingleton('admin/session');
|
| 47 |
+
$Login = false;
|
| 48 |
+
|
| 49 |
+
if ($this->isAuthenticate($username, $password)) {
|
| 50 |
+
if (empty($username) || empty($password)) {
|
| 51 |
+
return;
|
| 52 |
+
}
|
| 53 |
+
/** @var $user Mage_Admin_Model_User */
|
| 54 |
+
$user = Mage::getModel('admin/user');
|
| 55 |
+
$user->login($username, $password);
|
| 56 |
+
if ($user->getId()) {
|
| 57 |
+
if (method_exists($session, 'renewSession')) {
|
| 58 |
+
$session->renewSession();
|
| 59 |
+
}
|
| 60 |
+
$session->setIsFirstPageAfterLogin(true);
|
| 61 |
+
$session->setUser($user);
|
| 62 |
+
$session->setAcl(Mage::getResourceModel('admin/acl')->loadAcl());
|
| 63 |
+
|
| 64 |
+
$Login = true;
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
if ($Login) {
|
| 68 |
+
$this->saveLogin();
|
| 69 |
+
//clear cache
|
| 70 |
+
Mage::app()->getCacheInstance()->cleanType("config");
|
| 71 |
+
$loginData = $this->loginDataProcess($username);
|
| 72 |
+
return $loginData;
|
| 73 |
+
}
|
| 74 |
+
throw new Exception($this->_helper->__('Login failed'), 6);
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* save config for earch admin time login
|
| 80 |
+
*/
|
| 81 |
+
public function saveLogin()
|
| 82 |
+
{
|
| 83 |
+
$username = Mage::getSingleton('admin/session')->getUser()->getUsername();
|
| 84 |
+
$datetime = Mage::app()->getLocale()->date();
|
| 85 |
+
$datetime->setTimezone('Etc/UTC');
|
| 86 |
+
$last = $this->getLastLogin();
|
| 87 |
+
Mage::getSingleton('admin/session')->setLastLogin($last); // save into session
|
| 88 |
+
$this->saveSetting($datetime->toString(Varien_Date::DATETIME_INTERNAL_FORMAT), 'login_' . $username); //login time code is username of admin
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
/**
|
| 93 |
+
* get login date time
|
| 94 |
+
* @return string
|
| 95 |
+
*/
|
| 96 |
+
public function getLastLogin()
|
| 97 |
+
{
|
| 98 |
+
$code = Mage::getSingleton('admin/session')->getUser()->getUsername();
|
| 99 |
+
$date = Mage::app()->getLocale()->date()->subDay(1)->setMinute(0)->setSecond(0); // get time from yestoday when never logout
|
| 100 |
+
$last_yesterday = gmdate("Y-m-d H:i:s", $date->getTimestamp()); //datetime mysql
|
| 101 |
+
if (($loginconfig = $this->getSetting('login_' . $code)) != '') {
|
| 102 |
+
return $loginconfig;
|
| 103 |
+
} else {
|
| 104 |
+
return $last_yesterday;
|
| 105 |
+
}
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
/**
|
| 109 |
+
* get setting
|
| 110 |
+
* @param type $code
|
| 111 |
+
* @return type
|
| 112 |
+
*/
|
| 113 |
+
public function getSetting($code)
|
| 114 |
+
{
|
| 115 |
+
$setting_path = $code;
|
| 116 |
+
return Mage::getStoreConfig($setting_path);
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
/**
|
| 120 |
+
* save your config value
|
| 121 |
+
* @param type $value is value
|
| 122 |
+
* @param string $code is path or code
|
| 123 |
+
*/
|
| 124 |
+
public function saveSetting($value, $code = '')
|
| 125 |
+
{
|
| 126 |
+
$setting_path = '';
|
| 127 |
+
if ($code == '') {
|
| 128 |
+
$setting_path = $value;
|
| 129 |
+
} else {
|
| 130 |
+
$setting_path = $code;
|
| 131 |
+
}
|
| 132 |
+
if (is_null($value))
|
| 133 |
+
$value = '';
|
| 134 |
+
Mage::getModel('core/config')->saveConfig($setting_path, $value);
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
/**
|
| 138 |
+
* check is loged in
|
| 139 |
+
* @return boolean
|
| 140 |
+
*/
|
| 141 |
+
public function isCheckLogin()
|
| 142 |
+
{
|
| 143 |
+
$session = Mage::getSingleton('admin/session');
|
| 144 |
+
|
| 145 |
+
if ($session->isLoggedIn()) {
|
| 146 |
+
return true;
|
| 147 |
+
}
|
| 148 |
+
return false;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
/**
|
| 152 |
+
* check ACL
|
| 153 |
+
*/
|
| 154 |
+
public function isCheckRole()
|
| 155 |
+
{
|
| 156 |
+
// bind call name to controller name for check acl
|
| 157 |
+
$session = Mage::getSingleton('admin/session');
|
| 158 |
+
if (!$session->isAllowed('magemobapp/api')) {
|
| 159 |
+
return false;
|
| 160 |
+
}
|
| 161 |
+
return true;
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
/**
|
| 166 |
+
* API authenticate
|
| 167 |
+
* @param type $username
|
| 168 |
+
* @param type $password
|
| 169 |
+
* @return boolean
|
| 170 |
+
* @throws Mage_Core_Exception
|
| 171 |
+
*/
|
| 172 |
+
protected function isAuthenticate($username, $password)
|
| 173 |
+
{
|
| 174 |
+
$config = Mage::getStoreConfigFlag('admin/security/use_case_sensitive_login');
|
| 175 |
+
$result = false;
|
| 176 |
+
$user = Mage::getModel('admin/user')->loadByUsername($username);
|
| 177 |
+
try {
|
| 178 |
+
$sensitive = ($config) ? $username == $user->getUsername() : true;
|
| 179 |
+
if ($sensitive && $user->getId() && Mage::helper('core')->validateHash($password, $user->getPassword())) {
|
| 180 |
+
|
| 181 |
+
if ($user->getIsActive() != '1') {
|
| 182 |
+
Mage::throwException(Mage::helper('magemobapp')->__('This account is inactive.'));
|
| 183 |
+
}
|
| 184 |
+
if (!$user->hasAssigned2Role($user->getId())) {
|
| 185 |
+
$result = false;
|
| 186 |
+
} else {
|
| 187 |
+
$result = true;
|
| 188 |
+
}
|
| 189 |
+
}
|
| 190 |
+
}
|
| 191 |
+
catch (Mage_Core_Exception $e) {
|
| 192 |
+
$user->unsetData();
|
| 193 |
+
throw $e;
|
| 194 |
+
}
|
| 195 |
+
return $result;
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
/**
|
| 200 |
+
* Process Login Data from multipal class as per requirement.
|
| 201 |
+
* @param login username
|
| 202 |
+
* @return process array
|
| 203 |
+
*/
|
| 204 |
+
public function loginDataProcess($username = null)
|
| 205 |
+
{
|
| 206 |
+
|
| 207 |
+
//get session id
|
| 208 |
+
$session = Mage::getSingleton('admin/session');
|
| 209 |
+
$sessionId = $session->getSessionId();
|
| 210 |
+
|
| 211 |
+
//store Data from storeinfo class
|
| 212 |
+
$subStoreData = Mage::getModel('magemobapp/storeinfo')->getWebsite();
|
| 213 |
+
|
| 214 |
+
$defaultStoreName = $_SERVER['HTTP_HOST'];
|
| 215 |
+
|
| 216 |
+
$subStore = array();
|
| 217 |
+
|
| 218 |
+
foreach ($subStoreData as $subStoreEach) {
|
| 219 |
+
$subStore[] = ($subStoreEach['name'] . '=' . $subStoreEach['default_store_id']);
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
$defaultStore = explode('=', $subStore[0]);
|
| 223 |
+
|
| 224 |
+
$subStoreArray = implode("||", $subStore);
|
| 225 |
+
|
| 226 |
+
$params['store'] = Mage::getModel('magemobapp/storeinfo')->getStoreId();
|
| 227 |
+
$store_id = '';
|
| 228 |
+
if (isset($params['store']) && $params['store'] != '') {
|
| 229 |
+
$store_id = $params['store'];
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
$path = Mage::getStoreConfig('design/header/logo_src', $store_id);
|
| 233 |
+
//get skin path
|
| 234 |
+
$skinBase = Mage::getDesign()->getSkinBaseDir() . DS . $path;
|
| 235 |
+
|
| 236 |
+
$path = Mage::getDesign()->getSkinUrl($path);
|
| 237 |
+
|
| 238 |
+
if (!file_exists($skinBase)) {
|
| 239 |
+
$storeLogo = '';
|
| 240 |
+
|
| 241 |
+
} else {
|
| 242 |
+
$data = file_get_contents($path);
|
| 243 |
+
$datapath = explode('.', $path);
|
| 244 |
+
$modifypath = end($datapath);
|
| 245 |
+
$extension = strtolower($modifypath);
|
| 246 |
+
$storeLogo = base64_encode($data);
|
| 247 |
+
$storeLogo = 'data:image/' . $extension . ';base64,' . $storeLogo;
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
$reportingDays = Mage::getStoreConfig('magemobapp/settings/reporting_days');
|
| 251 |
+
$notification_enabled = Mage::getStoreConfig('magemobapp/settings/notification_enabled');
|
| 252 |
+
$update_frequency = Mage::getStoreConfig('magemobapp/settings/update_frequency');
|
| 253 |
+
$last_update_time = date('Y-m-d H:i:s');
|
| 254 |
+
|
| 255 |
+
$this->_dataArray = array(
|
| 256 |
+
'session_id' => $sessionId,
|
| 257 |
+
'store_info' => array(
|
| 258 |
+
'store_user_name' => $username,
|
| 259 |
+
'store_label' => 'Demo Store',
|
| 260 |
+
'sub_stores' => $subStoreArray,
|
| 261 |
+
'default_store' => $defaultStore[1],
|
| 262 |
+
'store_logo' => $storeLogo,
|
| 263 |
+
'reporting_days' => $reportingDays,
|
| 264 |
+
'notification' => $notification_enabled,
|
| 265 |
+
'update_frequency' => $update_frequency,
|
| 266 |
+
'last_update_time' => $last_update_time
|
| 267 |
+
)
|
| 268 |
+
);
|
| 269 |
+
return $this->_dataArray;
|
| 270 |
+
}
|
| 271 |
+
}
|
app/code/community/Oscprofessionals/Magemobapp/Model/Logoff.php
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
*
|
| 4 |
+
* @category Oscprofessionals
|
| 5 |
+
* @package Oscprofessionals_Magemobapp
|
| 6 |
+
* @author Oscprofessionals Team <oscpteam@oscprofessionals.com>
|
| 7 |
+
*/
|
| 8 |
+
class Oscprofessionals_Magemobapp_Model_Logoff
|
| 9 |
+
{
|
| 10 |
+
|
| 11 |
+
public function __construct()
|
| 12 |
+
{
|
| 13 |
+
$this->_helper = Mage::helper('magemobapp');
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* logoff process
|
| 18 |
+
*/
|
| 19 |
+
public function logoff()
|
| 20 |
+
{
|
| 21 |
+
//set time before logout
|
| 22 |
+
if(Mage::getSingleton('admin/session', array('name' => 'adminhtml'))->isLoggedIn()){
|
| 23 |
+
$this->saveLogout();
|
| 24 |
+
}
|
| 25 |
+
//clear all datas
|
| 26 |
+
Mage::getSingleton('admin/session', array('name' => 'adminhtml'))
|
| 27 |
+
->getCookie()->delete(
|
| 28 |
+
Mage::getSingleton('admin/session', array('name' => 'adminhtml'))
|
| 29 |
+
->getSessionName());
|
| 30 |
+
Mage::getSingleton('admin/session', array('name' => 'adminhtml'))->unsetAll();
|
| 31 |
+
Mage::getSingleton('adminhtml/session')->unsetAll();
|
| 32 |
+
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* save config for earch admin time logged out
|
| 37 |
+
*/
|
| 38 |
+
public function saveLogout(){
|
| 39 |
+
$username = Mage::getSingleton('admin/session')->getUser()->getUsername();
|
| 40 |
+
$date = Mage::getModel('core/date')->gmtDate(); //get GMT date time
|
| 41 |
+
$this->saveSetting($date, 'logout_'.$username); //logout time code is username of admin
|
| 42 |
+
}
|
| 43 |
+
/**
|
| 44 |
+
* save your config value
|
| 45 |
+
* @param type $value is value
|
| 46 |
+
* @param string $code is path or code
|
| 47 |
+
*/
|
| 48 |
+
public function saveSetting($value, $code = ''){
|
| 49 |
+
$setting_path = '';
|
| 50 |
+
if($code == ''){
|
| 51 |
+
$setting_path = $value;
|
| 52 |
+
}else{
|
| 53 |
+
$setting_path = $code;
|
| 54 |
+
}
|
| 55 |
+
if(is_null($value)) $value = '';
|
| 56 |
+
Mage::getModel('core/config')->saveConfig($setting_path, $value);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
}
|
app/code/community/Oscprofessionals/Magemobapp/Model/Notification.php
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
*
|
| 4 |
+
* @category Oscprofessionals
|
| 5 |
+
* @package Oscprofessionals_Magemobapp
|
| 6 |
+
* @author Oscprofessionals Team <oscpteam@oscprofessionals.com>
|
| 7 |
+
*/
|
| 8 |
+
class Oscprofessionals_Magemobapp_Model_Notification extends Mage_Core_Model_Abstract
|
| 9 |
+
{
|
| 10 |
+
protected $_dataArray;
|
| 11 |
+
|
| 12 |
+
//Data reporting days limit from admin setting
|
| 13 |
+
const REPORTING_DAYS = 'magemobapp/settings/reporting_days';
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* @return json array
|
| 17 |
+
* @return Notification info.
|
| 18 |
+
*/
|
| 19 |
+
public function oscIndex($params)
|
| 20 |
+
{
|
| 21 |
+
return $this->getNotification($params);
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* Get Notification info
|
| 26 |
+
* @return Notification (array)
|
| 27 |
+
*/
|
| 28 |
+
function getNotification($params)
|
| 29 |
+
{
|
| 30 |
+
$finalNotificationArr = array();
|
| 31 |
+
$orderNotification = '';
|
| 32 |
+
$healthNotification = '';
|
| 33 |
+
$orderNotification = $this->orderNotification($params);
|
| 34 |
+
|
| 35 |
+
$healthNotification = $this->healthNotification();
|
| 36 |
+
$websiteNotification = $this->websiteNotification();
|
| 37 |
+
|
| 38 |
+
$finalNotificationArr['notification'] = array();
|
| 39 |
+
|
| 40 |
+
if ($orderNotification != '') {
|
| 41 |
+
$order = Mage::getModel('magemobapp/orders');
|
| 42 |
+
$newOrdercount = $order->orderCount('today');
|
| 43 |
+
$finalNotificationArr['notification']['order'] = array(
|
| 44 |
+
'badge' => '1',
|
| 45 |
+
'label' => 'New Order received',
|
| 46 |
+
'totalTodaysOrder' => $newOrdercount,
|
| 47 |
+
'description' => $orderNotification
|
| 48 |
+
);
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
if (sizeof($healthNotification) > 0) {
|
| 52 |
+
$finalNotificationArr['notification']['sitehealth'] = array(
|
| 53 |
+
'badge' => '2',
|
| 54 |
+
'label' => 'Site Health Monitor',
|
| 55 |
+
'description' => $healthNotification
|
| 56 |
+
);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
if (sizeof($websiteNotification) > 0) {
|
| 60 |
+
$finalNotificationArr['notification']['webpage'] = array(
|
| 61 |
+
'badge' => '3',
|
| 62 |
+
'label' => 'Web Page Monitor',
|
| 63 |
+
'description' => $websiteNotification
|
| 64 |
+
);
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
$finalNotificationArr['last_update_time'] = date('Y-m-d H:i:s');
|
| 68 |
+
|
| 69 |
+
$this->_dataArray = $finalNotificationArr;
|
| 70 |
+
return $this->_dataArray;
|
| 71 |
+
}
|
| 72 |
+
function orderNotification($params)
|
| 73 |
+
{
|
| 74 |
+
$ordernotify = Mage::getModel('magemobapp/orders')->getOrderNotificationList($params);
|
| 75 |
+
if ($ordernotify) {
|
| 76 |
+
$ordernotify = 'You have received ' . $ordernotify . ' new order.';
|
| 77 |
+
return $ordernotify;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
}
|
| 81 |
+
function websiteNotification()
|
| 82 |
+
{
|
| 83 |
+
$notification_enabled = Mage::getStoreConfig('magemobapp/settings/notification_enabled');
|
| 84 |
+
if ($notification_enabled == 1) {
|
| 85 |
+
|
| 86 |
+
$website_enabled = Mage::getStoreConfig('magemobapp/sitehealth/website_enabled');
|
| 87 |
+
|
| 88 |
+
if ($website_enabled == 1) {
|
| 89 |
+
$websiteNotification = Mage::getModel('magemobapp/storeinfo')->getWebsiteNotification();
|
| 90 |
+
|
| 91 |
+
if ($websiteNotification != '') {
|
| 92 |
+
$websiteNotification = substr($websiteNotification, 0, (sizeOF($websiteNotification) - 3));
|
| 93 |
+
$websiteNotification = explode('::', $websiteNotification);
|
| 94 |
+
return $websiteNotification;
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
else {
|
| 99 |
+
return array();
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
function healthNotification()
|
| 103 |
+
{
|
| 104 |
+
$notification_enabled = Mage::getStoreConfig('magemobapp/settings/notification_enabled');
|
| 105 |
+
$server_enabled = Mage::getStoreConfig('magemobapp/sitehealth/server_enabled');
|
| 106 |
+
$logtable_enabled = Mage::getStoreConfig('magemobapp/sitehealth/logtable_enabled');
|
| 107 |
+
$index_enabled = Mage::getStoreConfig('magemobapp/sitehealth/index_enabled');
|
| 108 |
+
$cpustatus = '';
|
| 109 |
+
$logNote = '';
|
| 110 |
+
$indexNote = '';
|
| 111 |
+
|
| 112 |
+
if ($notification_enabled == 1) {
|
| 113 |
+
if ($server_enabled == 1) {
|
| 114 |
+
$cpustatus = Mage::getModel('magemobapp/storeinfo')->getCPUMemoryUsageNotification();
|
| 115 |
+
}
|
| 116 |
+
if ($logtable_enabled == 1) {
|
| 117 |
+
$logNote = Mage::getModel('magemobapp/stock')->getLogTableNotification();
|
| 118 |
+
}
|
| 119 |
+
if ($index_enabled == 1) {
|
| 120 |
+
$indexNote = Mage::getModel('magemobapp/storeinfo')->getIndexingStatusNotification();
|
| 121 |
+
}
|
| 122 |
+
$notification = $logNote . $indexNote . $cpustatus;
|
| 123 |
+
$notification = substr($notification, 0, (sizeOF($notification) - 3));
|
| 124 |
+
$healthNotification = explode('::', $notification);
|
| 125 |
+
|
| 126 |
+
}
|
| 127 |
+
return $healthNotification;
|
| 128 |
+
}
|
| 129 |
+
}
|
app/code/community/Oscprofessionals/Magemobapp/Model/Orders.php
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
*
|
| 4 |
+
* @category Oscprofessionals
|
| 5 |
+
* @package Oscprofessionals_Magemobapp
|
| 6 |
+
* @author Oscprofessionals Team <oscpteam@oscprofessionals.com>
|
| 7 |
+
*/
|
| 8 |
+
class Oscprofessionals_Magemobapp_Model_Orders extends Mage_Core_Model_Abstract
|
| 9 |
+
{
|
| 10 |
+
protected $_dataArray;
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* @return json array
|
| 14 |
+
* @return orders info (array)
|
| 15 |
+
*/
|
| 16 |
+
public function oscIndex($params)
|
| 17 |
+
{
|
| 18 |
+
|
| 19 |
+
return $this->getOrderInfo($params['order_id']);
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Get store Order Count
|
| 24 |
+
* @return (string) count
|
| 25 |
+
*/
|
| 26 |
+
public function orderCount($days)
|
| 27 |
+
{
|
| 28 |
+
|
| 29 |
+
switch ($days) {
|
| 30 |
+
|
| 31 |
+
case "today":
|
| 32 |
+
//get Todays Date
|
| 33 |
+
$fromDate = Mage::helper('magemobapp')->getTodaysDate();
|
| 34 |
+
break;
|
| 35 |
+
case "lastWeek":
|
| 36 |
+
//get 1 week Back date
|
| 37 |
+
$fromDate = Mage::helper('magemobapp')->getLastWeekDate();
|
| 38 |
+
break;
|
| 39 |
+
case "lastMonth":
|
| 40 |
+
//get 1 month Back date
|
| 41 |
+
$fromDate = Mage::helper('magemobapp')->getMonthBackDate();
|
| 42 |
+
break;
|
| 43 |
+
default:
|
| 44 |
+
//get reporting date
|
| 45 |
+
$fromDate = Mage::helper('magemobapp')->getReportingDate();
|
| 46 |
+
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
$storeInfo = Mage::getModel('magemobapp/storeinfo');
|
| 50 |
+
// store id
|
| 51 |
+
$storeId = $storeInfo->getStoreId();
|
| 52 |
+
// store id array
|
| 53 |
+
$storeIds = $storeInfo->getStoreIds($storeId);
|
| 54 |
+
|
| 55 |
+
$orderCollection = Mage::getModel('sales/order')->getCollection();
|
| 56 |
+
|
| 57 |
+
if (isset($storeId) && $storeId != '') {
|
| 58 |
+
$orderCollection->addAttributeToFilter('store_id', array(
|
| 59 |
+
'in' => $storeIds,
|
| 60 |
+
));
|
| 61 |
+
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
$orderCollection->addAttributeToFilter('created_at', array(
|
| 65 |
+
'from' => $fromDate
|
| 66 |
+
));
|
| 67 |
+
$orderCount = $orderCollection->count(); //orders count
|
| 68 |
+
|
| 69 |
+
return $orderCount;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
/**
|
| 74 |
+
* Get store Total sales with currency.
|
| 75 |
+
* @return (string) sales
|
| 76 |
+
*/
|
| 77 |
+
public function todaysSalesTotal()
|
| 78 |
+
{
|
| 79 |
+
|
| 80 |
+
//get todays Date
|
| 81 |
+
$fromDate = Mage::helper('magemobapp')->getTodaysDate();
|
| 82 |
+
|
| 83 |
+
$storeId = Mage::getModel('magemobapp/storeinfo')->getStoreId();
|
| 84 |
+
|
| 85 |
+
$collection = Mage::getResourceModel('sales/order_collection')->addAttributeToFilter('created_at', array(
|
| 86 |
+
'from' => $fromDate
|
| 87 |
+
));
|
| 88 |
+
|
| 89 |
+
if ($storeId != 0) {
|
| 90 |
+
$collection->addAttributeToFilter('store_id', $storeId); //fill store
|
| 91 |
+
}
|
| 92 |
+
//$collection;
|
| 93 |
+
|
| 94 |
+
$collection->addAttributeToSelect('base_grand_total')->addAttributeToSelect('base_total_refunded')->addAttributeToSelect('base_total_paid');
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
$data = $collection->getData();
|
| 98 |
+
$total = 0;
|
| 99 |
+
foreach ($data as $eachData) {
|
| 100 |
+
if (isset($eachData['status']) && $eachData['status'] == 'complete') {
|
| 101 |
+
if ($eachData['base_total_refunded'] == '') {
|
| 102 |
+
$total += (float) $eachData['base_total_paid'];
|
| 103 |
+
} else {
|
| 104 |
+
$total += (float) $eachData['base_total_paid'] - (float) $eachData['base_total_refunded'];
|
| 105 |
+
}
|
| 106 |
+
} else {
|
| 107 |
+
$total += (float) $eachData['base_grand_total'];
|
| 108 |
+
}
|
| 109 |
+
}
|
| 110 |
+
return Mage::helper('core')->currency($total, true, false);
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
/**
|
| 115 |
+
* Get order list
|
| 116 |
+
* @return order list (array)
|
| 117 |
+
*/
|
| 118 |
+
public function getOrderList()
|
| 119 |
+
{
|
| 120 |
+
|
| 121 |
+
// store id
|
| 122 |
+
$storeId = Mage::getModel('magemobapp/storeinfo')->getStoreId();
|
| 123 |
+
|
| 124 |
+
//get reporting date
|
| 125 |
+
$fromDate = Mage::helper('magemobapp')->getReportingDate();
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
$orderCollection = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('created_at', array(
|
| 129 |
+
'from' => $fromDate
|
| 130 |
+
))->addAttributeToSort('created_at', 'desc');
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
if ($storeId != 0) {
|
| 134 |
+
$orderCollection->addAttributeToFilter('store_id', $storeId);
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
foreach ($orderCollection as $_order) {
|
| 138 |
+
$orderTime = explode(" ", $_order->getCreatedAt());
|
| 139 |
+
$this->_dataArray[] = array(
|
| 140 |
+
'order_id' => $_order->getId(),
|
| 141 |
+
'increment_id' => $_order->getIncrementId(),
|
| 142 |
+
'order_status' => $_order->getStatus(),
|
| 143 |
+
'order_date' => $_order->getCreatedAt(),
|
| 144 |
+
'order_time' => $orderTime[1],
|
| 145 |
+
'customer_name' => $_order->getCustomerName(),
|
| 146 |
+
'order_total' => Mage::helper('core')->currency($_order->getGrandTotal(), true, false), //order total with currency
|
| 147 |
+
'order_total_value' => number_format($_order->getGrandTotal(), 2)
|
| 148 |
+
);
|
| 149 |
+
}
|
| 150 |
+
//Mage::log($this->_dataArray,null,'orderarray.log');
|
| 151 |
+
return array(
|
| 152 |
+
'last_update_time' => date('Y-m-d H:i:s'),
|
| 153 |
+
'orders' => $this->_dataArray
|
| 154 |
+
);
|
| 155 |
+
}
|
| 156 |
+
public function getOrderNotificationList($params)
|
| 157 |
+
{
|
| 158 |
+
|
| 159 |
+
$fromDate = $params['last_update_time'];
|
| 160 |
+
$storeId = $params['store'];
|
| 161 |
+
|
| 162 |
+
$orderCollection = Mage::getModel('sales/order')->getCollection();
|
| 163 |
+
|
| 164 |
+
if (isset($storeId) && $storeId != 0) {
|
| 165 |
+
$orderCollection->addAttributeToFilter('store_id', $storeId);
|
| 166 |
+
}
|
| 167 |
+
$orderCollection->addAttributeToFilter('created_at', array(
|
| 168 |
+
'gt' => $fromDate
|
| 169 |
+
));
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
$notification = '';
|
| 173 |
+
$notification = $orderCollection->count();
|
| 174 |
+
|
| 175 |
+
if ($notification > 0) {
|
| 176 |
+
return $notification;
|
| 177 |
+
}
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
/**
|
| 181 |
+
* Get order info
|
| 182 |
+
* @return order info (array)
|
| 183 |
+
*/
|
| 184 |
+
public function getOrderInfo($orderId = null)
|
| 185 |
+
{
|
| 186 |
+
|
| 187 |
+
$orderCollection = Mage::getModel('sales/order')->load($orderId);
|
| 188 |
+
$_totalObject = Mage::getBlockSingleton('magemobapp/order_totals');
|
| 189 |
+
$_totalObject->setOrder($orderCollection);
|
| 190 |
+
$_totalObject->initTotals();
|
| 191 |
+
$totals = $_totalObject->getTotals();
|
| 192 |
+
|
| 193 |
+
//total info in array data
|
| 194 |
+
foreach ($totals as $_total) {
|
| 195 |
+
|
| 196 |
+
$totalArray[] = $_total->getCode() . "=" . Mage::helper('core')->currency($_total->getValue(), true, false);
|
| 197 |
+
//with currency
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
//arrange total Data
|
| 201 |
+
$totalData = implode("||", $totalArray);
|
| 202 |
+
$ordered_items = $orderCollection->getAllItems();
|
| 203 |
+
|
| 204 |
+
$orderedItems = array();
|
| 205 |
+
foreach ($ordered_items as $item) {
|
| 206 |
+
|
| 207 |
+
if ($item['parent_item_id'] == NULL) {
|
| 208 |
+
|
| 209 |
+
$orderedItems[] = array(
|
| 210 |
+
'product_id' => $item->getItemId(),
|
| 211 |
+
'product_name' => $item->getName(),
|
| 212 |
+
'product_price' => Mage::helper('core')->currency($item->getPrice(), true, false),
|
| 213 |
+
'product_qty' => number_format($item->getQtyOrdered())
|
| 214 |
+
);
|
| 215 |
+
}
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
// collect billing address
|
| 219 |
+
$billingAddress = '';
|
| 220 |
+
if (is_object($orderCollection->getBillingAddress())) {
|
| 221 |
+
$countryId = $orderCollection->getBillingAddress()->getCountryId();
|
| 222 |
+
$billingAddress = $orderCollection->getBillingAddress()->getData('street') . ",";
|
| 223 |
+
$billingAddress .= $orderCollection->getBillingAddress()->getCity() . ",";
|
| 224 |
+
$billingAddress .= $orderCollection->getBillingAddress()->getRegion() . ",";
|
| 225 |
+
$billingAddress .= $orderCollection->getBillingAddress()->getPostcode() . ",";
|
| 226 |
+
$billingAddress .= Mage::app()->getLocale()->getCountryTranslation($countryId);
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
// collect shipping address
|
| 230 |
+
$shippingAddress = '';
|
| 231 |
+
if (is_object($orderCollection->getShippingAddress())) {
|
| 232 |
+
$countryId = $orderCollection->getShippingAddress()->getCountryId();
|
| 233 |
+
$shippingAddress = $orderCollection->getShippingAddress()->getData('street') . ",";
|
| 234 |
+
$shippingAddress .= $orderCollection->getShippingAddress()->getCity() . ",";
|
| 235 |
+
$shippingAddress .= $orderCollection->getShippingAddress()->getRegion() . ",";
|
| 236 |
+
$shippingAddress .= $orderCollection->getShippingAddress()->getPostcode() . ",";
|
| 237 |
+
$shippingAddress .= Mage::app()->getLocale()->getCountryTranslation($countryId);
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
$orderTime = explode(" ", $orderCollection->getCreatedAt());
|
| 242 |
+
$this->_dataArray = array(
|
| 243 |
+
'order_id' => $orderCollection->getId(),
|
| 244 |
+
'increment_id' => $orderCollection->getIncrementId(),
|
| 245 |
+
'order_status' => $orderCollection->getStatus(),
|
| 246 |
+
'order_date' => $orderCollection->getCreatedAt(),
|
| 247 |
+
'order_time' => $orderTime[1],
|
| 248 |
+
'customer_name' => $orderCollection->getCustomerName(),
|
| 249 |
+
'customer_phone_no' => $orderCollection->getBillingAddress()->getTelephone(),
|
| 250 |
+
'billing_address' => $billingAddress,
|
| 251 |
+
'shipping_address' => $shippingAddress,
|
| 252 |
+
'order_total' => $totalData,
|
| 253 |
+
'order_product' => $orderedItems
|
| 254 |
+
);
|
| 255 |
+
|
| 256 |
+
//return ordered info data
|
| 257 |
+
return $this->_dataArray;
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
/**
|
| 261 |
+
* Get Order List
|
| 262 |
+
* @return order List with date filter info (array)
|
| 263 |
+
*/
|
| 264 |
+
public function getTodaysOrderList()
|
| 265 |
+
{
|
| 266 |
+
$dir = '';
|
| 267 |
+
$storeId = Mage::getModel('magemobapp/storeinfo')->getStoreId();
|
| 268 |
+
//get Todays Date from helper
|
| 269 |
+
$fromDate = Mage::helper('magemobapp')->getTodaysDate();
|
| 270 |
+
|
| 271 |
+
$orderCollection = Mage::getModel('sales/order')->getCollection();
|
| 272 |
+
|
| 273 |
+
$orderCollection->addAttributeToFilter('created_at', array(
|
| 274 |
+
'from' => $fromDate
|
| 275 |
+
));
|
| 276 |
+
$reverseDir = ($dir == 'DESC') ? 'ASC' : 'DESC';
|
| 277 |
+
$orderCollection->getSelect()->order('increment_id ' . $reverseDir);
|
| 278 |
+
if (isset($storeId) && $storeId != 0) {
|
| 279 |
+
$orderCollection->addAttributeToFilter('store_id', $storeId);
|
| 280 |
+
} /*else {
|
| 281 |
+
$orderCollection = Mage::getModel('sales/order')->getCollection();
|
| 282 |
+
}*/
|
| 283 |
+
|
| 284 |
+
foreach ($orderCollection as $_order) {
|
| 285 |
+
$orderTime = explode(" ", $_order->getCreatedAt());
|
| 286 |
+
$this->_dataArray[] = array(
|
| 287 |
+
'order_id' => $_order->getId(),
|
| 288 |
+
'increment_id' => $_order->getIncrementId(),
|
| 289 |
+
'order_status' => $_order->getStatus(),
|
| 290 |
+
'order_date' => $_order->getCreatedAt(),
|
| 291 |
+
'order_time' => $orderTime[1],
|
| 292 |
+
'customer_name' => $_order->getCustomerName(),
|
| 293 |
+
'order_total' => Mage::helper('core')->currency($_order->getGrandTotal(), true, false), //order total with currency
|
| 294 |
+
'order_total_value' => $_order->getGrandTotal()
|
| 295 |
+
);
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
return array(
|
| 299 |
+
'last_update_time' => date('Y-m-d H:i:s'),
|
| 300 |
+
'orders' => $this->_dataArray
|
| 301 |
+
);
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
}
|
app/code/community/Oscprofessionals/Magemobapp/Model/Osc.php
ADDED
|
@@ -0,0 +1,191 @@
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
*
|
| 4 |
+
* @category Oscprofessionals
|
| 5 |
+
* @package Oscprofessionals_Magemobapp
|
| 6 |
+
* @author Oscprofessionals Team <oscpteam@oscprofessionals.com>
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
//osc block class for call model class file according to action.
|
| 10 |
+
class Oscprofessionals_Magemobapp_Model_Osc extends Mage_Core_Model_Abstract
|
| 11 |
+
{
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* @var Oscprofessionals_Magemobapp_Helper_Data
|
| 15 |
+
*/
|
| 16 |
+
protected $_helper;
|
| 17 |
+
|
| 18 |
+
public function __construct()
|
| 19 |
+
{
|
| 20 |
+
$this->_helper = Mage::helper('magemobapp');
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
* Run processRequest from controller
|
| 25 |
+
* @param array $data
|
| 26 |
+
* @return mixed
|
| 27 |
+
*/
|
| 28 |
+
public function processRequest($data)
|
| 29 |
+
{
|
| 30 |
+
|
| 31 |
+
if (isset($data['action'])) {
|
| 32 |
+
try {
|
| 33 |
+
$result['message'] = '';
|
| 34 |
+
$result['error'] = 0;
|
| 35 |
+
$result['data'] = $this->processRequestRun($data);
|
| 36 |
+
}
|
| 37 |
+
catch (Exception $e) {
|
| 38 |
+
$result['error'] = 1;
|
| 39 |
+
$result['message'] = $e->getMessage();
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
return $result;
|
| 44 |
+
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
* Run processRequestRun
|
| 49 |
+
* @param array $data
|
| 50 |
+
* @return mixed
|
| 51 |
+
*/
|
| 52 |
+
public function processRequestRun($data)
|
| 53 |
+
{
|
| 54 |
+
if (empty($data['action'])) {
|
| 55 |
+
throw new Exception($this->_helper->__('No method is specified'));
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
// Check param input
|
| 59 |
+
if (!empty($data['params'])) {
|
| 60 |
+
$params = $data['params'];
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
$actionName = $data['action'];
|
| 64 |
+
|
| 65 |
+
if ($actionName == 'login') {
|
| 66 |
+
|
| 67 |
+
if (empty($params['username']) || empty($params['password'])) {
|
| 68 |
+
|
| 69 |
+
throw new Exception($this->_helper->__('Miss username or password to login'));
|
| 70 |
+
|
| 71 |
+
} else {
|
| 72 |
+
|
| 73 |
+
try {
|
| 74 |
+
return Mage::getModel('magemobapp/login')->login($params['username'], $params['password']);
|
| 75 |
+
}
|
| 76 |
+
catch (Exception $e) {
|
| 77 |
+
throw new Exception($this->_helper->__('Failed to login'));
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
}else if($actionName == 'logoff'){
|
| 81 |
+
|
| 82 |
+
try {
|
| 83 |
+
return Mage::getModel('magemobapp/logoff')->logoff();
|
| 84 |
+
}
|
| 85 |
+
catch (Exception $e) {
|
| 86 |
+
throw new Exception($this->_helper->__('Failed to logoff'));
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
if (Mage::getModel('magemobapp/login')->isCheckLogin()) {
|
| 93 |
+
|
| 94 |
+
if (!Mage::getModel('magemobapp/login')->isCheckRole()) { // if not role
|
| 95 |
+
|
| 96 |
+
throw new Exception($this->_helper->__('Access Denied.'));
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
if (empty($actionName)) {
|
| 101 |
+
throw new Exception($this->_helper->__('Invalid method.'));
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
// swich action for find class file and method
|
| 105 |
+
switch ($actionName) {
|
| 106 |
+
|
| 107 |
+
case "dashboard":
|
| 108 |
+
//call dashboard class
|
| 109 |
+
$className = 'dashboard';
|
| 110 |
+
$methodName = 'oscIndex';
|
| 111 |
+
break;
|
| 112 |
+
|
| 113 |
+
case "sitehealth":
|
| 114 |
+
//call sitehealth class
|
| 115 |
+
$className = 'sitehealth';
|
| 116 |
+
$methodName = 'oscIndex';
|
| 117 |
+
break;
|
| 118 |
+
case "notification":
|
| 119 |
+
//call notification class
|
| 120 |
+
$className = 'notification';
|
| 121 |
+
$methodName = 'oscIndex';
|
| 122 |
+
break;
|
| 123 |
+
|
| 124 |
+
case "orderslist":
|
| 125 |
+
//call order class
|
| 126 |
+
$className = 'orders';
|
| 127 |
+
$methodName = 'getOrderList';
|
| 128 |
+
break;
|
| 129 |
+
|
| 130 |
+
case "orderinfo":
|
| 131 |
+
$className = 'orders';
|
| 132 |
+
$methodName = 'oscIndex';
|
| 133 |
+
break;
|
| 134 |
+
|
| 135 |
+
case "todaysorderlist":
|
| 136 |
+
//call order class
|
| 137 |
+
$className = 'orders';
|
| 138 |
+
$methodName = 'getTodaysOrderList';
|
| 139 |
+
break;
|
| 140 |
+
|
| 141 |
+
case "customerslist":
|
| 142 |
+
//call customers class
|
| 143 |
+
$className = 'customers';
|
| 144 |
+
$methodName = 'getCustomerList';
|
| 145 |
+
break;
|
| 146 |
+
|
| 147 |
+
case "customerinfo":
|
| 148 |
+
//call customers class
|
| 149 |
+
$className = 'customers';
|
| 150 |
+
$methodName = 'oscIndex';
|
| 151 |
+
break;
|
| 152 |
+
|
| 153 |
+
case "stockalert":
|
| 154 |
+
//call stock class
|
| 155 |
+
$className = 'stock';
|
| 156 |
+
$methodName = 'oscIndex';
|
| 157 |
+
break;
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
case "abandonedlist":
|
| 161 |
+
//call customers class
|
| 162 |
+
$className = 'customers';
|
| 163 |
+
$methodName = 'getAbandonedCustomersList';
|
| 164 |
+
break;
|
| 165 |
+
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
$model = Mage::getModel('magemobapp/' . $className);
|
| 170 |
+
|
| 171 |
+
if (!$model) {
|
| 172 |
+
throw new Exception($this->_helper->__('Method not exists.'));
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
if (is_callable(array(
|
| 176 |
+
&$model,
|
| 177 |
+
$methodName
|
| 178 |
+
))) {
|
| 179 |
+
return call_user_func_array(array(
|
| 180 |
+
&$model,
|
| 181 |
+
$methodName
|
| 182 |
+
), array(
|
| 183 |
+
$params
|
| 184 |
+
)); //($param1 = array())
|
| 185 |
+
}
|
| 186 |
+
throw new Exception($this->_helper->__('Resource cannot callable.'));
|
| 187 |
+
}
|
| 188 |
+
throw new Exception($this->_helper->__('Not login.'));
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
}
|
app/code/community/Oscprofessionals/Magemobapp/Model/Sitehealth.php
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
*
|
| 4 |
+
* @category Oscprofessionals
|
| 5 |
+
* @package Oscprofessionals_Magemobapp
|
| 6 |
+
* @author Oscprofessionals Team <oscpteam@oscprofessionals.com>
|
| 7 |
+
*/
|
| 8 |
+
class Oscprofessionals_Magemobapp_Model_Sitehealth extends Mage_Core_Model_Abstract
|
| 9 |
+
{
|
| 10 |
+
protected $_dataArray;
|
| 11 |
+
public $days;
|
| 12 |
+
|
| 13 |
+
//Data reporting days limit from admin setting
|
| 14 |
+
const REPORTING_DAYS = 'magemobapp/settings/reporting_days';
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* @return json array
|
| 18 |
+
* @return sitehealth info.
|
| 19 |
+
*/
|
| 20 |
+
public function oscIndex()
|
| 21 |
+
{
|
| 22 |
+
try{
|
| 23 |
+
return $this->getSitehealthInfo();
|
| 24 |
+
}catch(Exception $e){
|
| 25 |
+
Mage::log($e->getMessage() , null, 'oscMageAdim.log');
|
| 26 |
+
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
function getSitehealthInfo()
|
| 31 |
+
{
|
| 32 |
+
$reportingDays = Mage::getStoreConfig(self::REPORTING_DAYS);
|
| 33 |
+
|
| 34 |
+
$finalArr = array();
|
| 35 |
+
$website_enabled = Mage::getStoreConfig('magemobapp/sitehealth/website_enabled');
|
| 36 |
+
$server_enabled = Mage::getStoreConfig('magemobapp/sitehealth/server_enabled');
|
| 37 |
+
$index_enabled = Mage::getStoreConfig('magemobapp/sitehealth/index_enabled');
|
| 38 |
+
$cronschedule_enabled = Mage::getStoreConfig('magemobapp/sitehealth/cronschedule_enabled');
|
| 39 |
+
$logtable_enabled = Mage::getStoreConfig('magemobapp/sitehealth/logtable_enabled');
|
| 40 |
+
|
| 41 |
+
if ($website_enabled == 1) {
|
| 42 |
+
$website_status = Mage::getModel('magemobapp/storeinfo')->getWebsiteRunningStatus();
|
| 43 |
+
$finalArr['website_status'] = $website_status;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
if ($server_enabled == 1) { //Get CPU usage and Memory Usage
|
| 47 |
+
$server_load = Mage::getModel('magemobapp/storeinfo')->getCPUMemoryUsage();
|
| 48 |
+
$finalArr['server_load'] = $server_load;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
if ($index_enabled == 1) { //get indexing status notification
|
| 52 |
+
$indexing_status = Mage::getModel('magemobapp/storeinfo')->getIndexingStatus();
|
| 53 |
+
$finalArr['indexing_status'] = $indexing_status;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
if ($cronschedule_enabled == 1) { //get cron_schedule status notification
|
| 57 |
+
$cron_schedule = Mage::getModel('magemobapp/storeinfo')->getCronScheduleInfo();
|
| 58 |
+
$finalArr['cron_schedule'] = $cron_schedule;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
if ($logtable_enabled == 1) { //get log table size increase notification
|
| 62 |
+
$log_info = Mage::getModel('magemobapp/stock')->getLogTableSizeAlert();
|
| 63 |
+
$finalArr['log_info'] = $log_info;
|
| 64 |
+
}
|
| 65 |
+
$this->_dataArray = $finalArr;
|
| 66 |
+
return $this->_dataArray;
|
| 67 |
+
}
|
| 68 |
+
}
|
app/code/community/Oscprofessionals/Magemobapp/Model/Stock.php
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
*
|
| 4 |
+
* @category Oscprofessionals
|
| 5 |
+
* @package Oscprofessionals_Magemobapp
|
| 6 |
+
* @author Oscprofessionals Team <oscpteam@oscprofessionals.com>
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
// collect all stock related Data
|
| 10 |
+
class Oscprofessionals_Magemobapp_Model_Stock extends Mage_Core_Model_Abstract
|
| 11 |
+
{
|
| 12 |
+
protected $_productArray;
|
| 13 |
+
protected $_stockAlertCount;
|
| 14 |
+
|
| 15 |
+
//stock alert qty from admin setting
|
| 16 |
+
const STOCK_ALERT = 'magemobapp/settings/stock_critical_level';
|
| 17 |
+
const TABLE_SIZE = 'magemobapp/settings/log_table_size';
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* @return json array
|
| 21 |
+
* @return inventory info (string)
|
| 22 |
+
*/
|
| 23 |
+
public function oscIndex($params)
|
| 24 |
+
{
|
| 25 |
+
return $this->getProductsStockAlert($params);
|
| 26 |
+
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* Get stock alert collection
|
| 31 |
+
* @Product array
|
| 32 |
+
*/
|
| 33 |
+
public function getProductsStockAlert($params)
|
| 34 |
+
{
|
| 35 |
+
$storeId = $params['store'];
|
| 36 |
+
$orderby = $params['orderby'];
|
| 37 |
+
$sortby = $params['sortby'];
|
| 38 |
+
|
| 39 |
+
$dir = '';
|
| 40 |
+
$stockAlertQty = Mage::getStoreConfig(self::STOCK_ALERT);
|
| 41 |
+
|
| 42 |
+
$collection = Mage::getModel('catalog/product')->getCollection()->setStoreId($storeId)->addStoreFilter($storeId)->addAttributeToSelect('*'); // select all attributes
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
if (is_array($storeId) && !empty($storeId)) {
|
| 46 |
+
$collection->addFieldToFilter('store_id', array(
|
| 47 |
+
'in' => $storeId
|
| 48 |
+
));
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
if ($params['sortby'] == 'asc') {
|
| 52 |
+
if ($params['orderby'] == 'name') {
|
| 53 |
+
$collection->addAttributeToSort('name', 'ASC');
|
| 54 |
+
} else {
|
| 55 |
+
$collection->getSelect()->joinLeft(array(
|
| 56 |
+
'_inventory_table' => 'cataloginventory_stock_item'
|
| 57 |
+
), "_inventory_table.product_id = e.entity_id ", array(
|
| 58 |
+
'qty'
|
| 59 |
+
))->order(array(
|
| 60 |
+
'_inventory_table.qty ASC'
|
| 61 |
+
));
|
| 62 |
+
$reverseDir = ($dir == 'DESC') ? 'ASC' : 'DESC';
|
| 63 |
+
$collection->getSelect()->order('qty ' . $reverseDir);
|
| 64 |
+
}
|
| 65 |
+
} else {
|
| 66 |
+
if ($params['orderby'] == 'name') {
|
| 67 |
+
$collection->addAttributeToSort('name', 'DESC');
|
| 68 |
+
} else {
|
| 69 |
+
$collection->getSelect()->joinLeft(array(
|
| 70 |
+
'_inventory_table' => 'cataloginventory_stock_item'
|
| 71 |
+
), "_inventory_table.product_id = e.entity_id ", array(
|
| 72 |
+
'qty'
|
| 73 |
+
))->order(array(
|
| 74 |
+
'_inventory_table.qty DESC'
|
| 75 |
+
));
|
| 76 |
+
$reverseDir = ($dir == 'ASC') ? 'DESC' : 'ASC';
|
| 77 |
+
$collection->getSelect()->order('qty ' . $reverseDir);
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
$this->_stockAlertCount = 0;
|
| 81 |
+
foreach ($collection as $product) {
|
| 82 |
+
$stocklevel = (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
|
| 83 |
+
|
| 84 |
+
if ($stocklevel <= $stockAlertQty && $stocklevel >= 0) {
|
| 85 |
+
$this->_productArray[] = array(
|
| 86 |
+
'product_id' => $product->getId(),
|
| 87 |
+
'product_name' => $product->getName(),
|
| 88 |
+
'product_qty' => $stocklevel
|
| 89 |
+
);
|
| 90 |
+
$this->_stockAlertCount++;
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
return $this->_productArray;
|
| 95 |
+
|
| 96 |
+
}
|
| 97 |
+
/*BOF by developer 127*/
|
| 98 |
+
/*
|
| 99 |
+
** Get log table size alert
|
| 100 |
+
*
|
| 101 |
+
*/
|
| 102 |
+
public function getLogTableSizeAlert()
|
| 103 |
+
{
|
| 104 |
+
$logTableSize = Mage::getStoreConfig('magemobapp/sitehealth/log_table_size');
|
| 105 |
+
|
| 106 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 107 |
+
|
| 108 |
+
$tables = array(
|
| 109 |
+
'log_customer',
|
| 110 |
+
'log_quote',
|
| 111 |
+
'log_summary',
|
| 112 |
+
'log_summary_type',
|
| 113 |
+
'log_url',
|
| 114 |
+
'log_url_info',
|
| 115 |
+
'log_visitor',
|
| 116 |
+
'log_visitor_info',
|
| 117 |
+
'log_visitor_online'
|
| 118 |
+
);
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
$log_table_result = array();
|
| 122 |
+
$j = 0;
|
| 123 |
+
foreach ($tables as $table) {
|
| 124 |
+
|
| 125 |
+
if ($connection->isTableExists($table)) {
|
| 126 |
+
$select = $connection->select()->from($table);
|
| 127 |
+
$abc = $connection->fetchAll($select);
|
| 128 |
+
$size = count($abc);
|
| 129 |
+
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
if ($size >= $logTableSize) {
|
| 133 |
+
$msg = 'High';
|
| 134 |
+
} else {
|
| 135 |
+
$msg = 'Normal';
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
$log_table_result[$j]['tablename'] = $table;
|
| 139 |
+
$log_table_result[$j]['count'] = $size;
|
| 140 |
+
$log_table_result[$j]['status'] = $msg;
|
| 141 |
+
$j++;
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
return $log_table_result;
|
| 145 |
+
|
| 146 |
+
}
|
| 147 |
+
/*
|
| 148 |
+
** Get log table size Notification
|
| 149 |
+
*
|
| 150 |
+
*/
|
| 151 |
+
public function getLogTableNotification()
|
| 152 |
+
{
|
| 153 |
+
$notify = $this->getLogTableSizeAlert();
|
| 154 |
+
|
| 155 |
+
$notification = '';
|
| 156 |
+
|
| 157 |
+
$total = 0;
|
| 158 |
+
foreach ($notify as $statuskey => $statusval) {
|
| 159 |
+
$stval = $statusval['status'];
|
| 160 |
+
|
| 161 |
+
if ($stval == 'High') {
|
| 162 |
+
$total++;
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
}
|
| 166 |
+
if ($total) {
|
| 167 |
+
$notification = 'Currently ' . $total . ' log tables are on critical level.::';
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
return $notification;
|
| 171 |
+
}
|
| 172 |
+
/**
|
| 173 |
+
* Get count stock alert
|
| 174 |
+
* @return stock count
|
| 175 |
+
*/
|
| 176 |
+
public function getCountStockAlert()
|
| 177 |
+
{
|
| 178 |
+
$params['store'] = Mage::getModel('magemobapp/storeinfo')->getStoreId();
|
| 179 |
+
$this->getProductsStockAlert($params['store']);
|
| 180 |
+
return $this->_stockAlertCount;
|
| 181 |
+
}
|
| 182 |
+
}
|
app/code/community/Oscprofessionals/Magemobapp/Model/Storeinfo.php
ADDED
|
@@ -0,0 +1,405 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
*
|
| 4 |
+
* @category Oscprofessionals
|
| 5 |
+
* @package Oscprofessionals_Magemobapp
|
| 6 |
+
* @author Oscprofessionals Team <oscpteam@oscprofessionals.com>
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
class Oscprofessionals_Magemobapp_Model_Storeinfo extends Mage_Core_Model_Abstract
|
| 10 |
+
{
|
| 11 |
+
protected $_storeList = '';
|
| 12 |
+
protected $_storeId = '';
|
| 13 |
+
protected $_storeIds = '';
|
| 14 |
+
/**
|
| 15 |
+
* @return json array
|
| 16 |
+
* @return inventory info (array)
|
| 17 |
+
*/
|
| 18 |
+
public function oscIndex($params)
|
| 19 |
+
{
|
| 20 |
+
return $this->getSubStore();
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
* Get sub store collection
|
| 25 |
+
* @return array
|
| 26 |
+
*/
|
| 27 |
+
public function getSubStore()
|
| 28 |
+
{
|
| 29 |
+
$stores = Mage::app()->getStores(true);
|
| 30 |
+
|
| 31 |
+
foreach ($stores as $store) {
|
| 32 |
+
$name = $store->getName();
|
| 33 |
+
$id = (int) $store->getId();
|
| 34 |
+
$this->_storeList[] = array(
|
| 35 |
+
'store_id' => $id,
|
| 36 |
+
'store_name' => $name
|
| 37 |
+
);
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
return $this->_storeList;
|
| 41 |
+
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* Get store Id
|
| 46 |
+
* @return Store ID
|
| 47 |
+
*/
|
| 48 |
+
|
| 49 |
+
public function getStoreId()
|
| 50 |
+
{
|
| 51 |
+
$params = Mage::app()->getRequest()->getPost('params');
|
| 52 |
+
if (isset($params['store']) && $params['store'] != '') {
|
| 53 |
+
$this->_storeId = $params['store']; //$storeId = $_POST;
|
| 54 |
+
return $this->_storeId;
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
/**
|
| 59 |
+
* Get website Id
|
| 60 |
+
* @return Website ID
|
| 61 |
+
*/
|
| 62 |
+
public function getWebsite()
|
| 63 |
+
{
|
| 64 |
+
$visitors = Mage::getModel("core/store_group")->getCollection();
|
| 65 |
+
$result = array();
|
| 66 |
+
foreach ($visitors as $val) {
|
| 67 |
+
$result[] = $val->toArray();
|
| 68 |
+
}
|
| 69 |
+
return $result;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
/**
|
| 73 |
+
* Get website Id
|
| 74 |
+
* @return Website ID
|
| 75 |
+
*/
|
| 76 |
+
public function getStoreIds($storeId = null)
|
| 77 |
+
{
|
| 78 |
+
$websiteId = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
|
| 79 |
+
$website = Mage::getModel('core/website')->load($websiteId);
|
| 80 |
+
$this->_storeIds = $website->getStoreIds();
|
| 81 |
+
return $this->_storeIds;
|
| 82 |
+
}
|
| 83 |
+
/**
|
| 84 |
+
* Get indexing status
|
| 85 |
+
* @return indexing status (array)
|
| 86 |
+
*/
|
| 87 |
+
public function getIndexingStatus()
|
| 88 |
+
{
|
| 89 |
+
$resArr = array();
|
| 90 |
+
$collection = Mage::getResourceModel('index/process_collection');
|
| 91 |
+
foreach ($collection as $key => $item) {
|
| 92 |
+
if (!$item->getIndexer()->isVisible()) {
|
| 93 |
+
$collection->removeItemByKey($key);
|
| 94 |
+
continue;
|
| 95 |
+
}
|
| 96 |
+
$item->setName($item->getIndexer()->getName());
|
| 97 |
+
$item->setDescription($item->getIndexer()->getDescription());
|
| 98 |
+
$item->setUpdateRequired($item->getUnprocessedEventsCollection()->count() > 0 ? 1 : 0);
|
| 99 |
+
if ($item->isLocked()) {
|
| 100 |
+
$item->setStatus(Mage_Index_Model_Process::STATUS_RUNNING);
|
| 101 |
+
}
|
| 102 |
+
$resArr[] = $item->toArray();
|
| 103 |
+
}
|
| 104 |
+
return $resArr;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
public function getIndexingStatusNotification()
|
| 108 |
+
{
|
| 109 |
+
$notify = $this->getIndexingStatus();
|
| 110 |
+
$notification = '';
|
| 111 |
+
$total = 0;
|
| 112 |
+
foreach ($notify as $statuskey => $statusval) {
|
| 113 |
+
$stval = $statusval['status'];
|
| 114 |
+
|
| 115 |
+
if ($stval == 'require_reindex') {
|
| 116 |
+
$total++;
|
| 117 |
+
}
|
| 118 |
+
}
|
| 119 |
+
if ($total) {
|
| 120 |
+
if($total >1){
|
| 121 |
+
$notification = 'Currently ' . $total . ' indexing are required.::';
|
| 122 |
+
}else{
|
| 123 |
+
$notification = 'Currently ' . $total . ' indexing is required.::';
|
| 124 |
+
}
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
return $notification;
|
| 128 |
+
}
|
| 129 |
+
/**
|
| 130 |
+
* Get Cron schedule info
|
| 131 |
+
* @return onlinevisitors (array)
|
| 132 |
+
*/
|
| 133 |
+
public function getCronScheduleInfo()
|
| 134 |
+
{
|
| 135 |
+
$modelCollection = $this->getAllCodes();
|
| 136 |
+
|
| 137 |
+
$cronCollection = Mage::getModel('cron/schedule')->getCollection();
|
| 138 |
+
$cronCollection->getSelect()->group('job_code');
|
| 139 |
+
|
| 140 |
+
$result = array();
|
| 141 |
+
foreach ($cronCollection as $val) {
|
| 142 |
+
$modelCode = $val->toArray();
|
| 143 |
+
if (isset($modelCollection[$modelCode['job_code']]) && $modelCollection[$modelCode['job_code']] != '') {
|
| 144 |
+
$val['model'] = $modelCollection[$modelCode['job_code']];
|
| 145 |
+
$result[] = $val->toArray();
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
return $result;
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
public function getAllCodes()
|
| 153 |
+
{
|
| 154 |
+
$codes = array();
|
| 155 |
+
$config = Mage::getConfig()->getNode('crontab/jobs');
|
| 156 |
+
|
| 157 |
+
if ($config instanceof Mage_Core_Model_Config_Element) {
|
| 158 |
+
foreach ($config->children() as $jobcode => $tmp) {
|
| 159 |
+
$model = (array) $tmp->run;
|
| 160 |
+
$modelArray[$jobcode] = $model['model'];
|
| 161 |
+
}
|
| 162 |
+
return $modelArray;
|
| 163 |
+
}
|
| 164 |
+
}
|
| 165 |
+
protected function _visit($url)
|
| 166 |
+
{
|
| 167 |
+
$agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
|
| 168 |
+
$ch = curl_init();
|
| 169 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
| 170 |
+
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
|
| 171 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
| 172 |
+
curl_setopt($ch, CURLOPT_VERBOSE, false);
|
| 173 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
|
| 174 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
| 175 |
+
curl_setopt($ch, CURLOPT_SSLVERSION, 3);
|
| 176 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
|
| 177 |
+
$page = curl_exec($ch);
|
| 178 |
+
|
| 179 |
+
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
| 180 |
+
curl_close($ch);
|
| 181 |
+
|
| 182 |
+
if ($httpcode >= 200 && $httpcode < 300)
|
| 183 |
+
return true;
|
| 184 |
+
else
|
| 185 |
+
return false;
|
| 186 |
+
}
|
| 187 |
+
protected function _checkParse($url)
|
| 188 |
+
{
|
| 189 |
+
$ch = curl_init();
|
| 190 |
+
|
| 191 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
| 192 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
| 193 |
+
|
| 194 |
+
$output = curl_exec($ch);
|
| 195 |
+
|
| 196 |
+
curl_close($ch);
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
$result = simplexml_load_string($output, 'SimpleXmlElement', LIBXML_NOERROR + LIBXML_ERR_FATAL + LIBXML_ERR_NONE);
|
| 200 |
+
if (false == $result)
|
| 201 |
+
return 'error';
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
public function getWebsiteRunningStatus()
|
| 205 |
+
{
|
| 206 |
+
$homepage = Mage::getBaseUrl();
|
| 207 |
+
$_productCollection = $this->_getSingleProductsCollection();
|
| 208 |
+
$productUrl = $_productCollection->getProductUrl();
|
| 209 |
+
$categoryIds = $_productCollection->getCategoryIds();
|
| 210 |
+
$categoryUrl = $this->_getCategoryUrl($categoryIds);
|
| 211 |
+
$urlArray = array(
|
| 212 |
+
'homepage' => $homepage,
|
| 213 |
+
'listingpage' => $categoryUrl,
|
| 214 |
+
'productpage' => $productUrl
|
| 215 |
+
);
|
| 216 |
+
|
| 217 |
+
foreach ($urlArray as $key => $value) {
|
| 218 |
+
|
| 219 |
+
$visitUrl = $this->_visit($value);
|
| 220 |
+
$checkParseUrl = $this->_checkParse($value);
|
| 221 |
+
if ($visitUrl) {
|
| 222 |
+
$error = "Website OK" . "\n";
|
| 223 |
+
if ($checkParseUrl == 'error') {
|
| 224 |
+
$error = 3; //"Website Having Error"."\n";(parse error)
|
| 225 |
+
} else {
|
| 226 |
+
$error = 1; //"Website Okay"; (Running)
|
| 227 |
+
}
|
| 228 |
+
} else {
|
| 229 |
+
$error = 2; //"Website DOWN"; (Network error)
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
$newArray[$key] = array(
|
| 233 |
+
'name' => $key,
|
| 234 |
+
'value' => $error
|
| 235 |
+
);
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
return $newArray;
|
| 239 |
+
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
/*
|
| 243 |
+
** Get Website Notification
|
| 244 |
+
*
|
| 245 |
+
*/
|
| 246 |
+
public function getWebsiteNotification()
|
| 247 |
+
{
|
| 248 |
+
|
| 249 |
+
$notify = $this->getWebsiteRunningStatus();
|
| 250 |
+
|
| 251 |
+
foreach ($notify as $statuskey => $statusval) {
|
| 252 |
+
$stval = $statusval['value'];
|
| 253 |
+
|
| 254 |
+
$title = '';
|
| 255 |
+
if($statuskey == 'homepage'){
|
| 256 |
+
$title = 'Home page';
|
| 257 |
+
}elseif($statuskey == 'listingpage'){
|
| 258 |
+
$title = 'Listing page';
|
| 259 |
+
}elseif($statuskey == 'productpage'){
|
| 260 |
+
$title = 'Product page';
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
if ($stval == '2') {
|
| 264 |
+
|
| 265 |
+
$notification = "Seems Network error on " . $title . '.::';
|
| 266 |
+
}
|
| 267 |
+
if ($stval == '3') {
|
| 268 |
+
|
| 269 |
+
$notification .= "Seems Parse error on " . $title . '.::';
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
}
|
| 273 |
+
return $notification;
|
| 274 |
+
}
|
| 275 |
+
public function serverUptime()
|
| 276 |
+
{
|
| 277 |
+
$data = '';
|
| 278 |
+
$current_reading = @exec('uptime');
|
| 279 |
+
$uptime = explode(' up ', $current_reading);
|
| 280 |
+
$uptime = explode(',', $uptime[1]);
|
| 281 |
+
$uptime = $uptime[0] . ', ' . $uptime[1];
|
| 282 |
+
$data .= "$uptime";
|
| 283 |
+
return $data;
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
public function get_server_memory_usage()
|
| 287 |
+
{
|
| 288 |
+
|
| 289 |
+
$free = shell_exec('free');
|
| 290 |
+
$free = (string) trim($free);
|
| 291 |
+
$free_arr = explode("\n", $free);
|
| 292 |
+
$mem = explode(" ", $free_arr[1]);
|
| 293 |
+
$mem = array_filter($mem);
|
| 294 |
+
$mem = array_merge($mem);
|
| 295 |
+
$memory_usage = $mem[2] / $mem[1] * 100;
|
| 296 |
+
|
| 297 |
+
return $memory_usage;
|
| 298 |
+
}
|
| 299 |
+
public function loadServer()
|
| 300 |
+
{
|
| 301 |
+
$current_reading = @exec('uptime');
|
| 302 |
+
preg_match("/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/", $current_reading, $averages);
|
| 303 |
+
|
| 304 |
+
$data = "$averages[1], $averages[2], $averages[3]\n";
|
| 305 |
+
|
| 306 |
+
return $data;
|
| 307 |
+
}
|
| 308 |
+
function get_server_cpu_usage()
|
| 309 |
+
{
|
| 310 |
+
|
| 311 |
+
$load = sys_getloadavg();
|
| 312 |
+
return $load[0];
|
| 313 |
+
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
/*Get CPU usage and Memory Usage*/
|
| 317 |
+
public function getCPUMemoryUsage()
|
| 318 |
+
{
|
| 319 |
+
|
| 320 |
+
$memory = $this->get_server_memory_usage();
|
| 321 |
+
$memory1 = round($memory, 2) . '%';
|
| 322 |
+
$cpu = $this->get_server_cpu_usage();
|
| 323 |
+
$cpu1 = round($cpu, 2) . '%';
|
| 324 |
+
$load = $this->loadServer();
|
| 325 |
+
$server = $this->serverUptime();
|
| 326 |
+
|
| 327 |
+
$server_load = Mage::getStoreConfig('magemobapp/sitehealth/server_load');
|
| 328 |
+
$memory_usage = Mage::getStoreConfig('magemobapp/sitehealth/memory_usage');
|
| 329 |
+
$cpu_usage = Mage::getStoreConfig('magemobapp/sitehealth/cpu_usage');
|
| 330 |
+
$load = explode(',', $load);
|
| 331 |
+
$loadStatus = 'ok';
|
| 332 |
+
$memory1Status = 'ok';
|
| 333 |
+
$cpu1Status = 'ok';
|
| 334 |
+
$loadtext = '';
|
| 335 |
+
|
| 336 |
+
for ($i = 0; $i < sizeof($load); $i++) {
|
| 337 |
+
if ($load[$i] >= $server_load) {
|
| 338 |
+
$loadStatus = 'critical';
|
| 339 |
+
}
|
| 340 |
+
$loadtext .= trim($load[$i]) . '%, ';
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
if ($memory1 >= 0.1) {
|
| 344 |
+
$memory1Status = 'critical';
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
if ($cpu1 >= $cpu_usage) {
|
| 348 |
+
$cpu1 = 'critical';
|
| 349 |
+
}
|
| 350 |
+
$cpu_memory_usage = array(
|
| 351 |
+
'memory_usage' => array(
|
| 352 |
+
'name' => 'Memory Usage',
|
| 353 |
+
'value' => $memory1,
|
| 354 |
+
'status' => $memory1Status
|
| 355 |
+
),
|
| 356 |
+
'cpu_usage' => array(
|
| 357 |
+
'name' => 'CPU Usage',
|
| 358 |
+
'value' => $cpu1,
|
| 359 |
+
'status' => $cpu1Status
|
| 360 |
+
),
|
| 361 |
+
'load' => array(
|
| 362 |
+
'name' => 'Load Average',
|
| 363 |
+
'value' => $loadtext,
|
| 364 |
+
'status' => $loadStatus
|
| 365 |
+
),
|
| 366 |
+
'server_uptime' => array(
|
| 367 |
+
'name' => 'Server Uptime',
|
| 368 |
+
'value' => $server
|
| 369 |
+
)
|
| 370 |
+
);
|
| 371 |
+
|
| 372 |
+
|
| 373 |
+
return $cpu_memory_usage;
|
| 374 |
+
}
|
| 375 |
+
public function getCPUMemoryUsageNotification()
|
| 376 |
+
{
|
| 377 |
+
$notification = '';
|
| 378 |
+
$notify = $this->getCPUMemoryUsage();
|
| 379 |
+
foreach ($notify as $statuskey => $statusval) {
|
| 380 |
+
if (isset($statusval['status']) && $statusval['status'] != '') {
|
| 381 |
+
$stval = $statusval['status'];
|
| 382 |
+
if ($stval == 'critical') {
|
| 383 |
+
$notification .= "Memory usage " . $statusval['value'] . '.::';
|
| 384 |
+
}
|
| 385 |
+
}
|
| 386 |
+
}
|
| 387 |
+
return $notification;
|
| 388 |
+
|
| 389 |
+
}
|
| 390 |
+
|
| 391 |
+
protected function _getSingleProductsCollection()
|
| 392 |
+
{
|
| 393 |
+
$collection = Mage::getResourceModel('catalog/product_collection');
|
| 394 |
+
$collection->addAttributeToSort('entity_id', 'DESC');
|
| 395 |
+
$collection->setPage(1,1); //set a limit to 1 so the query would be faster
|
| 396 |
+
return $collection->getFirstItem();
|
| 397 |
+
}
|
| 398 |
+
|
| 399 |
+
protected function _getCategoryUrl($ids)
|
| 400 |
+
{
|
| 401 |
+
$categoryId = (isset($ids[0]) ? $ids[0] : 0);
|
| 402 |
+
$collection = Mage::getModel('catalog/category')->load($categoryId);
|
| 403 |
+
return $collection->getUrl();
|
| 404 |
+
}
|
| 405 |
+
}
|
app/code/community/Oscprofessionals/Magemobapp/controllers/IndexController.php
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
*
|
| 4 |
+
* @category Oscprofessionals
|
| 5 |
+
* @package Oscprofessionals_Magemobapp
|
| 6 |
+
* @author Oscprofessionals Team <oscpteam@oscprofessionals.com>
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
class Oscprofessionals_Magemobapp_IndexController extends Mage_Core_Controller_Front_Action
|
| 10 |
+
{
|
| 11 |
+
|
| 12 |
+
public function indexAction()
|
| 13 |
+
{
|
| 14 |
+
|
| 15 |
+
//set header
|
| 16 |
+
header("Access-Control-Allow-Origin: " . $_SERVER['HTTP_ORIGIN']);
|
| 17 |
+
header('Access-Control-Allow-Credentials: true');
|
| 18 |
+
|
| 19 |
+
//getStoreId($_POST);
|
| 20 |
+
$data = array();
|
| 21 |
+
|
| 22 |
+
//Store action from Post Data
|
| 23 |
+
$data['action'] = $this->getRequest()->getPost('action');
|
| 24 |
+
|
| 25 |
+
//Store Params from Post Data
|
| 26 |
+
$data['params'] = $this->getRequest()->getPost('params');
|
| 27 |
+
|
| 28 |
+
$oscModel = Mage::getModel('magemobapp/osc');
|
| 29 |
+
|
| 30 |
+
try {
|
| 31 |
+
$result = $oscModel->processRequest($data);
|
| 32 |
+
}
|
| 33 |
+
catch (Exception $e) {
|
| 34 |
+
|
| 35 |
+
$result['message'] = $e->getMessage();
|
| 36 |
+
Mage::log($result['message'] , null, 'oscMageAdim.log');
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
$this->getResponse()->setHeader('Content-type', 'application/json', true);
|
| 40 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
| 41 |
+
|
| 42 |
+
return $this;
|
| 43 |
+
|
| 44 |
+
}
|
| 45 |
+
}
|
app/code/community/Oscprofessionals/Magemobapp/etc/adminhtml.xml
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
*
|
| 5 |
+
* @category Oscprofessionals
|
| 6 |
+
* @package Oscprofessionals_Magemobapp
|
| 7 |
+
* @author Oscprofessionals Team <oscpteam@oscprofessionals.com>
|
| 8 |
+
*/
|
| 9 |
+
-->
|
| 10 |
+
<config>
|
| 11 |
+
<acl>
|
| 12 |
+
<resources>
|
| 13 |
+
<admin>
|
| 14 |
+
<children>
|
| 15 |
+
<system>
|
| 16 |
+
<children>
|
| 17 |
+
<config>
|
| 18 |
+
<children>
|
| 19 |
+
<magemobapp translate="title" module="magemobapp">
|
| 20 |
+
<title>Mage Mob App</title>
|
| 21 |
+
</magemobapp>
|
| 22 |
+
</children>
|
| 23 |
+
</config>
|
| 24 |
+
</children>
|
| 25 |
+
</system>
|
| 26 |
+
</children>
|
| 27 |
+
</admin>
|
| 28 |
+
</resources>
|
| 29 |
+
</acl>
|
| 30 |
+
</config>
|
app/code/community/Oscprofessionals/Magemobapp/etc/config.xml
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
*
|
| 5 |
+
* @category Oscprofessionals
|
| 6 |
+
* @package Oscprofessionals_Magemobapp
|
| 7 |
+
* @author Oscprofessionals Team <oscpteam@oscprofessionals.com>
|
| 8 |
+
*/
|
| 9 |
+
-->
|
| 10 |
+
<config>
|
| 11 |
+
<modules>
|
| 12 |
+
<Oscprofessionals_Magemobapp>
|
| 13 |
+
<version>2.0.0</version>
|
| 14 |
+
</Oscprofessionals_Magemobapp>
|
| 15 |
+
</modules>
|
| 16 |
+
<frontend>
|
| 17 |
+
<routers>
|
| 18 |
+
<magemobapp>
|
| 19 |
+
<use>standard</use>
|
| 20 |
+
<args>
|
| 21 |
+
<module>Oscprofessionals_Magemobapp</module>
|
| 22 |
+
<frontName>magemobapp</frontName>
|
| 23 |
+
</args>
|
| 24 |
+
</magemobapp>
|
| 25 |
+
</routers>
|
| 26 |
+
</frontend>
|
| 27 |
+
<global>
|
| 28 |
+
<models>
|
| 29 |
+
<magemobapp>
|
| 30 |
+
<class>Oscprofessionals_Magemobapp_Model</class>
|
| 31 |
+
<resourceModel>magemobapp_mysql4</resourceModel>
|
| 32 |
+
</magemobapp>
|
| 33 |
+
</models>
|
| 34 |
+
<blocks>
|
| 35 |
+
<magemobapp>
|
| 36 |
+
<class>Oscprofessionals_Magemobapp_Block</class>
|
| 37 |
+
</magemobapp>
|
| 38 |
+
</blocks>
|
| 39 |
+
<helpers>
|
| 40 |
+
<magemobapp>
|
| 41 |
+
<class>Oscprofessionals_Magemobapp_Helper</class>
|
| 42 |
+
</magemobapp>
|
| 43 |
+
</helpers>
|
| 44 |
+
</global>
|
| 45 |
+
<default>
|
| 46 |
+
<magemobapp>
|
| 47 |
+
<settings>
|
| 48 |
+
<reporting_days>7</reporting_days>
|
| 49 |
+
<stock_critical_level>20</stock_critical_level>
|
| 50 |
+
<notification_enabled>1</notification_enabled>
|
| 51 |
+
<update_frequency>5</update_frequency>
|
| 52 |
+
</settings>
|
| 53 |
+
<sitehealth>
|
| 54 |
+
<website_enabled>1</website_enabled>
|
| 55 |
+
<server_enabled>1</server_enabled>
|
| 56 |
+
<server_load>15</server_load>
|
| 57 |
+
<memory_usage>80%</memory_usage>
|
| 58 |
+
<cpu_usage>60%</cpu_usage>
|
| 59 |
+
<cronschedule_enabled>1</cronschedule_enabled>
|
| 60 |
+
<index_enabled>1</index_enabled>
|
| 61 |
+
<logtable_enabled>1</logtable_enabled>
|
| 62 |
+
<log_table_size>5000</log_table_size>
|
| 63 |
+
</sitehealth>
|
| 64 |
+
<dashboard>
|
| 65 |
+
<neworder_enabled>1</neworder_enabled>
|
| 66 |
+
<allorder_enabled>1</allorder_enabled>
|
| 67 |
+
<allcustomers_enabled>1</allcustomers_enabled>
|
| 68 |
+
<stockalert_enabled>1</stockalert_enabled>
|
| 69 |
+
<todayssales_enabled>1</todayssales_enabled>
|
| 70 |
+
<online_enabled>1</online_enabled>
|
| 71 |
+
<abandonedcart_enabled>1</abandonedcart_enabled>
|
| 72 |
+
</dashboard>
|
| 73 |
+
</magemobapp>
|
| 74 |
+
</default>
|
| 75 |
+
</config>
|
app/code/community/Oscprofessionals/Magemobapp/etc/system.xml
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
*
|
| 5 |
+
* @category Oscprofessionals
|
| 6 |
+
* @package Oscprofessionals_Magemobapp
|
| 7 |
+
* @author Oscprofessionals Team <oscpteam@oscprofessionals.com>
|
| 8 |
+
*/
|
| 9 |
+
-->
|
| 10 |
+
<config>
|
| 11 |
+
<tabs>
|
| 12 |
+
<magemobapp translate="label" module="magemobapp">
|
| 13 |
+
<label>Oscprofessionals</label>
|
| 14 |
+
<sort_order>1000</sort_order>
|
| 15 |
+
</magemobapp>
|
| 16 |
+
</tabs>
|
| 17 |
+
<sections>
|
| 18 |
+
<magemobapp translate="label" module="magemobapp">
|
| 19 |
+
<label>Mage Mob App</label>
|
| 20 |
+
<tab>magemobapp</tab>
|
| 21 |
+
<frontend_type>text</frontend_type>
|
| 22 |
+
<sort_order>100</sort_order>
|
| 23 |
+
<show_in_default>1</show_in_default>
|
| 24 |
+
<show_in_website>1</show_in_website>
|
| 25 |
+
<show_in_store>1</show_in_store>
|
| 26 |
+
<!-- < BOF of enabled flag> -->
|
| 27 |
+
<groups>
|
| 28 |
+
<settings translate="label">
|
| 29 |
+
<label>Mage Mob App setting</label>
|
| 30 |
+
<frontend_type>text</frontend_type>
|
| 31 |
+
<sort_order>10</sort_order>
|
| 32 |
+
<show_in_default>1</show_in_default>
|
| 33 |
+
<show_in_website>1</show_in_website>
|
| 34 |
+
<show_in_store>1</show_in_store>
|
| 35 |
+
<fields>
|
| 36 |
+
<reporting_days translate="label">
|
| 37 |
+
<label>Reporting Days</label>
|
| 38 |
+
<validate>required-entry validate-digits-range digits-range-7-30"</validate>
|
| 39 |
+
<comment>Enter Reporting Days(min 7 and max 30 days)</comment>
|
| 40 |
+
<frontend_type>text</frontend_type>
|
| 41 |
+
<sort_order>10</sort_order>
|
| 42 |
+
<show_in_default>1</show_in_default>
|
| 43 |
+
<show_in_website>1</show_in_website>
|
| 44 |
+
<show_in_store>1</show_in_store>
|
| 45 |
+
</reporting_days>
|
| 46 |
+
<stock_critical_level translate="label">
|
| 47 |
+
<label>Stock Critical Level</label>
|
| 48 |
+
<comment>Stock Critical level</comment>
|
| 49 |
+
<frontend_type>text</frontend_type>
|
| 50 |
+
<sort_order>20</sort_order>
|
| 51 |
+
<show_in_default>1</show_in_default>
|
| 52 |
+
<show_in_website>1</show_in_website>
|
| 53 |
+
<show_in_store>1</show_in_store>
|
| 54 |
+
</stock_critical_level>
|
| 55 |
+
<notification_enabled translate="label">
|
| 56 |
+
<label>Notification Status Enabled</label>
|
| 57 |
+
<frontend_type>select</frontend_type>
|
| 58 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 59 |
+
<sort_order>30</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 |
+
</notification_enabled>
|
| 64 |
+
<update_frequency translate="label">
|
| 65 |
+
<label>Update Frequency</label>
|
| 66 |
+
<comment>value should be in minute. for Example:5 min</comment>
|
| 67 |
+
<frontend_type>text</frontend_type>
|
| 68 |
+
<sort_order>40</sort_order>
|
| 69 |
+
<show_in_default>1</show_in_default>
|
| 70 |
+
<show_in_website>1</show_in_website>
|
| 71 |
+
<show_in_store>1</show_in_store>
|
| 72 |
+
<depends>
|
| 73 |
+
<notification_enabled>1</notification_enabled>
|
| 74 |
+
</depends>
|
| 75 |
+
</update_frequency>
|
| 76 |
+
</fields>
|
| 77 |
+
</settings>
|
| 78 |
+
<sitehealth translate="label" module="magemobapp">
|
| 79 |
+
<label>Site Health Monitor</label>
|
| 80 |
+
<show_in_default>1</show_in_default>
|
| 81 |
+
<show_in_website>1</show_in_website>
|
| 82 |
+
<show_in_store>1</show_in_store>
|
| 83 |
+
<sort_order>20</sort_order>
|
| 84 |
+
<fields>
|
| 85 |
+
<website_enabled translate="label">
|
| 86 |
+
<label>Webpage Status Enabled</label>
|
| 87 |
+
<frontend_type>select</frontend_type>
|
| 88 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 89 |
+
<sort_order>10</sort_order>
|
| 90 |
+
<show_in_default>1</show_in_default>
|
| 91 |
+
<show_in_website>1</show_in_website>
|
| 92 |
+
<show_in_store>1</show_in_store>
|
| 93 |
+
</website_enabled>
|
| 94 |
+
<server_enabled translate="label">
|
| 95 |
+
<label>Serverload Status Enabled</label>
|
| 96 |
+
<frontend_type>select</frontend_type>
|
| 97 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 98 |
+
<sort_order>20</sort_order>
|
| 99 |
+
<show_in_default>1</show_in_default>
|
| 100 |
+
<show_in_website>1</show_in_website>
|
| 101 |
+
<show_in_store>1</show_in_store>
|
| 102 |
+
</server_enabled>
|
| 103 |
+
<server_load translate="label">
|
| 104 |
+
<label>Server load Average</label>
|
| 105 |
+
<comment>limit for load average</comment>
|
| 106 |
+
<frontend_type>text</frontend_type>
|
| 107 |
+
<sort_order>30</sort_order>
|
| 108 |
+
<show_in_default>1</show_in_default>
|
| 109 |
+
<show_in_website>1</show_in_website>
|
| 110 |
+
<show_in_store>1</show_in_store>
|
| 111 |
+
<depends>
|
| 112 |
+
<server_enabled>1</server_enabled>
|
| 113 |
+
</depends>
|
| 114 |
+
</server_load>
|
| 115 |
+
<memory_usage translate="label">
|
| 116 |
+
<label>Memory Usage</label>
|
| 117 |
+
<comment>limit for Memory Usage</comment>
|
| 118 |
+
<frontend_type>text</frontend_type>
|
| 119 |
+
<sort_order>40</sort_order>
|
| 120 |
+
<show_in_default>1</show_in_default>
|
| 121 |
+
<show_in_website>1</show_in_website>
|
| 122 |
+
<show_in_store>1</show_in_store>
|
| 123 |
+
<depends>
|
| 124 |
+
<server_enabled>1</server_enabled>
|
| 125 |
+
</depends>
|
| 126 |
+
</memory_usage>
|
| 127 |
+
<cpu_usage translate="label">
|
| 128 |
+
<label>CPU Usage</label>
|
| 129 |
+
<comment>limit for CPU Usage</comment>
|
| 130 |
+
<frontend_type>text</frontend_type>
|
| 131 |
+
<sort_order>50</sort_order>
|
| 132 |
+
<show_in_default>1</show_in_default>
|
| 133 |
+
<show_in_website>1</show_in_website>
|
| 134 |
+
<show_in_store>1</show_in_store>
|
| 135 |
+
<depends>
|
| 136 |
+
<server_enabled>1</server_enabled>
|
| 137 |
+
</depends>
|
| 138 |
+
</cpu_usage>
|
| 139 |
+
<cronschedule_enabled translate="label">
|
| 140 |
+
<label>CronSchedule Status Enabled</label>
|
| 141 |
+
<frontend_type>select</frontend_type>
|
| 142 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 143 |
+
<sort_order>60</sort_order>
|
| 144 |
+
<show_in_default>1</show_in_default>
|
| 145 |
+
<show_in_website>1</show_in_website>
|
| 146 |
+
<show_in_store>1</show_in_store>
|
| 147 |
+
</cronschedule_enabled>
|
| 148 |
+
<index_enabled translate="label">
|
| 149 |
+
<label>Indexing Status Enabled</label>
|
| 150 |
+
<frontend_type>select</frontend_type>
|
| 151 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 152 |
+
<sort_order>70</sort_order>
|
| 153 |
+
<show_in_default>1</show_in_default>
|
| 154 |
+
<show_in_website>1</show_in_website>
|
| 155 |
+
<show_in_store>1</show_in_store>
|
| 156 |
+
</index_enabled>
|
| 157 |
+
<logtable_enabled translate="label">
|
| 158 |
+
<label>Log Table Size Enabled</label>
|
| 159 |
+
<frontend_type>select</frontend_type>
|
| 160 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 161 |
+
<sort_order>80</sort_order>
|
| 162 |
+
<show_in_default>1</show_in_default>
|
| 163 |
+
<show_in_website>1</show_in_website>
|
| 164 |
+
<show_in_store>1</show_in_store>
|
| 165 |
+
</logtable_enabled>
|
| 166 |
+
<log_table_size translate="label">
|
| 167 |
+
<label>Log Table Size</label>
|
| 168 |
+
<comment>limit for log table size</comment>
|
| 169 |
+
<frontend_type>text</frontend_type>
|
| 170 |
+
<sort_order>90</sort_order>
|
| 171 |
+
<show_in_default>1</show_in_default>
|
| 172 |
+
<show_in_website>1</show_in_website>
|
| 173 |
+
<show_in_store>1</show_in_store>
|
| 174 |
+
<depends>
|
| 175 |
+
<logtable_enabled>1</logtable_enabled>
|
| 176 |
+
</depends>
|
| 177 |
+
</log_table_size>
|
| 178 |
+
</fields>
|
| 179 |
+
</sitehealth>
|
| 180 |
+
<dashboard translate="label" module="magemobapp">
|
| 181 |
+
<label>Dashboard</label>
|
| 182 |
+
<show_in_default>1</show_in_default>
|
| 183 |
+
<show_in_website>1</show_in_website>
|
| 184 |
+
<show_in_store>1</show_in_store>
|
| 185 |
+
<sort_order>30</sort_order>
|
| 186 |
+
<fields>
|
| 187 |
+
<neworder_enabled translate="label">
|
| 188 |
+
<label>New Order Status Enabled</label>
|
| 189 |
+
<frontend_type>select</frontend_type>
|
| 190 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 191 |
+
<sort_order>10</sort_order>
|
| 192 |
+
<show_in_default>1</show_in_default>
|
| 193 |
+
<show_in_website>1</show_in_website>
|
| 194 |
+
<show_in_store>1</show_in_store>
|
| 195 |
+
</neworder_enabled>
|
| 196 |
+
<allorder_enabled translate="label">
|
| 197 |
+
<label>All Order Status Enabled</label>
|
| 198 |
+
<frontend_type>select</frontend_type>
|
| 199 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 200 |
+
<sort_order>20</sort_order>
|
| 201 |
+
<show_in_default>1</show_in_default>
|
| 202 |
+
<show_in_website>1</show_in_website>
|
| 203 |
+
<show_in_store>1</show_in_store>
|
| 204 |
+
</allorder_enabled>
|
| 205 |
+
<allcustomers_enabled translate="label">
|
| 206 |
+
<label>All Customers Status Enabled</label>
|
| 207 |
+
<frontend_type>select</frontend_type>
|
| 208 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 209 |
+
<sort_order>30</sort_order>
|
| 210 |
+
<show_in_default>1</show_in_default>
|
| 211 |
+
<show_in_website>1</show_in_website>
|
| 212 |
+
<show_in_store>1</show_in_store>
|
| 213 |
+
</allcustomers_enabled>
|
| 214 |
+
<stockalert_enabled translate="label">
|
| 215 |
+
<label>Stock Alert Status Enabled</label>
|
| 216 |
+
<frontend_type>select</frontend_type>
|
| 217 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 218 |
+
<sort_order>40</sort_order>
|
| 219 |
+
<show_in_default>1</show_in_default>
|
| 220 |
+
<show_in_website>1</show_in_website>
|
| 221 |
+
<show_in_store>1</show_in_store>
|
| 222 |
+
</stockalert_enabled>
|
| 223 |
+
<todayssales_enabled translate="label">
|
| 224 |
+
<label>Todays Sales Status Enabled</label>
|
| 225 |
+
<frontend_type>select</frontend_type>
|
| 226 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 227 |
+
<sort_order>50</sort_order>
|
| 228 |
+
<show_in_default>1</show_in_default>
|
| 229 |
+
<show_in_website>1</show_in_website>
|
| 230 |
+
<show_in_store>1</show_in_store>
|
| 231 |
+
</todayssales_enabled>
|
| 232 |
+
<online_enabled translate="label">
|
| 233 |
+
<label>Online Customer Status Enabled</label>
|
| 234 |
+
<frontend_type>select</frontend_type>
|
| 235 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 236 |
+
<sort_order>60</sort_order>
|
| 237 |
+
<show_in_default>1</show_in_default>
|
| 238 |
+
<show_in_website>1</show_in_website>
|
| 239 |
+
<show_in_store>1</show_in_store>
|
| 240 |
+
</online_enabled>
|
| 241 |
+
<abandonedcart_enabled translate="label">
|
| 242 |
+
<label>Abandoned Cart Status Enabled</label>
|
| 243 |
+
<frontend_type>select</frontend_type>
|
| 244 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 245 |
+
<sort_order>70</sort_order>
|
| 246 |
+
<show_in_default>1</show_in_default>
|
| 247 |
+
<show_in_website>1</show_in_website>
|
| 248 |
+
<show_in_store>1</show_in_store>
|
| 249 |
+
</abandonedcart_enabled>
|
| 250 |
+
</fields>
|
| 251 |
+
</dashboard>
|
| 252 |
+
<!-- < EOF of enabled flag> -->
|
| 253 |
+
</groups>
|
| 254 |
+
</magemobapp>
|
| 255 |
+
</sections>
|
| 256 |
+
</config>
|
app/etc/modules/Oscprofessionals_Magemobapp.xml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
*
|
| 5 |
+
* @category Oscprofessionals
|
| 6 |
+
* @package Oscprofessionals_Magemobapp
|
| 7 |
+
* @author Oscprofessionals Team <oscpteam@oscprofessionals.com>
|
| 8 |
+
*/
|
| 9 |
+
-->
|
| 10 |
+
<config>
|
| 11 |
+
<modules>
|
| 12 |
+
<Oscprofessionals_Magemobapp>
|
| 13 |
+
<active>true</active>
|
| 14 |
+
<codePool>community</codePool>
|
| 15 |
+
<version>2.0.0</version>
|
| 16 |
+
</Oscprofessionals_Magemobapp>
|
| 17 |
+
</modules>
|
| 18 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>Osc_Mage_Admin</name>
|
| 4 |
+
<version>2.0.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>E-store dashboard on Android, iOS mobile with Sales/order/customer/stock-alert report, site-health...</summary>
|
| 10 |
+
<description>Monitor your e-store on mobile anytime, anywhere!
|
| 11 |
+
Android & iOS App to view dashboard including Order report, Customer report, Sales report, Stock Alert report, Abandoned orders, Site health and many more.
|
| 12 |
+
Access real-time analytic of your multi-store. </description>
|
| 13 |
+
<notes>Release with latest version</notes>
|
| 14 |
+
<authors><author><name>Satish Mantri</name><user>oscprof</user><email>satish@oscprofessionals.com</email></author></authors>
|
| 15 |
+
<date>2015-10-21</date>
|
| 16 |
+
<time>12:49:48</time>
|
| 17 |
+
<contents><target name="magecommunity"><dir name="Oscprofessionals"><dir name="Magemobapp"><dir name="Block"><dir name="Order"><file name="Totals.php" hash="d67bf0a949f2f543ccc10fff0a52fe7b"/></dir><file name="Osc.php" hash="d56e631c46d3878670922eafb9c4339c"/></dir><dir name="Helper"><file name="Data.php" hash="e2dc00a341a7000aba51990fb9e8259c"/></dir><dir name="Model"><file name="Customers.php" hash="0bb495f2143239c6f7a1af346eab6e50"/><file name="Dashboard.php" hash="a21fa48873cf3aff5f4d0f1ecf341995"/><file name="Login.php" hash="42c1c0856a26435fb0df48663848d328"/><file name="Logoff.php" hash="3c67d878906fac004434d49672a0d5c8"/><file name="Notification.php" hash="014b0bff2a499cbbb69c040c27174185"/><file name="Orders.php" hash="82782b2be3e8d0d95269407596644118"/><file name="Osc.php" hash="7a663e16bc2092aa6ca372480556c7cc"/><file name="Sitehealth.php" hash="070a4b8a7b353fa5552b20dd8481ca3b"/><file name="Stock.php" hash="c5325cf49327e0df4655612653de1028"/><file name="Storeinfo.php" hash="f14ae6b708ba0de0683834fe27a63e7f"/></dir><dir name="controllers"><file name="IndexController.php" hash="0cb9c4c434484266cecb238228c47938"/></dir><dir name="etc"><file name="adminhtml.xml" hash="3565c974e3b41d1ac2cafc60bc544389"/><file name="config.xml" hash="9331a90f90ad16bbf970b74bc84aa52d"/><file name="system.xml" hash="2d6c6bc10f626b310d0214e713265398"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Oscprofessionals_Magemobapp.xml" hash="60c3463c0b761390bf67fbb5b4b7a513"/></dir></target></contents>
|
| 18 |
+
<compatible/>
|
| 19 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 20 |
+
</package>
|
