Version Notes
You can Now Track you all the Magento Backend Activity Using our Emizentech Magento Mobile Apps . IT has very great feature API to display All the Sales Activity with Graph . You can now easily see all the Magento Orders Listing , Product Listing, Customer Listing .
Features :
* Wonderful View of your Sales with Days Filter Graph
* Sales Listing View with Details.
* Customer Listing View with Details
* Product Listing View With Details
* Store view Selection For Dashboard,
* Multistore Support
Download this release
Release Info
| Developer | Emizen Tech Private Limited |
| Extension | emizenmobileadmin |
| Version | 1.0.0 |
| Comparing to | |
| See all releases | |
Version 1.0.0
- app/code/local/EmizenTech/MobileAdmin/Block/Index.php +8 -0
- app/code/local/EmizenTech/MobileAdmin/Helper/Data.php +113 -0
- app/code/local/EmizenTech/MobileAdmin/Model/Api.php +77 -0
- app/code/local/EmizenTech/MobileAdmin/Model/Emizenmob.php +12 -0
- app/code/local/EmizenTech/MobileAdmin/Model/Mysql4/Emizenmob.php +8 -0
- app/code/local/EmizenTech/MobileAdmin/Model/Mysql4/Emizenmob/Collection.php +12 -0
- app/code/local/EmizenTech/MobileAdmin/Model/Observer.php +24 -0
- app/code/local/EmizenTech/MobileAdmin/controllers/IndexController.php +1236 -0
- app/code/local/EmizenTech/MobileAdmin/etc/adminhtml.xml +23 -0
- app/code/local/EmizenTech/MobileAdmin/etc/api.xml +29 -0
- app/code/local/EmizenTech/MobileAdmin/etc/config.xml +104 -0
- app/code/local/EmizenTech/MobileAdmin/etc/system.xml +60 -0
- app/code/local/EmizenTech/MobileAdmin/sql/mobileadmin_setup/mysql4-install-0.1.0.php +29 -0
- app/design/frontend/base/default/layout/mobileadmin.xml +12 -0
- app/design/frontend/base/default/template/mobileadmin/index.phtml +1 -0
- app/etc/modules/EmizenTech_MobileAdmin.xml +13 -0
- package.xml +36 -0
app/code/local/EmizenTech/MobileAdmin/Block/Index.php
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class EmizenTech_MobileAdmin_Block_Index extends Mage_Core_Block_Template{
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
}
|
app/code/local/EmizenTech/MobileAdmin/Helper/Data.php
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class EmizenTech_MobileAdmin_Helper_Data extends Mage_Core_Helper_Abstract
|
| 3 |
+
{
|
| 4 |
+
public function getPrice($price)
|
| 5 |
+
{
|
| 6 |
+
$price = strip_tags(Mage::helper('core')->currency($this->getPriceFormat($price)));
|
| 7 |
+
return $price;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
public function getPriceFormat($price)
|
| 11 |
+
{
|
| 12 |
+
$price = sprintf("%01.2f", $price);
|
| 13 |
+
return $price;
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
public function getActualDate($updated_date)
|
| 17 |
+
{
|
| 18 |
+
$date = Mage::app()->getLocale()->date(strtotime($updated_date));
|
| 19 |
+
$timestamp = $date->get(Zend_Date::TIMESTAMP) - $date->get(Zend_Date::TIMEZONE_SECS);
|
| 20 |
+
$updated_date = date("Y-m-d H:i:s", $timestamp);
|
| 21 |
+
return $updated_date;
|
| 22 |
+
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
public function isEnable()
|
| 26 |
+
{
|
| 27 |
+
return Mage::getStoreConfig('emizen_mob/emizen_general/enabled');
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
public function pushNotification($notification_type,$entity_id){
|
| 31 |
+
$google_api_key = 'AIzaSyAZPkT165oPcjfhUmgJnt5Lcs2OInBFJmE';
|
| 32 |
+
$passphrase = 'push2magento';
|
| 33 |
+
$collections = Mage::getModel("mobileadmin/emizenmob")->getCollection()->addFieldToFilter('notification_flag',Array('eq'=>1))->addFieldToFilter('is_logout',Array('eq'=>0));
|
| 34 |
+
|
| 35 |
+
if ($notification_type=='customer'){
|
| 36 |
+
$message = Mage::getStoreConfig('emizen_mob/emizen_general/emizen_register');
|
| 37 |
+
if($message == null){
|
| 38 |
+
$message = Mage::helper('mobileadmin')->__('A New customer has been registered on the Store.');
|
| 39 |
+
}
|
| 40 |
+
}else{
|
| 41 |
+
$message = Mage::getStoreConfig('emizen_mob/emizen_general/emizen_noti');
|
| 42 |
+
if($message == null){
|
| 43 |
+
$message = Mage::helper('mobileadmin')->__('A New order has been received on the Store.');
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
$apnsCert = Mage::getBaseDir('lib'). DS. "mobileadmin".DS."pushcert.pem";
|
| 48 |
+
$ctx = stream_context_create();
|
| 49 |
+
stream_context_set_option($ctx, 'ssl', 'local_cert', $apnsCert);
|
| 50 |
+
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
|
| 51 |
+
$flags = STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT;
|
| 52 |
+
$fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err,$errstr, 60, $flags, $ctx);
|
| 53 |
+
|
| 54 |
+
foreach($collections as $collection){
|
| 55 |
+
$deviceType = $collection->getDeviceType();
|
| 56 |
+
|
| 57 |
+
if($deviceType == 'ios'){
|
| 58 |
+
|
| 59 |
+
if ($fp){
|
| 60 |
+
|
| 61 |
+
$deviceToken = $collection->getDeviceToken();
|
| 62 |
+
$body['aps'] = array(
|
| 63 |
+
'alert' => $message,
|
| 64 |
+
'sound' => 'default',
|
| 65 |
+
'entity_id' => $entity_id,
|
| 66 |
+
'type' => $notification_type
|
| 67 |
+
);
|
| 68 |
+
$payload = json_encode($body);
|
| 69 |
+
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
|
| 70 |
+
$result = fwrite($fp, $msg, strlen($msg));
|
| 71 |
+
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
}elseif($deviceType == 'android')
|
| 75 |
+
{
|
| 76 |
+
$deviceToken = $collection->getDeviceToken();
|
| 77 |
+
$registrationIds = array($deviceToken);
|
| 78 |
+
|
| 79 |
+
$msg_a = array(
|
| 80 |
+
'message' => $message,
|
| 81 |
+
'entity_id' => $entity_id,
|
| 82 |
+
'type' => $notification_type
|
| 83 |
+
);
|
| 84 |
+
|
| 85 |
+
$fields = array(
|
| 86 |
+
'registration_ids' => $registrationIds,
|
| 87 |
+
'data' => $msg_a
|
| 88 |
+
);
|
| 89 |
+
|
| 90 |
+
$headers = array(
|
| 91 |
+
'Authorization: key=' . $google_api_key,
|
| 92 |
+
'Content-Type: application/json'
|
| 93 |
+
);
|
| 94 |
+
|
| 95 |
+
$ch = curl_init();
|
| 96 |
+
curl_setopt( $ch,CURLOPT_URL, 'https://android.googleapis.com/gcm/send' );
|
| 97 |
+
curl_setopt( $ch,CURLOPT_POST, true );
|
| 98 |
+
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
|
| 99 |
+
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
|
| 100 |
+
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
|
| 101 |
+
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
|
| 102 |
+
$result = curl_exec($ch );
|
| 103 |
+
curl_close( $ch );
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
}
|
| 107 |
+
}
|
| 108 |
+
fclose($fp);
|
| 109 |
+
|
| 110 |
+
return true;
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
?>
|
app/code/local/EmizenTech/MobileAdmin/Model/Api.php
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class EmizenTech_MobileAdmin_Model_Api extends Mage_Api_Model_Resource_Abstract
|
| 3 |
+
{
|
| 4 |
+
/* @method: $soap->call($session_id,'mobileadmin_api.create',$data);
|
| 5 |
+
* @param: $data
|
| 6 |
+
*/
|
| 7 |
+
public function create($data)
|
| 8 |
+
{
|
| 9 |
+
$collections = Mage::getModel("mobileadmin/emizenmob")
|
| 10 |
+
->getCollection()
|
| 11 |
+
->addFieldToFilter('username',Array('eq'=>$data['user']))
|
| 12 |
+
->addFieldToFilter('apikey',Array('eq'=>$data['key']))
|
| 13 |
+
->addFieldToFilter('device_token',Array('eq'=>$data['devicetoken']));
|
| 14 |
+
$count = count($collections);
|
| 15 |
+
//return $count;
|
| 16 |
+
if($count == 0)
|
| 17 |
+
{
|
| 18 |
+
Mage::getModel("mobileadmin/emizenmob") // load model to save user detail in database
|
| 19 |
+
->setUsername($data['user'])
|
| 20 |
+
->setFirstname($data['firstname'])
|
| 21 |
+
->setLastname($data['lastname'])
|
| 22 |
+
->setEmail($data['email'])
|
| 23 |
+
->setApikey($data['key'])
|
| 24 |
+
->setDeviceToken($data['devicetoken'])
|
| 25 |
+
->setDeviceType($data['device_type'])
|
| 26 |
+
->setNotificationFlag($data['notification_flag'])
|
| 27 |
+
->save();
|
| 28 |
+
}
|
| 29 |
+
//return $count;
|
| 30 |
+
if($count == 1)
|
| 31 |
+
{
|
| 32 |
+
foreach($collections as $user)
|
| 33 |
+
{
|
| 34 |
+
$user_id = $user->getUserId();
|
| 35 |
+
$flag = $user->getNotificationFlag();
|
| 36 |
+
}
|
| 37 |
+
if($flag != $data['notification_flag'] || $data['is_logout'] != 1)
|
| 38 |
+
{
|
| 39 |
+
try
|
| 40 |
+
{
|
| 41 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 42 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 43 |
+
$connection->beginTransaction();
|
| 44 |
+
$fields = array();
|
| 45 |
+
$fields['notification_flag'] = $data['notification_flag'];
|
| 46 |
+
$fields['is_logout'] = $data['is_logout'];
|
| 47 |
+
$where = $connection->quoteInto('user_id =?', $user_id);
|
| 48 |
+
$connection->update($prefix.'emizenmob', $fields, $where);
|
| 49 |
+
$connection->commit();
|
| 50 |
+
}
|
| 51 |
+
catch (Exception $e)
|
| 52 |
+
{
|
| 53 |
+
return $e->getMessage();
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
$successArr[] = array('success_msg' => 'Login sucessfully','session_id' => $data['session_id'],'firstname' => $data['firstname'],'lastname' => $data['lastname'],'email' => $data['email']) ; // return logged in status
|
| 59 |
+
|
| 60 |
+
foreach(Mage::app()->getWebsites() as $website)
|
| 61 |
+
{
|
| 62 |
+
foreach ($website->getGroups() as $group)
|
| 63 |
+
{
|
| 64 |
+
$stores = $group->getStores();
|
| 65 |
+
foreach ($stores as $store)
|
| 66 |
+
{
|
| 67 |
+
$storeArr[] = array('id' =>$store->getId(),
|
| 68 |
+
'name' => $store->getName()
|
| 69 |
+
);
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
$isPos = 0;
|
| 74 |
+
$result = array('success' => $successArr,'stores' => $storeArr,'is_pos' => $isPos);
|
| 75 |
+
return $result;
|
| 76 |
+
}
|
| 77 |
+
}
|
app/code/local/EmizenTech/MobileAdmin/Model/Emizenmob.php
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class EmizenTech_MobileAdmin_Model_Emizenmob extends Mage_Core_Model_Abstract
|
| 4 |
+
{
|
| 5 |
+
protected function _construct(){
|
| 6 |
+
|
| 7 |
+
$this->_init("mobileadmin/emizenmob");
|
| 8 |
+
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
}
|
| 12 |
+
|
app/code/local/EmizenTech/MobileAdmin/Model/Mysql4/Emizenmob.php
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class EmizenTech_MobileAdmin_Model_Mysql4_Emizenmob extends Mage_Core_Model_Mysql4_Abstract
|
| 3 |
+
{
|
| 4 |
+
protected function _construct()
|
| 5 |
+
{
|
| 6 |
+
$this->_init("mobileadmin/emizenmob", "user_id");
|
| 7 |
+
}
|
| 8 |
+
}
|
app/code/local/EmizenTech/MobileAdmin/Model/Mysql4/Emizenmob/Collection.php
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class EmizenTech_MobileAdmin_Model_Mysql4_Emizenmob_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
| 3 |
+
{
|
| 4 |
+
|
| 5 |
+
public function _construct(){
|
| 6 |
+
$this->_init("mobileadmin/emizenmob");
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
}
|
| 12 |
+
|
app/code/local/EmizenTech/MobileAdmin/Model/Observer.php
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class EmizenTech_MobileAdmin_Model_Observer
|
| 3 |
+
{
|
| 4 |
+
public function salesOrderSaveAfter(Varien_Event_Observer $observer)
|
| 5 |
+
{
|
| 6 |
+
//Mage::dispatchEvent('admin_session_user_login_success', array('user'=>$user));
|
| 7 |
+
//$user = $observer->getEvent()->getUser();
|
| 8 |
+
//$user->doSomething();
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
public function customerRegisterNotification(Varien_Event_Observer $observer)
|
| 12 |
+
{
|
| 13 |
+
//Mage::dispatchEvent('admin_session_user_login_success', array('user'=>$user));
|
| 14 |
+
//$user = $observer->getEvent()->getUser();
|
| 15 |
+
//$user->doSomething();
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
public function customerRegisterNotificationCheckout(Varien_Event_Observer $observer)
|
| 19 |
+
{
|
| 20 |
+
//Mage::dispatchEvent('admin_session_user_login_success', array('user'=>$user));
|
| 21 |
+
//$user = $observer->getEvent()->getUser();
|
| 22 |
+
//$user->doSomething();
|
| 23 |
+
}
|
| 24 |
+
}
|
app/code/local/EmizenTech/MobileAdmin/controllers/IndexController.php
ADDED
|
@@ -0,0 +1,1236 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class EmizenTech_MobileAdmin_IndexController extends Mage_Core_Controller_Front_Action{
|
| 3 |
+
|
| 4 |
+
/* If you want to check function is working perfect or not please direct hit this URL on your browser: YOUR WEB BASE URL/emizenstore/mobileadmin/index/index // pass parameter like this after second index from this URL ?userapi=test&keyapi=test etc.
|
| 5 |
+
* required parameter: @ userapi,keyapi,magento_url
|
| 6 |
+
*/
|
| 7 |
+
public function IndexAction()
|
| 8 |
+
{
|
| 9 |
+
$modules = Mage::getConfig()->getNode('modules')->children();
|
| 10 |
+
$modulesArray = (array)$modules;
|
| 11 |
+
$check_arr = (array)$modulesArray['EmizenTech_MobileAdmin'];
|
| 12 |
+
|
| 13 |
+
if(!isset($modulesArray['EmizenTech_MobileAdmin']) && $check_arr['active'])
|
| 14 |
+
{
|
| 15 |
+
$error = array('error' => 'Please install and activate EmizenTech_MobileAdminn extension on your store');
|
| 16 |
+
$jsonData = Mage::helper('core')->jsonEncode($error);
|
| 17 |
+
return Mage::app()->getResponse()->setBody($jsonData);
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
if(Mage::getStoreConfig('emizen_mob/emizen_general/enabled')) // check if extension is enabled on your magento store.
|
| 22 |
+
{
|
| 23 |
+
$isSecure = Mage::app()->getFrontController()->getRequest()->isSecure();
|
| 24 |
+
$validate_url = false;
|
| 25 |
+
if($isSecure)
|
| 26 |
+
{
|
| 27 |
+
if(Mage::getStoreConfig('web/secure/base_url') == Mage::getStoreConfig('web/secure/base_link_url')) // check secure URL
|
| 28 |
+
{
|
| 29 |
+
$validate_url = true;
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
else
|
| 33 |
+
{
|
| 34 |
+
if(Mage::getStoreConfig('web/unsecure/base_url') == Mage::getStoreConfig('web/unsecure/base_link_url')) // check unsecure URL
|
| 35 |
+
{
|
| 36 |
+
$validate_url = true;
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
if($validate_url) // if validate is true
|
| 40 |
+
{
|
| 41 |
+
$details = Mage::app()->getRequest()->getParams();
|
| 42 |
+
$user = $details['userapi'];
|
| 43 |
+
$api_key = $details['keyapi'];
|
| 44 |
+
$deviceToken = $details['token'];
|
| 45 |
+
$flag = $details['notification_flag'];
|
| 46 |
+
$device_type = $details['device_type'];
|
| 47 |
+
|
| 48 |
+
$get_length = strlen($details['magento_url']);
|
| 49 |
+
|
| 50 |
+
if(substr($details['magento_url'], $get_length-1) != '/')
|
| 51 |
+
{
|
| 52 |
+
$details['magento_url'] = $details['magento_url']."/";
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
$url = $details['magento_url'].'api/soap/?wsdl';
|
| 56 |
+
|
| 57 |
+
//Mage::log("userapi:".$details['userapi'] . " ~ keyapi:".$details['keyapi'] ." ~ magento_url:".$details['magento_url'] ." ~ token:".$details['token'] ." ~ notification_flag:".$details['notification_flag'] ." ~ url:".$url, null , 'myadmin.log');
|
| 58 |
+
|
| 59 |
+
try
|
| 60 |
+
{
|
| 61 |
+
$soap = new SoapClient($url); // load shop library
|
| 62 |
+
$session_id = $soap->login($user, $api_key);
|
| 63 |
+
|
| 64 |
+
}
|
| 65 |
+
catch(SoapFault $fault)
|
| 66 |
+
{
|
| 67 |
+
$result['error'] = $fault->getMessage();
|
| 68 |
+
$jsonData = Mage::helper('core')->jsonEncode($result); // encode array to json
|
| 69 |
+
return Mage::app()->getResponse()->setBody($jsonData);
|
| 70 |
+
}
|
| 71 |
+
//echo $session_id; die;
|
| 72 |
+
if($session_id)
|
| 73 |
+
{
|
| 74 |
+
$webservice_user = Mage::getModel('api/user')->getCollection()->addFieldToFilter('username',Array('eq'=>$user))->getFirstItem();
|
| 75 |
+
$data[] = array(
|
| 76 |
+
'user' => $user,
|
| 77 |
+
'key' => $api_key,
|
| 78 |
+
'devicetoken'=>$deviceToken,
|
| 79 |
+
'session_id' => $session_id,
|
| 80 |
+
'notification_flag'=> $flag,
|
| 81 |
+
'device_type'=> $device_type,
|
| 82 |
+
'is_logout'=> '0',
|
| 83 |
+
'firstname'=>$webservice_user->getFirstname(),
|
| 84 |
+
'lastname'=>$webservice_user->getLastname(),
|
| 85 |
+
'email'=>$webservice_user->getEmail()
|
| 86 |
+
); // get data in array
|
| 87 |
+
$result = $soap->call($session_id,'mobileadmin_api.create',$data); // create api with entry in database
|
| 88 |
+
$jsonData = Mage::helper('core')->jsonEncode($result);
|
| 89 |
+
//echo "<pre>"; print_r($result); die;
|
| 90 |
+
return Mage::app()->getResponse()->setBody($jsonData);
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
+
else
|
| 94 |
+
{
|
| 95 |
+
$result['error'] = $this->__('Please check web base URL and magento base url on the store.'); // error if condishion is not true
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
else
|
| 99 |
+
{
|
| 100 |
+
$result['error'] = $this->__('Please activate the Mobile Emizentech Extension on the Magento Store.');
|
| 101 |
+
}
|
| 102 |
+
$jsonData = Mage::helper('core')->jsonEncode($result);
|
| 103 |
+
return Mage::app()->getResponse()->setBody($jsonData);
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
/* If you want to check function is working perfect or not please direct hit this URL on your browser: YOUR WEB BASE URL/emizenstore/mobileadmin/index/checkfront // pass parameter like this after checkfront from this URL ?userapi=test&keyapi=test etc.
|
| 107 |
+
* required parameter: @ magento_url
|
| 108 |
+
*/
|
| 109 |
+
public function checkFrontAction()
|
| 110 |
+
{
|
| 111 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
| 112 |
+
$url = $post_data['magento_url']; // get magento url from the query string
|
| 113 |
+
$url_info = parse_url($url); // parse url using this function
|
| 114 |
+
|
| 115 |
+
$modules = Mage::getConfig()->getNode('modules')->children();
|
| 116 |
+
$modulesArray = (array)$modules;
|
| 117 |
+
$check_arr = (array)$modulesArray['EmizenTech_MobileAdmin'];
|
| 118 |
+
|
| 119 |
+
if(!isset($modulesArray['EmizenTech_MobileAdmin']) && $check_arr['active'])
|
| 120 |
+
{
|
| 121 |
+
$error = array('error' => 'Please install and activate EmizenTech_MobileAdminn extension in your store');
|
| 122 |
+
$jsonData = Mage::helper('core')->jsonEncode($error);
|
| 123 |
+
return Mage::app()->getResponse()->setBody($jsonData);
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
if(Mage::getStoreConfig('emizen_mob/emizen_general/enabled')) // if extension is enabled return true
|
| 127 |
+
{
|
| 128 |
+
$isSecure = Mage::app()->getFrontController()->getRequest()->isSecure();
|
| 129 |
+
$validate_url = false;
|
| 130 |
+
if($isSecure)
|
| 131 |
+
{
|
| 132 |
+
if(Mage::getStoreConfig('web/secure/base_url') == Mage::getStoreConfig('web/secure/base_link_url'))
|
| 133 |
+
{
|
| 134 |
+
$validate_url = true;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
if($url_info['scheme'] == 'http') // check http and https in the URL
|
| 138 |
+
{
|
| 139 |
+
$result['error'] = $this->__('It seems you use secure url for your store. So please use "https". '); // check add index.php or not
|
| 140 |
+
$jsonData = Mage::helper('core')->jsonEncode($result);
|
| 141 |
+
return Mage::app()->getResponse()->setBody($jsonData);
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
}
|
| 145 |
+
else
|
| 146 |
+
{
|
| 147 |
+
if(Mage::getStoreConfig('web/unsecure/base_url') == Mage::getStoreConfig('web/unsecure/base_link_url'))
|
| 148 |
+
{
|
| 149 |
+
$validate_url = true;
|
| 150 |
+
}
|
| 151 |
+
}
|
| 152 |
+
if($validate_url)
|
| 153 |
+
{
|
| 154 |
+
$is_index = Mage::getStoreConfig('web/seo/use_rewrites');
|
| 155 |
+
if(!$is_index && basename($url) != 'index.php')
|
| 156 |
+
{
|
| 157 |
+
$result['error'] = $this->__('Please add "index.php" after url.'); // return error
|
| 158 |
+
$jsonData = Mage::helper('core')->jsonEncode($result);
|
| 159 |
+
return Mage::app()->getResponse()->setBody($jsonData);
|
| 160 |
+
}
|
| 161 |
+
$result['success'] = $this->__('Now connection is fine, you can run app.'); // if will be validated URL it will return this message.
|
| 162 |
+
}
|
| 163 |
+
else
|
| 164 |
+
{
|
| 165 |
+
$result['error'] = $this->__('There seems some difference between the Based URL & Magento Based URL(on the store).');
|
| 166 |
+
}
|
| 167 |
+
}
|
| 168 |
+
else
|
| 169 |
+
{
|
| 170 |
+
$result['error'] = $this->__('Please activate the Mobile Emizentech Extension on the Magento Store.');
|
| 171 |
+
}
|
| 172 |
+
$jsonData = Mage::helper('core')->jsonEncode($result); // convert data array to json
|
| 173 |
+
return Mage::app()->getResponse()->setBody($jsonData);
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
/* If you want to check function is working perfect or not please direct hit this URL on your browser: YOUR WEB BASE URL/emizenstore/mobileadmin/index/adminlogout // pass parameter like this after adminlogout from this URL ?userapi=test&token=test etc.
|
| 177 |
+
* required parameter: @ userapi,token
|
| 178 |
+
*/
|
| 179 |
+
public function AdminLogoutAction()
|
| 180 |
+
{
|
| 181 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
| 182 |
+
$user = $post_data['userapi'];
|
| 183 |
+
$deviceToken = $post_data['token'];
|
| 184 |
+
$collections = Mage::getModel("mobileadmin/emizenmob")->getCollection()->addFieldToFilter('device_token',Array('eq'=>$deviceToken));
|
| 185 |
+
$count = count($collections); // get number of record
|
| 186 |
+
|
| 187 |
+
foreach($collections as $user) // get device token using this loop
|
| 188 |
+
{
|
| 189 |
+
$device_token = $user->getDeviceToken();
|
| 190 |
+
try
|
| 191 |
+
{
|
| 192 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 193 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 194 |
+
$connection->beginTransaction();
|
| 195 |
+
$fields = array();
|
| 196 |
+
$fields['is_logout'] = 1; // if admin will be logged out then update this field in the database
|
| 197 |
+
$where = $connection->quoteInto('device_token =?', $device_token);
|
| 198 |
+
$connection->update($prefix.'emizenmob', $fields, $where); // update field if admin logout
|
| 199 |
+
$connection->commit();
|
| 200 |
+
}
|
| 201 |
+
catch(Exception $e)
|
| 202 |
+
{
|
| 203 |
+
return $e->getMessage(); // generate exception if will not perform try method data.
|
| 204 |
+
}
|
| 205 |
+
$successArr[] = array('success_msg' => 'You are now successfully logged out.'); // if admin is logged out will return this message
|
| 206 |
+
$result = Mage::helper('core')->jsonEncode($successArr);
|
| 207 |
+
return Mage::app()->getResponse()->setBody($result);
|
| 208 |
+
}
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
/* If you want to check function is working perfect or not please direct hit this URL on your browser: YOUR WEB BASE URL/emizenstore/mobileadmin/index/getlogoandcurrency // pass parameter like this after getlogoandcurrency from this URL ?userapi=test&keyapi=test etc.
|
| 212 |
+
* required parameter: @ storeid(optional)
|
| 213 |
+
*/
|
| 214 |
+
public function getLogoAndCurrencyAction()
|
| 215 |
+
{
|
| 216 |
+
$post_data = Mage::app()->getRequest()->getParams(); // get post data in array format.
|
| 217 |
+
$storeId = $post_data['storeid'];
|
| 218 |
+
$block = new Mage_Page_Block_Html_Header(); // load block to get header content of your current package theme logo
|
| 219 |
+
$logo = $block->getLogoSrc(); // get current store logo URL
|
| 220 |
+
|
| 221 |
+
$currency_code = Mage::getModel('core/store')->load($storeId)->getCurrentCurrencyCode(); // get current currency symbol on current store
|
| 222 |
+
|
| 223 |
+
$isPos = 0;
|
| 224 |
+
$resultArr = array('logo' => $logo,'currency_symbol' => Mage::app()->getLocale()->currency($currency_code)->getSymbol(),'is_pos' => $isPos);
|
| 225 |
+
//echo "<pre>"; print_r($resultArr); die;
|
| 226 |
+
$result = Mage::helper('core')->jsonEncode($resultArr); // convert array data to json
|
| 227 |
+
return Mage::app()->getResponse()->setBody($result); // set json result in body
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
/* If you want to check function is working perfect or not please direct hit this URL on your browser: YOUR WEB BASE URL/emizenstore/mobileadmin/index/admindashboard // pass parameter like this after admindashboard from this URL ?session=sdfsdf
|
| 231 |
+
* required parameter: @ session
|
| 232 |
+
*/
|
| 233 |
+
public function AdminDashboardAction()
|
| 234 |
+
{
|
| 235 |
+
$result = array(); // make attay to use one by one key push in array
|
| 236 |
+
if(Mage::helper('mobileadmin')->isEnable()) // check if extension is enabled or not ?
|
| 237 |
+
{
|
| 238 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
| 239 |
+
$sessionId = $post_data['session'];
|
| 240 |
+
if (!Mage::getSingleton('api/session')->isLoggedIn($sessionId)) { // check if customer is not logged in then return Access denied
|
| 241 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
| 242 |
+
return false; // return logged out
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
// It will return admin stores from using this code
|
| 246 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
| 247 |
+
foreach ($website->getGroups() as $group) {
|
| 248 |
+
$stores = $group->getStores();
|
| 249 |
+
foreach ($stores as $store) {
|
| 250 |
+
$result['store'][] = array('id' =>$store->getId(),
|
| 251 |
+
'name' => $store->getName()
|
| 252 |
+
);
|
| 253 |
+
}
|
| 254 |
+
}
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
// It will return total lifetime sale from using this code
|
| 258 |
+
$orderColl = Mage::getResourceModel('reports/order_collection')->calculateSales()->load()->getFirstItem()->getLifetime();
|
| 259 |
+
$total_sale_with_formetted_price = Mage::helper('core')->currency($orderColl, true, false);
|
| 260 |
+
$result['total_sale'] = $total_sale_with_formetted_price;
|
| 261 |
+
|
| 262 |
+
// It will return total average order from using this code
|
| 263 |
+
$collection = Mage::getResourceModel('reports/order_collection')->calculateSales(1);
|
| 264 |
+
$collection->load();
|
| 265 |
+
$sales = $collection->getFirstItem();
|
| 266 |
+
$total_avg_order_formetted_price = Mage::helper('core')->currency($sales->getAverage(), true, false);
|
| 267 |
+
$result['total_avg_orders'] = $total_avg_order_formetted_price;
|
| 268 |
+
|
| 269 |
+
// It will return last 5 orders from using this code
|
| 270 |
+
$collection_customer = Mage::getResourceModel('reports/order_collection')
|
| 271 |
+
->addItemCountExpr()
|
| 272 |
+
->joinCustomerName('customer')
|
| 273 |
+
->orderByCreatedAt();
|
| 274 |
+
$collection_customer->addAttributeToFilter('store_id', 1);
|
| 275 |
+
$collection_customer->addRevenueToSelect();
|
| 276 |
+
$collection_customer->setPageSize(5);
|
| 277 |
+
|
| 278 |
+
//echo "<pre>"; print_r($collection_customer->getData()); die;
|
| 279 |
+
foreach ($collection_customer->getData() as $value)
|
| 280 |
+
{
|
| 281 |
+
$result['last_orders']['Customer'][] = $value['customer_firstname']." ".$value['customer_lastname'];
|
| 282 |
+
$result['last_orders']['Items'][] = $value['total_item_count'];
|
| 283 |
+
$result['last_orders']['Grand Total'][] = $value['grand_total'];
|
| 284 |
+
}
|
| 285 |
+
//echo "<pre>"; print_r($result); die;
|
| 286 |
+
}
|
| 287 |
+
else
|
| 288 |
+
{
|
| 289 |
+
$result['error'] = $this->__('Please activate the Mobile Emizentech Extension on the Magento Store.');
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
$isEnable = Mage::helper('core')->jsonEncode($result);
|
| 293 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
/* If you want to check function is working perfect or not please direct hit this URL on your browser: YOUR WEB BASE URL/emizenstore/mobileadmin/index/adminorders // pass parameter like this after adminorders from this URL ?session=sdfsdf
|
| 297 |
+
* required parameter: @ session , limit , See $post_data variable
|
| 298 |
+
*/
|
| 299 |
+
public function AdminOrdersAction()
|
| 300 |
+
{
|
| 301 |
+
if(Mage::helper('mobileadmin')->isEnable()) // check if extesion enabled or not ?
|
| 302 |
+
{
|
| 303 |
+
$post_data = Mage::app()->getRequest()->getParams(); // get parameter from post method
|
| 304 |
+
$sessionId = $post_data['session'];
|
| 305 |
+
if (!Mage::getSingleton('api/session')->isLoggedIn($sessionId)) { // check session if expired return access denied
|
| 306 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
| 307 |
+
return false;
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
$limit = $post_data['limit'];
|
| 311 |
+
$storeId = $post_data['storeid']; // Make varibles to get post data one by one
|
| 312 |
+
$offset = $post_data['offset'];
|
| 313 |
+
$is_refresh = $post_data['is_refresh'];
|
| 314 |
+
|
| 315 |
+
$orderCollection = Mage::getResourceModel('sales/order_grid_collection')->addFieldToFilter('store_id',Array('eq'=>$storeId))->setOrder('entity_id', 'desc'); // get order collection filter by storeId and desc order by entityId
|
| 316 |
+
if($offset != null)
|
| 317 |
+
{
|
| 318 |
+
$orderCollection->addAttributeToFilter('entity_id', array('lt' => $offset)); // lt means less then
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
if($is_refresh == 1) // check last updated order when you pass parameter to $is_refresh = 1
|
| 322 |
+
{
|
| 323 |
+
$last_fetch_order = $post_data['last_fetch_order'];
|
| 324 |
+
$min_fetch_order = $post_data['min_fetch_order'];
|
| 325 |
+
$last_updated = Mage::helper('mobileadmin')->getActualDate($post_data['last_updated']);
|
| 326 |
+
|
| 327 |
+
$orderCollection->getSelect()->where("(entity_id BETWEEN '".$min_fetch_order."'AND '".$last_fetch_order ."' AND updated_at > '".$last_updated."') OR entity_id >'".$last_fetch_order."'"); // collection filter by updated date
|
| 328 |
+
}
|
| 329 |
+
$orderCollection->getSelect()->limit($limit); // define limit
|
| 330 |
+
|
| 331 |
+
foreach($orderCollection as $order){
|
| 332 |
+
|
| 333 |
+
$orderListData[] = array(
|
| 334 |
+
'entity_id' => $order->getEntityId(),
|
| 335 |
+
'increment_id' => $order->getIncrementId(),
|
| 336 |
+
'store_id' => $order->getStoreId(),
|
| 337 |
+
'customer_name' => $order->getBillingName(),
|
| 338 |
+
'status' => $order->getStatus(),
|
| 339 |
+
'order_date' => date('Y-m-d H:i:s', strtotime($order->getCreatedAt())),
|
| 340 |
+
'grand_total' => Mage::helper('mobileadmin')->getPrice($order->getGrandTotal()),
|
| 341 |
+
'toal_qty' => Mage::getModel('sales/order')->load($order->getEntityId())->getTotalQtyOrdered()
|
| 342 |
+
);
|
| 343 |
+
}
|
| 344 |
+
|
| 345 |
+
$updated_time = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time())); // get updated time
|
| 346 |
+
$orderListResultArr = array('orderlistdata' => $orderListData,'updated_time' =>$updated_time);
|
| 347 |
+
//echo "<pre>"; print_r($orderListResultArr); die;
|
| 348 |
+
$orderListResult = Mage::helper('core')->jsonEncode($orderListResultArr); // comvert data array to json
|
| 349 |
+
return Mage::app()->getResponse()->setBody($orderListResult);
|
| 350 |
+
}
|
| 351 |
+
else
|
| 352 |
+
{
|
| 353 |
+
$result['error'] = $this->__('Please activate the Mobile Emizentech Extension on the Magento Store.');
|
| 354 |
+
}
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
/* If you want to check function is working perfect or not please direct hit this URL on your browser: YOUR WEB BASE URL/emizenstore/mobileadmin/index/adminorderdetail // pass parameter like this after adminorderdetail from this URL ?session=sdfsdf
|
| 358 |
+
* required parameter: @ session , entity_id , See $post_data variable
|
| 359 |
+
*/
|
| 360 |
+
public function AdminOrderDetailAction()
|
| 361 |
+
{
|
| 362 |
+
if(Mage::helper('mobileadmin')->isEnable()){ // check extension if enabled or not
|
| 363 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
| 364 |
+
$sessionId = $post_data['session'];
|
| 365 |
+
if (!Mage::getSingleton('api/session')->isLoggedIn($sessionId)) { // check session if not, will return false
|
| 366 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
| 367 |
+
return false;
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
$order_id = $post_data['entity_id']; // get entity id form post method
|
| 371 |
+
$order = Mage::getModel('sales/order')->load($order_id); // load sales order model by order id
|
| 372 |
+
|
| 373 |
+
$order_detail = array(
|
| 374 |
+
'entity_id' => $order->getEntityId(),
|
| 375 |
+
'increment_id' => $order->getIncrementId(),
|
| 376 |
+
'status' => $order->getStatus(),
|
| 377 |
+
'order_date' => date('Y-m-d H:i:s', strtotime($order->getCreatedAt())),
|
| 378 |
+
'total_qty' => $order->getTotalQtyOrdered(),
|
| 379 |
+
'grand_total' => Mage::helper('mobileadmin')->getPrice($order->getGrandTotal()),
|
| 380 |
+
'sub_total' => Mage::helper('mobileadmin')->getPrice($order->getSubtotal()),
|
| 381 |
+
'discount' => Mage::helper('mobileadmin')->getPrice($order->getDiscountAmount()),
|
| 382 |
+
'tax' => Mage::helper('mobileadmin')->getPrice($order->getTax())
|
| 383 |
+
);
|
| 384 |
+
|
| 385 |
+
$customer_id = $order->getCustomerId(); // get order customer id
|
| 386 |
+
$customer_name = $order->getCustomerFirstname()." ".$order->getCustomerLastname(); // get order first and last name
|
| 387 |
+
if($customer_id == null)
|
| 388 |
+
{
|
| 389 |
+
$customer_name = $order->getCustomerName();
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
$customer_detail = array(
|
| 393 |
+
'customer_id' => $customer_id,
|
| 394 |
+
'customer_name' => $customer_name,
|
| 395 |
+
'customer_email' => $order->getCustomerEmail()
|
| 396 |
+
);
|
| 397 |
+
|
| 398 |
+
$billing_address = $order->getBillingAddress(); // get order billing address
|
| 399 |
+
$billing_address_data = array(
|
| 400 |
+
'name' => $billing_address->getFirstname().' '.$billing_address->getLastname(),
|
| 401 |
+
'street' => $billing_address->getData('street'),
|
| 402 |
+
'city' => $billing_address->getCity(),
|
| 403 |
+
'region' => $billing_address->getRegion(),
|
| 404 |
+
'postcode' => $billing_address->getPostcode(),
|
| 405 |
+
'country' => Mage::getModel('directory/country')->loadByCode($billing_address->getCountryId())->getName(),
|
| 406 |
+
'telephone' => $billing_address->getTelephone()
|
| 407 |
+
);
|
| 408 |
+
$shipping_address = $order->getShippingAddress(); // get order shipping address
|
| 409 |
+
if($shipping_address)
|
| 410 |
+
{
|
| 411 |
+
$shipping_address_data = array(
|
| 412 |
+
'name' => $shipping_address->getFirstname().' '.$shipping_address->getLastname(),
|
| 413 |
+
'street' => $shipping_address->getData('street'),
|
| 414 |
+
'city' => $shipping_address->getCity(),
|
| 415 |
+
'region' => $shipping_address->getRegion(),
|
| 416 |
+
'postcode' => $shipping_address->getPostcode(),
|
| 417 |
+
'country' => Mage::getModel('directory/country')->loadByCode($shipping_address->getCountryId())->getName(),
|
| 418 |
+
'telephone' => $shipping_address->getTelephone()
|
| 419 |
+
);
|
| 420 |
+
}
|
| 421 |
+
|
| 422 |
+
$payment_info = array(
|
| 423 |
+
'payment_method' => $order->getPayment()->getMethodInstance()->getTitle() // Include payment method to array
|
| 424 |
+
);
|
| 425 |
+
|
| 426 |
+
$shipping_info = array(
|
| 427 |
+
'shipping_method' => $order->getShippingDescription(), // Shipping methods also add
|
| 428 |
+
'shipping_charge' => Mage::helper('mobileadmin')->getPrice($order->getShippingAmount())
|
| 429 |
+
);
|
| 430 |
+
|
| 431 |
+
$products_detail = $this->_orderedAdminProductDetails($order_id); // get products detail by order id
|
| 432 |
+
|
| 433 |
+
$full_order_detail = array(
|
| 434 |
+
'basic_order_detail' => $order_detail,
|
| 435 |
+
'customer_detail' => $customer_detail,
|
| 436 |
+
'billing_address' => $billing_address_data, // Order and product detail in array
|
| 437 |
+
'shipping_address' => $shipping_address_data,
|
| 438 |
+
'payment_info' => $payment_info,
|
| 439 |
+
'shipping_info' => $shipping_info,
|
| 440 |
+
'product_detail' => $products_detail
|
| 441 |
+
);
|
| 442 |
+
$orderDetailResultArr = array('orderlistdata' => $full_order_detail); // make array of order list
|
| 443 |
+
//echo "<pre>"; print_r($orderDetailResultArr); die;
|
| 444 |
+
$orderDetailResult = Mage::helper('core')->jsonEncode($orderDetailResultArr);
|
| 445 |
+
return Mage::app()->getResponse()->setBody($orderDetailResult);
|
| 446 |
+
}else{
|
| 447 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
| 448 |
+
return Mage::app()->getResponse()->setBody($isEnable); // set body with json format
|
| 449 |
+
}
|
| 450 |
+
}
|
| 451 |
+
|
| 452 |
+
/*
|
| 453 |
+
* Protected function use in another function according to order id
|
| 454 |
+
* It will return order detail by order id
|
| 455 |
+
*/
|
| 456 |
+
protected function _orderedAdminProductDetails($order_id)
|
| 457 |
+
{
|
| 458 |
+
$order = Mage::getModel('sales/order')->load($order_id); // load order according to order id
|
| 459 |
+
foreach ($order->getItemsCollection() as $item)
|
| 460 |
+
{
|
| 461 |
+
$options = $item->getProductOptions();
|
| 462 |
+
if($item->getProductType() == "downloadable")
|
| 463 |
+
{
|
| 464 |
+
$obj = new Mage_Downloadable_Block_Adminhtml_Sales_Items_Column_Downloadable_Name();
|
| 465 |
+
foreach($options['links'] as $links)
|
| 466 |
+
{
|
| 467 |
+
|
| 468 |
+
$this->_purchased = Mage::getModel('downloadable/link_purchased')
|
| 469 |
+
->load($order_id, 'order_id');
|
| 470 |
+
$purchasedItem = Mage::getModel('downloadable/link_purchased_item')->getCollection() // downloadable products collection
|
| 471 |
+
->addFieldToFilter('order_item_id', $item->getId());
|
| 472 |
+
$this->_purchased->setPurchasedItems($purchasedItem);
|
| 473 |
+
|
| 474 |
+
foreach ($this->_purchased->getPurchasedItems() as $_link)
|
| 475 |
+
{
|
| 476 |
+
$links_value[] = $_link->getLinkTitle().'('. $_link->getNumberOfDownloadsUsed() . ' / ' . ($_link->getNumberOfDownloadsBought() ? $_link->getNumberOfDownloadsBought() : Mage::helper('downloadable')->__('U')) .')';
|
| 477 |
+
}
|
| 478 |
+
|
| 479 |
+
$info = array(array(
|
| 480 |
+
'label' => $obj->getLinksTitle(),
|
| 481 |
+
'value' => implode(',',$links_value)
|
| 482 |
+
));
|
| 483 |
+
}
|
| 484 |
+
}
|
| 485 |
+
else
|
| 486 |
+
{
|
| 487 |
+
$result = array();
|
| 488 |
+
if ($options = $item->getProductOptions()) {
|
| 489 |
+
if (isset($options['options'])) {
|
| 490 |
+
$result = array_merge($result, $options['options']);
|
| 491 |
+
}
|
| 492 |
+
if (isset($options['additional_options'])) {
|
| 493 |
+
$result = array_merge($result, $options['additional_options']);
|
| 494 |
+
}
|
| 495 |
+
if (!empty($options['attributes_info'])) {
|
| 496 |
+
$result = array_merge($options['attributes_info'], $result);
|
| 497 |
+
}
|
| 498 |
+
}
|
| 499 |
+
|
| 500 |
+
$info = array();
|
| 501 |
+
if($result)
|
| 502 |
+
{
|
| 503 |
+
foreach ($result as $_option){ // label and value
|
| 504 |
+
$info[] = array(
|
| 505 |
+
'label' => $_option['label'],
|
| 506 |
+
'value' => $_option['value']
|
| 507 |
+
);
|
| 508 |
+
}
|
| 509 |
+
}
|
| 510 |
+
}
|
| 511 |
+
$skus = '';
|
| 512 |
+
$product = Mage::getModel('catalog/product')->load($item->getProductId()); // load product collection
|
| 513 |
+
|
| 514 |
+
if($item->getParentItem()) continue;
|
| 515 |
+
|
| 516 |
+
if($_options = $this->_getAdminItemOptions($item))
|
| 517 |
+
{
|
| 518 |
+
$skus = $_options;
|
| 519 |
+
}
|
| 520 |
+
$products_detail[] = array(
|
| 521 |
+
'product_id' => $item->getProductId(),
|
| 522 |
+
'name' => $item->getName(),
|
| 523 |
+
'sku' => $item->getSku(),
|
| 524 |
+
'unit_price' => Mage::helper('mobileadmin')->getPrice($item->getOriginalPrice()),
|
| 525 |
+
'ordered_qty' => round($item->getQtyOrdered(), 2),
|
| 526 |
+
'row_total' => Mage::helper('mobileadmin')->getPrice($item->getRowTotal()),
|
| 527 |
+
'options' => $skus ? $skus : '',
|
| 528 |
+
'image' => ($product->getImage())?Mage::helper('catalog/image')->init($product, 'image',$product->getImage())->resize(300,330)->keepAspectRatio(true)->constrainOnly(true)->__toString():'N/A',
|
| 529 |
+
'attribute_info' => $info ? $info : ''
|
| 530 |
+
);
|
| 531 |
+
}
|
| 532 |
+
return $products_detail;
|
| 533 |
+
}
|
| 534 |
+
|
| 535 |
+
/* Private function using another function
|
| 536 |
+
* It will return product SKU's according to item ID
|
| 537 |
+
*/
|
| 538 |
+
private function _getAdminItemOptions($item)
|
| 539 |
+
{
|
| 540 |
+
$id = array('id' => $item->getItemId()); // get item id by products items
|
| 541 |
+
$order_items = Mage::getModel('sales/order_item')->getCollection()->addFieldToFilter('parent_item_id',Array('eq'=>$id)); // sales order
|
| 542 |
+
foreach($order_items as $order_item)
|
| 543 |
+
{
|
| 544 |
+
$product_data = Mage::getModel('catalog/product')->load($order_item->getProductId());
|
| 545 |
+
$skus[] = $product_data->getSku();
|
| 546 |
+
}
|
| 547 |
+
return $skus; //return SKU's
|
| 548 |
+
}
|
| 549 |
+
|
| 550 |
+
/* If you want to check function is working perfect or not please direct hit this URL on your browser: YOUR WEB BASE URL/emizenstore/mobileadmin/index/adminproductlist // pass parameter like this after adminproductlist from this URL ?session=sdfsdf
|
| 551 |
+
* required parameter: @ session , limit , See $post_data variable
|
| 552 |
+
*/
|
| 553 |
+
public function AdminProductListAction()
|
| 554 |
+
{
|
| 555 |
+
if(Mage::helper('mobileadmin')->isEnable())
|
| 556 |
+
{
|
| 557 |
+
$post_data = Mage::app()->getRequest()->getParams(); // get data from post method
|
| 558 |
+
$sessionId = $post_data['session'];
|
| 559 |
+
if(!Mage::getSingleton('api/session')->isLoggedIn($sessionId)) // if session expired return access denied
|
| 560 |
+
{
|
| 561 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
| 562 |
+
return false;
|
| 563 |
+
}
|
| 564 |
+
$storeId = $post_data['storeid'];
|
| 565 |
+
$limit = $post_data['limit']; // Pass parameter according to post method pass
|
| 566 |
+
$offset = $post_data['offset'];
|
| 567 |
+
$new_products = $post_data['last_fetch_product'];
|
| 568 |
+
$is_refresh = $post_data['is_refresh'];
|
| 569 |
+
|
| 570 |
+
$products = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($storeId)->setOrder('entity_id', 'desc');
|
| 571 |
+
if($offset != null)
|
| 572 |
+
{
|
| 573 |
+
$products->addAttributeToFilter('entity_id', array('lt' => $offset)); // lt means less then
|
| 574 |
+
}
|
| 575 |
+
|
| 576 |
+
if($is_refresh == 1) // When you pull dowm your ios app it will be refresh according to last updated time
|
| 577 |
+
{
|
| 578 |
+
$last_fetch_product = $post_data['last_fetch_product'];
|
| 579 |
+
$min_fetch_product = $post_data['min_fetch_product'];
|
| 580 |
+
$last_updated = $post_data['last_updated'];
|
| 581 |
+
$products->getSelect()->where("(entity_id BETWEEN '".$min_fetch_product."'AND '".$last_fetch_product ."' AND updated_at > '".$last_updated."') OR entity_id >'".$last_fetch_product."'");
|
| 582 |
+
}
|
| 583 |
+
|
| 584 |
+
$products->getSelect()->limit($limit); // define limit how many show items in your page
|
| 585 |
+
|
| 586 |
+
foreach($products as $product) // make array of products detail
|
| 587 |
+
{
|
| 588 |
+
$product_data = Mage::getModel('catalog/product')->load($product->getId()); // load product according to product id
|
| 589 |
+
$status = $product_data->getStatus(); // get product status
|
| 590 |
+
$qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product_data)->getQty(); // get Quantity
|
| 591 |
+
if($status == 1)
|
| 592 |
+
{
|
| 593 |
+
$status = 'Enabled';}else{$status = 'Disabled';
|
| 594 |
+
}
|
| 595 |
+
if($qty == 0 || $product_data->getIsInStock() == 0)
|
| 596 |
+
{
|
| 597 |
+
$qty = 'Out of Stock';
|
| 598 |
+
}
|
| 599 |
+
$product_list[] = array(
|
| 600 |
+
'id' => $product->getId(), // products list array
|
| 601 |
+
'sku' => $product_data->getSku(),
|
| 602 |
+
'name' => $product_data->getName(),
|
| 603 |
+
'status' => $status,
|
| 604 |
+
'qty' => $qty,
|
| 605 |
+
'price' => Mage::helper('mobileadmin')->getPrice($product_data->getPrice()),
|
| 606 |
+
'image' => ($product_data->getImage())?Mage::helper('catalog/image')->init($product, 'image',$product_data->getImage())->resize(300,330)->keepAspectRatio(true)->constrainOnly(true)->__toString():'N/A',
|
| 607 |
+
'type' => $product->getTypeId()
|
| 608 |
+
);
|
| 609 |
+
}
|
| 610 |
+
$updated_time = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time())); // last item updated time
|
| 611 |
+
$productResultArr = array('productlistdata' => $product_list,'updated_time' =>$updated_time);
|
| 612 |
+
//echo "<pre>"; print_r($productResultArr); die;
|
| 613 |
+
$productListResult = Mage::helper('core')->jsonEncode($productResultArr);
|
| 614 |
+
return Mage::app()->getResponse()->setBody($productListResult);
|
| 615 |
+
}
|
| 616 |
+
else
|
| 617 |
+
{
|
| 618 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
| 619 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
| 620 |
+
}
|
| 621 |
+
}
|
| 622 |
+
|
| 623 |
+
/* If you want to check function is working perfect or not please direct hit this URL on your browser: YOUR WEB BASE URL/emizenstore/mobileadmin/index/adminproductdetail // pass parameter like this after adminproductdetail from this URL ?session=sdfsdf
|
| 624 |
+
* required parameter: @ session , productid , See $post_data variable
|
| 625 |
+
*/
|
| 626 |
+
public function AdminProductDetailAction()
|
| 627 |
+
{
|
| 628 |
+
if(Mage::helper('mobileadmin')->isEnable()) // check extension if enabled or not
|
| 629 |
+
{
|
| 630 |
+
$post_data = Mage::app()->getRequest()->getParams(); // parameter of array which is sending by URL
|
| 631 |
+
$sessionId = $post_data['session']; // session id
|
| 632 |
+
if(!Mage::getSingleton('api/session')->isLoggedIn($sessionId)) // if exists session id return true otherwise return false
|
| 633 |
+
{
|
| 634 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
| 635 |
+
return false;
|
| 636 |
+
}
|
| 637 |
+
try
|
| 638 |
+
{
|
| 639 |
+
$storeId = $post_data['storeid']; // store id
|
| 640 |
+
$productId = $post_data['productid']; // product id
|
| 641 |
+
$product_data = Mage::getModel('catalog/product')->load($productId); // load product by product id
|
| 642 |
+
$status = $product_data->getStatus(); // get product status
|
| 643 |
+
$qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product_data)->getQty(); // get Quantity
|
| 644 |
+
|
| 645 |
+
if($status == 1) // if status 1 return Enabled Otherwise return Disabled
|
| 646 |
+
{
|
| 647 |
+
$status = 'Enabled';
|
| 648 |
+
}
|
| 649 |
+
else
|
| 650 |
+
{
|
| 651 |
+
$status = 'Disabled';
|
| 652 |
+
}
|
| 653 |
+
|
| 654 |
+
if($product_data->getTypeId() == 'grouped') // if product type is grouped, load product type of grouped
|
| 655 |
+
{
|
| 656 |
+
$associated_products = $product_data->getTypeInstance(true)->getAssociatedProducts($product_data);
|
| 657 |
+
}
|
| 658 |
+
elseif($product_data->getTypeId() == 'configurable') // if product type is configurable, load product type of configurable
|
| 659 |
+
{
|
| 660 |
+
|
| 661 |
+
$associated_products = $product_data->getTypeInstance()->getUsedProducts();
|
| 662 |
+
|
| 663 |
+
}elseif($product_data->getTypeId() == 'bundle') // if product type is bundle, load product type of bundle
|
| 664 |
+
{
|
| 665 |
+
$associated_products = $product_data->getTypeInstance(true)->getSelectionsCollection($product_data->getTypeInstance(true)->getOptionsIds($product_data), $product_data);
|
| 666 |
+
}
|
| 667 |
+
foreach($associated_products as $associated_product) // make products detail array
|
| 668 |
+
{
|
| 669 |
+
$status = $associated_product->getStatus(); // product status
|
| 670 |
+
$qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($associated_product)->getQty(); // Quantity
|
| 671 |
+
|
| 672 |
+
if($status == 1) // if status 1 return Enabled otherwise disabled
|
| 673 |
+
{
|
| 674 |
+
$status = 'Enabled';
|
| 675 |
+
}
|
| 676 |
+
else
|
| 677 |
+
{
|
| 678 |
+
$status = 'Disabled';
|
| 679 |
+
}
|
| 680 |
+
|
| 681 |
+
if($qty == 0 || $associated_product->getIsInStock() == 0) // if qty 0 return out of stock products
|
| 682 |
+
{
|
| 683 |
+
$qty = 'Out of Stock';
|
| 684 |
+
}
|
| 685 |
+
|
| 686 |
+
$associated_products_details[] = array( // associated products array of product
|
| 687 |
+
'id' => $associated_product->getId(),
|
| 688 |
+
'sku' => $associated_product->getSku()
|
| 689 |
+
);
|
| 690 |
+
|
| 691 |
+
$associated_products_list[] = array( // associated products array with other key of product
|
| 692 |
+
'id' => $associated_product->getId(),
|
| 693 |
+
'sku' => $associated_product->getSku(),
|
| 694 |
+
'name' => $associated_product->getName(),
|
| 695 |
+
'status' => $status,
|
| 696 |
+
'qty' => $qty,
|
| 697 |
+
'price' => Mage::helper('mobileadmin')->getPrice($associated_product->getPrice())
|
| 698 |
+
);
|
| 699 |
+
}
|
| 700 |
+
$product_details[] = array( // products detail array
|
| 701 |
+
'id' => $product_data->getId(),
|
| 702 |
+
'sku' => $product_data->getSku(),
|
| 703 |
+
'name' => $product_data->getName(),
|
| 704 |
+
'status' => $status,
|
| 705 |
+
'qty' => $qty,
|
| 706 |
+
'price' => Mage::helper('mobileadmin')->getPrice($product_data->getPrice()),
|
| 707 |
+
'desc' => $product_data->getDescription(),
|
| 708 |
+
'type' => $product_data->getTypeId(),
|
| 709 |
+
'image' => Mage::getModel('catalog/product_media_config')->getMediaUrl($product_data->getImage()),
|
| 710 |
+
'special_price' => Mage::helper('mobileadmin')->getPrice($product_data->getSpecialPrice()),
|
| 711 |
+
'image' => ($product_data->getImage())?Mage::helper('catalog/image')->init($product_data, 'image',$product_data->getImage())->resize(300,330)->keepAspectRatio(true)->constrainOnly(true)->__toString():'N/A',
|
| 712 |
+
'associated_skus' => $associated_products_details
|
| 713 |
+
);
|
| 714 |
+
|
| 715 |
+
$productResultArr = array('productdata' => $product_details , 'associated_products_list' =>$associated_products_list);
|
| 716 |
+
//echo "<pre>"; print_r($productResultArr); die;
|
| 717 |
+
$productDetailResult = Mage::helper('core')->jsonEncode($productResultArr);
|
| 718 |
+
return Mage::app()->getResponse()->setBody($productDetailResult);
|
| 719 |
+
}
|
| 720 |
+
catch (Exception $e)
|
| 721 |
+
{
|
| 722 |
+
$product_details = array (
|
| 723 |
+
'status' => 'error',
|
| 724 |
+
'message' => $e->getMessage()
|
| 725 |
+
);
|
| 726 |
+
return Mage::app()->getResponse()->setBody(Mage::helper('core')->jsonEncode($product_details));
|
| 727 |
+
}
|
| 728 |
+
}
|
| 729 |
+
else
|
| 730 |
+
{
|
| 731 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
| 732 |
+
return Mage::app()->getResponse()->setBody($isEnable); // set body of json products data
|
| 733 |
+
}
|
| 734 |
+
}
|
| 735 |
+
|
| 736 |
+
|
| 737 |
+
/* If you want to check function is working perfect or not please direct hit this URL on your browser: YOUR WEB BASE URL/emizenstore/mobileadmin/index/admincustomerlist // pass parameter like this after admincustomerlist from this URL ?session=sdfsdf
|
| 738 |
+
* required parameter: @ session , limit See $post_data variable
|
| 739 |
+
*/
|
| 740 |
+
public function AdminCustomerListAction()
|
| 741 |
+
{
|
| 742 |
+
if(Mage::helper('mobileadmin')->isEnable()) // check if extension enabled or not
|
| 743 |
+
{
|
| 744 |
+
$post_data = Mage::app()->getRequest()->getParams(); // get parameter from array
|
| 745 |
+
$sessionId = $post_data['session']; // get session
|
| 746 |
+
if (!Mage::getSingleton('api/session')->isLoggedIn($sessionId)) // if exists session is return true
|
| 747 |
+
{
|
| 748 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
| 749 |
+
return false;
|
| 750 |
+
}
|
| 751 |
+
|
| 752 |
+
$limit = $post_data['limit']; // define limit
|
| 753 |
+
$offset = $post_data['offset']; // define offset
|
| 754 |
+
$new_customers = $post_data['last_fetch_customer']; // define last fetch customer time
|
| 755 |
+
$is_refresh = $post_data['is_refresh']; // pass is_refresh int 1 or 0
|
| 756 |
+
$customers = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*')->setOrder('entity_id', 'desc');
|
| 757 |
+
|
| 758 |
+
if($offset != null)
|
| 759 |
+
{
|
| 760 |
+
$customers->addAttributeToFilter('entity_id', array('lt' => $offset)); // lt means less then
|
| 761 |
+
}
|
| 762 |
+
|
| 763 |
+
if($is_refresh == 1) // if 1 refresh last updated entry come or not
|
| 764 |
+
{
|
| 765 |
+
$last_fetch_customer = $post_data['last_fetch_customer'];
|
| 766 |
+
$min_fetch_customer = $post_data['min_fetch_customer'];
|
| 767 |
+
$last_updated = Mage::helper('mobileadmin')->getActualDate($post_data['last_updated']);
|
| 768 |
+
$customers->getSelect()->where("(e.entity_id BETWEEN '".$min_fetch_customer."'AND '".$last_fetch_customer ."' AND updated_at > '".$last_updated."') OR e.entity_id >'".$last_fetch_customer."'");
|
| 769 |
+
}
|
| 770 |
+
|
| 771 |
+
$customers->getSelect()->limit($limit); // define limit
|
| 772 |
+
foreach($customers as $customer)
|
| 773 |
+
{
|
| 774 |
+
$billing_address = Mage::getModel('customer/address')->load($customer->getDefaultBilling()); // get billing address
|
| 775 |
+
$shipping_address = Mage::getModel('customer/address')->load($customer->getDefaultShipping()); // get shipping address
|
| 776 |
+
|
| 777 |
+
$customer_list[] = array(
|
| 778 |
+
'entity_id' => $customer->getEntityId(), // make array of customer list
|
| 779 |
+
'firstname' => $customer->getFirstname(),
|
| 780 |
+
'lastname' => $customer->getLastname(),
|
| 781 |
+
'email_id' => $customer->getEmail(),
|
| 782 |
+
'telephone' => $billing_address->getData('telephone'),
|
| 783 |
+
'billing_address_id' => $billing_address->getId(),
|
| 784 |
+
'shipping_address_id' => $shipping_address->getId()
|
| 785 |
+
);
|
| 786 |
+
}
|
| 787 |
+
$updated_time = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time())); // updated time
|
| 788 |
+
$customerListResultArr = array('customerlistdata' => $customer_list,'updated_time' =>$updated_time);
|
| 789 |
+
$customerListResult = Mage::helper('core')->jsonEncode($customerListResultArr);
|
| 790 |
+
return Mage::app()->getResponse()->setBody($customerListResult); // return customer list in default json format
|
| 791 |
+
}
|
| 792 |
+
else
|
| 793 |
+
{
|
| 794 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
| 795 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
| 796 |
+
}
|
| 797 |
+
}
|
| 798 |
+
|
| 799 |
+
/* If you want to check function is working perfect or not please direct hit this URL on your browser: YOUR WEB BASE URL/emizenstore/mobileadmin/index/admincustomerdetail // pass parameter like this after admincustomerdetail from this URL ?session=sdfsdf
|
| 800 |
+
* required parameter: @ session , customer_id limit See $post_data variable
|
| 801 |
+
*/
|
| 802 |
+
public function AdminCustomerDetailAction()
|
| 803 |
+
{
|
| 804 |
+
if(Mage::helper('mobileadmin')->isEnable()) // if extension is enabled
|
| 805 |
+
{
|
| 806 |
+
$post_data = Mage::app()->getRequest()->getParams(); // get parameter
|
| 807 |
+
$sessionId = $post_data['session']; // session id
|
| 808 |
+
if(!Mage::getSingleton('api/session')->isLoggedIn($sessionId)) // if session not exists return access denied
|
| 809 |
+
{
|
| 810 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
| 811 |
+
return false;
|
| 812 |
+
}
|
| 813 |
+
$customer_id = $post_data['customer_id']; // get customer id
|
| 814 |
+
|
| 815 |
+
$customerData = Mage::getModel('customer/customer')->load($customer_id); // load customer according to customer id
|
| 816 |
+
|
| 817 |
+
$basic_detail = array(
|
| 818 |
+
'entity_id' => $customerData->getEntityId(), // customer detail in array
|
| 819 |
+
'firstname' => $customerData->getFirstname(),
|
| 820 |
+
'lastname' => $customerData->getLastname(),
|
| 821 |
+
'email' => $customerData->getEmail(),
|
| 822 |
+
);
|
| 823 |
+
|
| 824 |
+
foreach ($customerData->getAddresses() as $address)
|
| 825 |
+
{
|
| 826 |
+
$billing_type = 0;
|
| 827 |
+
$shipping_type = 0; // make customer address array
|
| 828 |
+
$billing_country_name = null;
|
| 829 |
+
|
| 830 |
+
if($address->getCountryId()) // get country id
|
| 831 |
+
{
|
| 832 |
+
$billing_country_name = Mage::getModel('directory/country')->loadByCode($address->getCountryId())->getName();
|
| 833 |
+
}
|
| 834 |
+
|
| 835 |
+
if ($address->getId()==$customerData->getDefaultBilling()) // get billing type
|
| 836 |
+
$billing_type=1;
|
| 837 |
+
|
| 838 |
+
if ($address->getId()==$customerData->getDefaultShipping()) // get shipping type
|
| 839 |
+
$shipping_type=1;
|
| 840 |
+
|
| 841 |
+
$billing_address_detail[] = array( // make array of billing address detail
|
| 842 |
+
'firstname' => $address->getFirstname(),
|
| 843 |
+
'lastname' => $address->getLastname(),
|
| 844 |
+
'street' => $address->getData('street'),
|
| 845 |
+
'city' => $address->getCity(),
|
| 846 |
+
'region_id' => $address->getRegionId() ? $address->getRegionId() : '',
|
| 847 |
+
'region' => $address->getRegion(),
|
| 848 |
+
'postcode' => $address->getPostcode(),
|
| 849 |
+
'country' => $billing_country_name,
|
| 850 |
+
'country_id' => $address->getCountryId(),
|
| 851 |
+
'telephone' => $address->getTelephone(),
|
| 852 |
+
'address_id' => $address->getId(),
|
| 853 |
+
'billing_type' => $billing_type,
|
| 854 |
+
'shipping_type' => $shipping_type
|
| 855 |
+
);
|
| 856 |
+
}
|
| 857 |
+
|
| 858 |
+
$customer_detail = array(
|
| 859 |
+
'basic_details' => $basic_detail, // customer address detail
|
| 860 |
+
'address' => $billing_address_detail,
|
| 861 |
+
);
|
| 862 |
+
|
| 863 |
+
$order_detail = $this->_getCustomerOrderList($customer_id); // get customer order list according to customer id
|
| 864 |
+
|
| 865 |
+
$customerDetailResultArr = array('customerDetails' => $customer_detail,'customerOrderDetail' =>$order_detail); /// return customer detail
|
| 866 |
+
|
| 867 |
+
$customerDetailResult = Mage::helper('core')->jsonEncode($customerDetailResultArr);
|
| 868 |
+
|
| 869 |
+
return Mage::app()->getResponse()->setBody($customerDetailResult);
|
| 870 |
+
}else{
|
| 871 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
| 872 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
| 873 |
+
}
|
| 874 |
+
}
|
| 875 |
+
|
| 876 |
+
/* make protected function to use further function directly
|
| 877 |
+
* // It will return customer order list by customer id
|
| 878 |
+
*/
|
| 879 |
+
protected function _getCustomerOrderList($customer_id)
|
| 880 |
+
{
|
| 881 |
+
$orderCollection = Mage::getResourceModel('sales/order_grid_collection')->addFieldToFilter('customer_id',Array('eq'=>$customer_id))->setOrder('entity_id', 'desc'); // order collection with filter spicific parameter
|
| 882 |
+
|
| 883 |
+
$limit = 5; // define limit 5
|
| 884 |
+
|
| 885 |
+
$orderCollection->getSelect()->limit($limit); // get latest 5 orders
|
| 886 |
+
|
| 887 |
+
foreach($orderCollection as $order) // order detail array, which will return in array
|
| 888 |
+
{
|
| 889 |
+
$orderListData[] = array(
|
| 890 |
+
'entity_id' => $order->getEntityId(),
|
| 891 |
+
'increment_id' => $order->getIncrementId(),
|
| 892 |
+
'store_id' => $order->getStoreId(),
|
| 893 |
+
'customer_name' => $order->getBillingName(),
|
| 894 |
+
'status' => $order->getStatus(),
|
| 895 |
+
'order_date' => date('Y-m-d H:i:s', strtotime($order->getCreatedAt())),
|
| 896 |
+
'grand_total' => Mage::helper('mobileadmin')->getPrice($order->getGrandTotal()),
|
| 897 |
+
'toal_qty' => Mage::getModel('sales/order')->load($order->getEntityId())->getTotalQtyOrdered()
|
| 898 |
+
);
|
| 899 |
+
}
|
| 900 |
+
return $orderListData; // return customer order detail
|
| 901 |
+
}
|
| 902 |
+
|
| 903 |
+
/* Filter customer accoprding to firstname and lastname and email
|
| 904 |
+
* It will return filterable collection of customer
|
| 905 |
+
*/
|
| 906 |
+
public function AdminFilterCustomerListAction()
|
| 907 |
+
{
|
| 908 |
+
if(Mage::helper('mobileadmin')->isEnable()) // check extension if enabled or not
|
| 909 |
+
{
|
| 910 |
+
$post_data = Mage::app()->getRequest()->getParams(); // get data from post method
|
| 911 |
+
$sessionId = $post_data['session']; // session id
|
| 912 |
+
if(!Mage::getSingleton('api/session')->isLoggedIn($sessionId)) // if logged in return true otherwise access denied
|
| 913 |
+
{
|
| 914 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
| 915 |
+
return false;
|
| 916 |
+
}
|
| 917 |
+
$search = $post_data['search_content']; // pass search content which you want to search by firstname,lastname,email
|
| 918 |
+
|
| 919 |
+
// get latest customer from customer model
|
| 920 |
+
$customers = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*')->setOrder('entity_id', 'desc');
|
| 921 |
+
|
| 922 |
+
if($search != null) // if search content is not null return filterable data
|
| 923 |
+
{
|
| 924 |
+
$customers->addAttributeToFilter(array(
|
| 925 |
+
array(
|
| 926 |
+
'attribute' => 'firstname', // firstname
|
| 927 |
+
'like' => '%'.$search.'%'
|
| 928 |
+
),
|
| 929 |
+
array(
|
| 930 |
+
'attribute' => 'lastname', // lastname
|
| 931 |
+
'like' => '%'.$search.'%'
|
| 932 |
+
),
|
| 933 |
+
array(
|
| 934 |
+
'attribute' => 'email', // email
|
| 935 |
+
'like' => '%'.$search.'%'
|
| 936 |
+
)
|
| 937 |
+
));
|
| 938 |
+
}
|
| 939 |
+
|
| 940 |
+
foreach($customers as $customer) // make customer filterable data in array
|
| 941 |
+
{
|
| 942 |
+
$billing_address = Mage::getModel('customer/address')->load($customer->getDefaultBilling());
|
| 943 |
+
$shipping_address = Mage::getModel('customer/address')->load($customer->getDefaultShipping());
|
| 944 |
+
|
| 945 |
+
$customer_list[] = array(
|
| 946 |
+
'entity_id' => $customer->getEntityId(),
|
| 947 |
+
'firstname' => $customer->getFirstname(), // get every customer detail
|
| 948 |
+
'lastname' => $customer->getLastname(),
|
| 949 |
+
'email_id' => $customer->getEmail(),
|
| 950 |
+
'telephone' => $billing_address->getData('telephone'),
|
| 951 |
+
'billing_address_id' => $billing_address->getId(),
|
| 952 |
+
'shipping_address_id' => $shipping_address->getId(),
|
| 953 |
+
);
|
| 954 |
+
}
|
| 955 |
+
$customerListResultArr = array('customerlistdata' => $customer_list); // return customer array
|
| 956 |
+
$customerListResult = Mage::helper('core')->jsonEncode($customerListResultArr);
|
| 957 |
+
return Mage::app()->getResponse()->setBody($customerListResult);
|
| 958 |
+
}
|
| 959 |
+
else
|
| 960 |
+
{
|
| 961 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
| 962 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
| 963 |
+
}
|
| 964 |
+
}
|
| 965 |
+
|
| 966 |
+
/* Shoing x and y value for admin graph in particular days
|
| 967 |
+
* @ required parameter: session
|
| 968 |
+
*/
|
| 969 |
+
public function AdminDashboardGraphAction()
|
| 970 |
+
{
|
| 971 |
+
|
| 972 |
+
if(Mage::helper('mobileadmin')->isEnable()) // check if extension enabled or not
|
| 973 |
+
{
|
| 974 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
| 975 |
+
$sessionId = $post_data['session'];
|
| 976 |
+
if (!Mage::getSingleton('api/session')->isLoggedIn($sessionId)) // check session if exists session continue otherwise access denied
|
| 977 |
+
{
|
| 978 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
| 979 |
+
return false;
|
| 980 |
+
}
|
| 981 |
+
|
| 982 |
+
$storeId = $post_data['storeid']; // get magento admin stores
|
| 983 |
+
$type_id = $post_data['days_for_dashboard']; // days for graph like 7 days , current month etc.
|
| 984 |
+
|
| 985 |
+
$now = Mage::getModel('core/date')->timestamp(time()); // current datetime
|
| 986 |
+
$end_date = date('Y-m-d 23:59:59', $now); // change current datetime format
|
| 987 |
+
$start_date = '';
|
| 988 |
+
$orderCollection = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id',Array('eq'=>$storeId))->addFieldToFilter('status',Array('eq'=>'complete'))->setOrder('entity_id', 'desc');
|
| 989 |
+
|
| 990 |
+
// select days range for different different days
|
| 991 |
+
if($type_id == 7) // for 7 days
|
| 992 |
+
{
|
| 993 |
+
$start_date = date('Y-m-d 00:00:00', strtotime('-6 days'));
|
| 994 |
+
}
|
| 995 |
+
elseif($type_id == 30) // for 30 days
|
| 996 |
+
{
|
| 997 |
+
$start_date = date('Y-m-d 00:00:00', strtotime('-29 days'));
|
| 998 |
+
}
|
| 999 |
+
elseif($type_id == 90) // for 90 days
|
| 1000 |
+
{
|
| 1001 |
+
$start_date = date('Y-m-d 00:00:00', strtotime('-89 days'));
|
| 1002 |
+
}
|
| 1003 |
+
else if ($type_id == 24) // for 24 days
|
| 1004 |
+
{
|
| 1005 |
+
$end_date = date("Y-m-d H:m:s");
|
| 1006 |
+
$start_date = date("Y-m-d H:m:s", strtotime('-24 hours', time()));
|
| 1007 |
+
$timezoneLocal = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
|
| 1008 |
+
|
| 1009 |
+
list ($dateStart, $dateEnd) = Mage::getResourceModel('reports/order_collection')
|
| 1010 |
+
->getDateRange('24h', '', '', true);
|
| 1011 |
+
|
| 1012 |
+
$dateStart->setTimezone($timezoneLocal);
|
| 1013 |
+
$dateEnd->setTimezone($timezoneLocal);
|
| 1014 |
+
|
| 1015 |
+
$dates = array();
|
| 1016 |
+
|
| 1017 |
+
while($dateStart->compare($dateEnd) < 0)
|
| 1018 |
+
{
|
| 1019 |
+
$d = $dateStart->toString('yyyy-MM-dd HH:mm:ss');
|
| 1020 |
+
$dateStart->addHour(1);
|
| 1021 |
+
$dates[] = $d;
|
| 1022 |
+
}
|
| 1023 |
+
|
| 1024 |
+
$start_date = $dates[0];
|
| 1025 |
+
$end_date = $dates[count($dates)-1];
|
| 1026 |
+
|
| 1027 |
+
$orderCollection->addAttributeToFilter('created_at', array('from'=>$start_date, 'to'=>$end_date));
|
| 1028 |
+
$total_count = count($orderCollection);
|
| 1029 |
+
}
|
| 1030 |
+
//echo $type_id; die;
|
| 1031 |
+
if($type_id != 'year')
|
| 1032 |
+
{
|
| 1033 |
+
if ($type_id=='month')
|
| 1034 |
+
{
|
| 1035 |
+
$end_date = date("Y-m-d H:m:s");
|
| 1036 |
+
$start_date = date('Y-m-01 H:m:s');
|
| 1037 |
+
}
|
| 1038 |
+
|
| 1039 |
+
if($type_id!=24)
|
| 1040 |
+
{
|
| 1041 |
+
$orderCollection->addAttributeToFilter('created_at', array('from'=>$start_date, 'to'=>$end_date));
|
| 1042 |
+
$total_count = count($orderCollection);
|
| 1043 |
+
$dates = $this->getDatesFromRange($start_date, $end_date);
|
| 1044 |
+
}
|
| 1045 |
+
$count = 0;
|
| 1046 |
+
foreach($dates as $date)
|
| 1047 |
+
{
|
| 1048 |
+
$orderCollectionByDate = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id',Array('eq'=>$storeId))->addFieldToFilter('status',Array('eq'=>'complete'))->setOrder('entity_id', 'desc');
|
| 1049 |
+
|
| 1050 |
+
if($type_id==24)
|
| 1051 |
+
{
|
| 1052 |
+
$dateStart = $dates[$count];
|
| 1053 |
+
$dateEnd = $dates[$count+1];
|
| 1054 |
+
}
|
| 1055 |
+
else
|
| 1056 |
+
{
|
| 1057 |
+
$dateStart = date('Y-m-d 00:00:00',strtotime($date));
|
| 1058 |
+
$dateEnd = date('Y-m-d 23:59:59',strtotime($date));
|
| 1059 |
+
}
|
| 1060 |
+
$orderByDate = $orderCollectionByDate->addAttributeToFilter('created_at', array('from'=>$dateStart, 'to'=>$dateEnd));
|
| 1061 |
+
$orderByDate->getSelect()->columns('SUM(grand_total) AS grand_total_sum');
|
| 1062 |
+
$orderByDate->getSelect()->group(array('store_id'));
|
| 1063 |
+
$orderdata= $orderByDate->getData();
|
| 1064 |
+
if(count($orderByDate) == 0)
|
| 1065 |
+
{
|
| 1066 |
+
if ($type_id==24)
|
| 1067 |
+
{
|
| 1068 |
+
$orderTotalByDate[date("Y-m-d H:i",strtotime($date))] = 0;
|
| 1069 |
+
}
|
| 1070 |
+
else if ($type_id=='month')
|
| 1071 |
+
{
|
| 1072 |
+
$orderTotalByDate[date('d',strtotime($date))] = 0;
|
| 1073 |
+
}
|
| 1074 |
+
else
|
| 1075 |
+
{
|
| 1076 |
+
$orderTotalByDate[$date] = 0;
|
| 1077 |
+
}
|
| 1078 |
+
}
|
| 1079 |
+
else
|
| 1080 |
+
{
|
| 1081 |
+
if($type_id==24)
|
| 1082 |
+
{
|
| 1083 |
+
$ordersByDate[date("Y-m-d H:i",strtotime($date))][] = $orderdata[0]['grand_total_sum'];
|
| 1084 |
+
$orderTotalByDate[date("Y-m-d H:i",strtotime($date))] = array_sum($ordersByDate[date("Y-m-d H:i",strtotime($date))]);
|
| 1085 |
+
}
|
| 1086 |
+
else if ($type_id=='month')
|
| 1087 |
+
{
|
| 1088 |
+
$ordersByDate[date('d',strtotime($date))][] = $orderdata[0]['grand_total_sum'];
|
| 1089 |
+
$orderTotalByDate[date('d',strtotime($date))] = array_sum($ordersByDate[date('d',strtotime($date))]);
|
| 1090 |
+
}
|
| 1091 |
+
else
|
| 1092 |
+
{
|
| 1093 |
+
$ordersByDate[$date][] = $orderdata[0]['grand_total_sum'];
|
| 1094 |
+
$orderTotalByDate[$date] = array_sum($ordersByDate[$date]);
|
| 1095 |
+
}
|
| 1096 |
+
}
|
| 1097 |
+
|
| 1098 |
+
$count++;
|
| 1099 |
+
}
|
| 1100 |
+
}
|
| 1101 |
+
else
|
| 1102 |
+
{
|
| 1103 |
+
$end_date = date ('Y-m-d');
|
| 1104 |
+
$start_date = date ('Y-01-01');
|
| 1105 |
+
$orderCollection->addAttributeToFilter('created_at', array('from'=>$start_date, 'to'=>$end_date));
|
| 1106 |
+
$total_count = count($orderCollection);
|
| 1107 |
+
$months = $this->get_months($start_date, $end_date);
|
| 1108 |
+
$current_year = date("Y");
|
| 1109 |
+
foreach ($months as $month)
|
| 1110 |
+
{
|
| 1111 |
+
$first_day = $this->firstDay($month,$current_year);
|
| 1112 |
+
$ordersByDate = array();
|
| 1113 |
+
|
| 1114 |
+
if ($month==date('F'))
|
| 1115 |
+
$last_day = date ('Y-m-d');
|
| 1116 |
+
else
|
| 1117 |
+
$last_day = $this->lastday($month,$current_year);
|
| 1118 |
+
|
| 1119 |
+
$dates = $this->getDatesFromRange($first_day, $last_day);
|
| 1120 |
+
|
| 1121 |
+
foreach($dates as $date)
|
| 1122 |
+
{
|
| 1123 |
+
$orderCollectionByDate = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id',Array('eq'=>$storeId))->addFieldToFilter('status',Array('eq'=>'complete'))->setOrder('entity_id', 'desc');
|
| 1124 |
+
$dateStart = date('Y-m-d 00:00:00',strtotime($date));
|
| 1125 |
+
$dateEnd = date('Y-m-d 23:59:59',strtotime($date));
|
| 1126 |
+
$orderByDate = $orderCollectionByDate->addAttributeToFilter('created_at', array('from'=>$dateStart, 'to'=>$dateEnd));
|
| 1127 |
+
$orderByDate->getSelect()->columns('SUM(grand_total) AS grand_total_sum');
|
| 1128 |
+
$orderByDate->getSelect()->group(array('store_id'));
|
| 1129 |
+
$orderdata= $orderByDate->getData();
|
| 1130 |
+
$ordersByDate[] = $orderdata[0]['grand_total_sum'];
|
| 1131 |
+
}
|
| 1132 |
+
|
| 1133 |
+
$orderTotalByDate[$month] = array_sum($ordersByDate);
|
| 1134 |
+
}
|
| 1135 |
+
}
|
| 1136 |
+
|
| 1137 |
+
/*** These commented lines get us grandTotal,lifeTimeSales,averageOrder if you want these, uncomment please ***/
|
| 1138 |
+
//$orderGrandTotal = strip_tags(Mage::helper('core')->currency(array_sum($orderTotalByDate)));
|
| 1139 |
+
//$lifeTimeSales = strip_tags(Mage::helper('core')->currency(round(Mage::getResourceModel('reports/order_collection')->addFieldToFilter('store_id', $storeId)->calculateSales()->load()->getFirstItem()->getLifetime(),2)));
|
| 1140 |
+
//$averageOrder = strip_tags(Mage::helper('core')->currency(round(Mage::getResourceModel('reports/order_collection')->addFieldToFilter('store_id', $storeId)->calculateSales()->load()->getFirstItem()->getAverage(),2)));
|
| 1141 |
+
//$orderTotalResultArr = array('dashboard_result' =>array('ordertotalbydate' => $orderTotalByDate,'ordergrandtotal' => $orderGrandTotal,'totalordercount' => $total_count,'lifetimesales' => $lifeTimeSales,'averageorder' => $averageOrder));
|
| 1142 |
+
|
| 1143 |
+
$orderTotalResultArr = array('dashboard_result' =>array('ordertotalbydate' => $orderTotalByDate));
|
| 1144 |
+
//echo "<pre>"; print_r($orderTotalResultArr); die;
|
| 1145 |
+
$orderDashboardResult = Mage::helper('core')->jsonEncode($orderTotalResultArr);
|
| 1146 |
+
return Mage::app()->getResponse()->setBody($orderDashboardResult);
|
| 1147 |
+
}
|
| 1148 |
+
else
|
| 1149 |
+
{
|
| 1150 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
| 1151 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
| 1152 |
+
}
|
| 1153 |
+
}
|
| 1154 |
+
|
| 1155 |
+
/*
|
| 1156 |
+
* @ get range between two dates
|
| 1157 |
+
* @param: $start_date,$end_date
|
| 1158 |
+
*/
|
| 1159 |
+
public function getDatesFromRange($start_date, $end_date)
|
| 1160 |
+
{
|
| 1161 |
+
$date_from = strtotime(date('Y-m-d', strtotime($start_date)));
|
| 1162 |
+
$date_to = strtotime(date('Y-m-d', strtotime($end_date)));
|
| 1163 |
+
|
| 1164 |
+
for($i=$date_from; $i<=$date_to; $i+=86400)
|
| 1165 |
+
{
|
| 1166 |
+
$dates[] = date("Y-m-d", $i);
|
| 1167 |
+
}
|
| 1168 |
+
return $dates;
|
| 1169 |
+
}
|
| 1170 |
+
|
| 1171 |
+
/*
|
| 1172 |
+
* @ get months
|
| 1173 |
+
* @param: $date1,$date2
|
| 1174 |
+
*/
|
| 1175 |
+
public function get_months($date1, $date2)
|
| 1176 |
+
{
|
| 1177 |
+
$time1 = strtotime($date1);
|
| 1178 |
+
$time2 = strtotime($date2);
|
| 1179 |
+
$my = date('mY', $time2);
|
| 1180 |
+
$months = array();
|
| 1181 |
+
$f = '';
|
| 1182 |
+
|
| 1183 |
+
while($time1 < $time2)
|
| 1184 |
+
{
|
| 1185 |
+
$time1 = strtotime((date('Y-m-d', $time1).' +15days'));
|
| 1186 |
+
|
| 1187 |
+
if(date('m', $time1) != $f)
|
| 1188 |
+
{
|
| 1189 |
+
$f = date('m', $time1);
|
| 1190 |
+
|
| 1191 |
+
if(date('mY', $time1) != $my && ($time1 < $time2))
|
| 1192 |
+
$months[] = date('m', $time1);
|
| 1193 |
+
}
|
| 1194 |
+
}
|
| 1195 |
+
|
| 1196 |
+
$months[] = date('m', $time2);
|
| 1197 |
+
return $months;
|
| 1198 |
+
}
|
| 1199 |
+
|
| 1200 |
+
/*
|
| 1201 |
+
* @ get last day
|
| 1202 |
+
* @param: $month,$year
|
| 1203 |
+
*/
|
| 1204 |
+
public function lastday($month = '', $year = '')
|
| 1205 |
+
{
|
| 1206 |
+
if(empty($month))
|
| 1207 |
+
{
|
| 1208 |
+
$month = date('m');
|
| 1209 |
+
}
|
| 1210 |
+
if(empty($year))
|
| 1211 |
+
{
|
| 1212 |
+
$year = date('Y');
|
| 1213 |
+
}
|
| 1214 |
+
$result = strtotime("{$year}-{$month}-01");
|
| 1215 |
+
$result = strtotime('-1 day', strtotime('+1 month', $result));
|
| 1216 |
+
return date('Y-m-d', $result);
|
| 1217 |
+
}
|
| 1218 |
+
|
| 1219 |
+
/*
|
| 1220 |
+
* @ get first day
|
| 1221 |
+
* @param: $month,$year
|
| 1222 |
+
*/
|
| 1223 |
+
public function firstDay($month = '', $year = '')
|
| 1224 |
+
{
|
| 1225 |
+
if(empty($month))
|
| 1226 |
+
{
|
| 1227 |
+
$month = date('m');
|
| 1228 |
+
}
|
| 1229 |
+
if(empty($year))
|
| 1230 |
+
{
|
| 1231 |
+
$year = date('Y');
|
| 1232 |
+
}
|
| 1233 |
+
$result = strtotime("{$year}-{$month}-01");
|
| 1234 |
+
return date('Y-m-d', $result);
|
| 1235 |
+
}
|
| 1236 |
+
}
|
app/code/local/EmizenTech/MobileAdmin/etc/adminhtml.xml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<acl>
|
| 4 |
+
<resources>
|
| 5 |
+
<admin>
|
| 6 |
+
<children>
|
| 7 |
+
<system>
|
| 8 |
+
<children>
|
| 9 |
+
<config>
|
| 10 |
+
<children>
|
| 11 |
+
<emizen_mob translate="title" module="mobileadmin">
|
| 12 |
+
<title>Emizen Mobile Admin Section</title>
|
| 13 |
+
<sort_order>0</sort_order>
|
| 14 |
+
</emizen_mob>
|
| 15 |
+
</children>
|
| 16 |
+
</config>
|
| 17 |
+
</children>
|
| 18 |
+
</system>
|
| 19 |
+
</children>
|
| 20 |
+
</admin>
|
| 21 |
+
</resources>
|
| 22 |
+
</acl>
|
| 23 |
+
</config>
|
app/code/local/EmizenTech/MobileAdmin/etc/api.xml
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<api>
|
| 4 |
+
<resources>
|
| 5 |
+
<mobileadmin_api translate="title" module="mobileadmin">
|
| 6 |
+
<title>Myapi</title>
|
| 7 |
+
<acl>mobileadmin/api</acl>
|
| 8 |
+
<model>mobileadmin/api</model>
|
| 9 |
+
<methods>
|
| 10 |
+
<create translate="title" module="mobileadmin">
|
| 11 |
+
<title>Create</title>
|
| 12 |
+
<acl>mobileadmin/create</acl>
|
| 13 |
+
</create>
|
| 14 |
+
</methods>
|
| 15 |
+
</mobileadmin_api>
|
| 16 |
+
</resources>
|
| 17 |
+
<acl>
|
| 18 |
+
<resources>
|
| 19 |
+
<mobileadmin translate="title" module="mobileadmin">
|
| 20 |
+
<title>MobileAdmin</title>
|
| 21 |
+
<sort_order>2000</sort_order>
|
| 22 |
+
<create translate="title" module="mobileadmin">
|
| 23 |
+
<title>Create</title>
|
| 24 |
+
</create>
|
| 25 |
+
</mobileadmin>
|
| 26 |
+
</resources>
|
| 27 |
+
</acl>
|
| 28 |
+
</api>
|
| 29 |
+
</config>
|
app/code/local/EmizenTech/MobileAdmin/etc/config.xml
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<EmizenTech_MobileAdmin>
|
| 5 |
+
<version>0.1.0</version>
|
| 6 |
+
</EmizenTech_MobileAdmin>
|
| 7 |
+
</modules>
|
| 8 |
+
<frontend>
|
| 9 |
+
<routers>
|
| 10 |
+
<mobileadmin>
|
| 11 |
+
<use>standard</use>
|
| 12 |
+
<args>
|
| 13 |
+
<module>EmizenTech_MobileAdmin</module>
|
| 14 |
+
<frontName>mobileadmin</frontName>
|
| 15 |
+
</args>
|
| 16 |
+
</mobileadmin>
|
| 17 |
+
</routers>
|
| 18 |
+
<layout>
|
| 19 |
+
<updates>
|
| 20 |
+
<mobileadmin>
|
| 21 |
+
<file>mobileadmin.xml</file>
|
| 22 |
+
</mobileadmin>
|
| 23 |
+
</updates>
|
| 24 |
+
</layout>
|
| 25 |
+
</frontend>
|
| 26 |
+
<global>
|
| 27 |
+
<helpers>
|
| 28 |
+
<mobileadmin>
|
| 29 |
+
<class>EmizenTech_MobileAdmin_Helper</class>
|
| 30 |
+
</mobileadmin>
|
| 31 |
+
</helpers>
|
| 32 |
+
<blocks>
|
| 33 |
+
<mobileadmin>
|
| 34 |
+
<class>EmizenTech_MobileAdmin_Block</class>
|
| 35 |
+
</mobileadmin>
|
| 36 |
+
</blocks>
|
| 37 |
+
<models>
|
| 38 |
+
<mobileadmin>
|
| 39 |
+
<class>EmizenTech_MobileAdmin_Model</class>
|
| 40 |
+
<resourceModel>mobileadmin_mysql4</resourceModel>
|
| 41 |
+
</mobileadmin>
|
| 42 |
+
<mobileadmin_mysql4>
|
| 43 |
+
<class>EmizenTech_MobileAdmin_Model_Mysql4</class>
|
| 44 |
+
<entities>
|
| 45 |
+
<emizenmob>
|
| 46 |
+
<table>emizenmob</table>
|
| 47 |
+
</emizenmob>
|
| 48 |
+
</entities>
|
| 49 |
+
</mobileadmin_mysql4>
|
| 50 |
+
</models>
|
| 51 |
+
<resources>
|
| 52 |
+
<mobileadmin_setup>
|
| 53 |
+
<setup>
|
| 54 |
+
<module>EmizenTech_MobileAdmin</module>
|
| 55 |
+
</setup>
|
| 56 |
+
<connection>
|
| 57 |
+
<use>core_setup</use>
|
| 58 |
+
</connection>
|
| 59 |
+
</mobileadmin_setup>
|
| 60 |
+
<mobileadmin_write>
|
| 61 |
+
<connection>
|
| 62 |
+
<use>core_write</use>
|
| 63 |
+
</connection>
|
| 64 |
+
</mobileadmin_write>
|
| 65 |
+
<mobileadmin_read>
|
| 66 |
+
<connection>
|
| 67 |
+
<use>core_read</use>
|
| 68 |
+
</connection>
|
| 69 |
+
</mobileadmin_read>
|
| 70 |
+
</resources>
|
| 71 |
+
<events>
|
| 72 |
+
<sales_order_save_after> <!-- identifier of the event we want to catch -->
|
| 73 |
+
<observers>
|
| 74 |
+
<sales_order_save_after_handler> <!-- identifier of the event handler -->
|
| 75 |
+
<type>model</type> <!-- class method call type; valid are model, object and singleton -->
|
| 76 |
+
<class>mobileadmin/observer</class> <!-- observers class alias -->
|
| 77 |
+
<method>salesOrderSaveAfter</method> <!-- observer's method to be called -->
|
| 78 |
+
<args></args> <!-- additional arguments passed to observer -->
|
| 79 |
+
</sales_order_save_after_handler>
|
| 80 |
+
</observers>
|
| 81 |
+
</sales_order_save_after>
|
| 82 |
+
<customer_register_success> <!-- identifier of the event we want to catch -->
|
| 83 |
+
<observers>
|
| 84 |
+
<customer_register_success_handler> <!-- identifier of the event handler -->
|
| 85 |
+
<type>model</type> <!-- class method call type; valid are model, object and singleton -->
|
| 86 |
+
<class>mobileadmin/observer</class> <!-- observers class alias -->
|
| 87 |
+
<method>customerRegisterNotification</method> <!-- observer's method to be called -->
|
| 88 |
+
<args></args> <!-- additional arguments passed to observer -->
|
| 89 |
+
</customer_register_success_handler>
|
| 90 |
+
</observers>
|
| 91 |
+
</customer_register_success>
|
| 92 |
+
<customer_register_checkout> <!-- identifier of the event we want to catch -->
|
| 93 |
+
<observers>
|
| 94 |
+
<customer_register_checkout_handler> <!-- identifier of the event handler -->
|
| 95 |
+
<type>model</type> <!-- class method call type; valid are model, object and singleton -->
|
| 96 |
+
<class>mobileadmin/observer</class> <!-- observers class alias -->
|
| 97 |
+
<method>customerRegisterNotificationCheckout</method> <!-- observer's method to be called -->
|
| 98 |
+
<args></args> <!-- additional arguments passed to observer -->
|
| 99 |
+
</customer_register_checkout_handler>
|
| 100 |
+
</observers>
|
| 101 |
+
</customer_register_checkout>
|
| 102 |
+
</events>
|
| 103 |
+
</global>
|
| 104 |
+
</config>
|
app/code/local/EmizenTech/MobileAdmin/etc/system.xml
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<tabs>
|
| 4 |
+
<emizen_extension translate="label" module="mobileadmin">
|
| 5 |
+
<label>Emizentech Extensions</label>
|
| 6 |
+
<sort_order>0</sort_order>
|
| 7 |
+
</emizen_extension>
|
| 8 |
+
</tabs>
|
| 9 |
+
<sections>
|
| 10 |
+
<emizen_mob translate="label" module="mobileadmin">
|
| 11 |
+
<label>Emizen Mobile Admin</label>
|
| 12 |
+
<tab>emizen_extension</tab>
|
| 13 |
+
<frontend_type>text</frontend_type>
|
| 14 |
+
<sort_order>0</sort_order>
|
| 15 |
+
<show_in_default>1</show_in_default>
|
| 16 |
+
<show_in_website>1</show_in_website>
|
| 17 |
+
<show_in_store>1</show_in_store>
|
| 18 |
+
<groups>
|
| 19 |
+
<emizen_general translate="label">
|
| 20 |
+
<label>General</label>
|
| 21 |
+
<frontend_type>text</frontend_type>
|
| 22 |
+
<sort_order>0</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 |
+
<fields>
|
| 27 |
+
<enabled translate="label">
|
| 28 |
+
<label>Enabled</label>
|
| 29 |
+
<frontend_type>select</frontend_type>
|
| 30 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 31 |
+
<sort_order>0</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 |
+
<comment>Select Yes to enable this extension.</comment>
|
| 36 |
+
</enabled>
|
| 37 |
+
<emizen_noti translate="label">
|
| 38 |
+
<label>New Order Notification Message</label>
|
| 39 |
+
<frontend_type>text</frontend_type>
|
| 40 |
+
<sort_order>0</sort_order>
|
| 41 |
+
<show_in_default>1</show_in_default>
|
| 42 |
+
<show_in_website>1</show_in_website>
|
| 43 |
+
<show_in_store>1</show_in_store>
|
| 44 |
+
<comment>Enter your message which will be received on the Mobile app whenever a New Order is received.</comment>
|
| 45 |
+
</emizen_noti>
|
| 46 |
+
<emizen_register translate="label">
|
| 47 |
+
<label>New Customer Register Notification Message</label>
|
| 48 |
+
<frontend_type>text</frontend_type>
|
| 49 |
+
<sort_order>0</sort_order>
|
| 50 |
+
<show_in_default>1</show_in_default>
|
| 51 |
+
<show_in_website>1</show_in_website>
|
| 52 |
+
<show_in_store>1</show_in_store>
|
| 53 |
+
<comment>Enter your message which will be received on the Mobile app whenever a New Customer is registered.</comment>
|
| 54 |
+
</emizen_register>
|
| 55 |
+
</fields>
|
| 56 |
+
</emizen_general>
|
| 57 |
+
</groups>
|
| 58 |
+
</emizen_mob>
|
| 59 |
+
</sections>
|
| 60 |
+
</config>
|
app/code/local/EmizenTech/MobileAdmin/sql/mobileadmin_setup/mysql4-install-0.1.0.php
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
$installer = $this;
|
| 5 |
+
|
| 6 |
+
$installer->startSetup();
|
| 7 |
+
|
| 8 |
+
$installer->run("
|
| 9 |
+
|
| 10 |
+
-- DROP TABLE IF EXISTS {$this->getTable('emizenmob')};
|
| 11 |
+
CREATE TABLE {$this->getTable('emizenmob')} (
|
| 12 |
+
`user_id` int(11) unsigned NOT NULL auto_increment,
|
| 13 |
+
`username` varchar(255) NOT NULL default '',
|
| 14 |
+
`firstname` varchar(255) NOT NULL default '',
|
| 15 |
+
`lastname` varchar(255) NOT NULL default '',
|
| 16 |
+
`email` varchar(255) NOT NULL default '',
|
| 17 |
+
`apikey` varchar(40) NOT NULL default '',
|
| 18 |
+
`device_token` varchar(255) NOT NULL default '',
|
| 19 |
+
`notification_flag` smallint(11) NOT NULL default '1',
|
| 20 |
+
PRIMARY KEY (`user_id`)
|
| 21 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
| 22 |
+
|
| 23 |
+
ALTER TABLE `{$installer->getTable('emizenmob')}` ADD `device_type` VARCHAR( 255 ) NOT NULL DEFAULT '',
|
| 24 |
+
ADD `is_logout` SMALLINT( 11 ) NOT NULL DEFAULT '0';
|
| 25 |
+
|
| 26 |
+
");
|
| 27 |
+
|
| 28 |
+
$installer->endSetup();
|
| 29 |
+
|
app/design/frontend/base/default/layout/mobileadmin.xml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<layout version="0.1.0">
|
| 3 |
+
<mobileadmin_index_index>
|
| 4 |
+
<reference name="root">
|
| 5 |
+
<action method="setTemplate"><template>page/1column.phtml</template></action>
|
| 6 |
+
</reference>
|
| 7 |
+
<reference name="content">
|
| 8 |
+
<block type="mobileadmin/index" name="mobileadmin_index" template="mobileadmin/index.phtml"/>
|
| 9 |
+
</reference>
|
| 10 |
+
</mobileadmin_index_index>
|
| 11 |
+
</layout>
|
| 12 |
+
|
app/design/frontend/base/default/template/mobileadmin/index.phtml
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
| 1 |
+
Demo Page
|
app/etc/modules/EmizenTech_MobileAdmin.xml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<EmizenTech_MobileAdmin>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>local</codePool>
|
| 7 |
+
<depends>
|
| 8 |
+
<Mage_Api />
|
| 9 |
+
</depends>
|
| 10 |
+
<version>0.1.0</version>
|
| 11 |
+
</EmizenTech_MobileAdmin>
|
| 12 |
+
</modules>
|
| 13 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>emizenmobileadmin</name>
|
| 4 |
+
<version>1.0.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>You can Now Track you all the Magento Backend Activity Using our Emizentech Magento Mobile Apps . IT has very great feature API to display All the Sales Activity with Graph . You can now easily see all the Magento Orders Listing , Product Listing, Customer Listing .</summary>
|
| 10 |
+
<description>You can Now Track you all the Magento Backend Activity Using our Emizentech Magento Mobile Apps . IT has very great feature API to display All the Sales Activity with Graph . You can now easily see all the Magento Orders Listing , Product Listing, Customer Listing .
|
| 11 |
+

|
| 12 |
+
Features :
|
| 13 |
+

|
| 14 |
+
* Wonderful View of your Sales with Days Filter Graph 
|
| 15 |
+
* Sales Listing View with Details.
|
| 16 |
+
* Customer Listing View with Details
|
| 17 |
+
* Product Listing View With Details
|
| 18 |
+
* Store view Selection For Dashboard,
|
| 19 |
+
* Multistore Support</description>
|
| 20 |
+
<notes>You can Now Track you all the Magento Backend Activity Using our Emizentech Magento Mobile Apps . IT has very great feature API to display All the Sales Activity with Graph . You can now easily see all the Magento Orders Listing , Product Listing, Customer Listing .
|
| 21 |
+

|
| 22 |
+
Features :
|
| 23 |
+

|
| 24 |
+
* Wonderful View of your Sales with Days Filter Graph 
|
| 25 |
+
* Sales Listing View with Details.
|
| 26 |
+
* Customer Listing View with Details
|
| 27 |
+
* Product Listing View With Details
|
| 28 |
+
* Store view Selection For Dashboard,
|
| 29 |
+
* Multistore Support</notes>
|
| 30 |
+
<authors><author><name>Emizen Tech Private Limited</name><user>emizen</user><email>info@emizentech.com</email></author></authors>
|
| 31 |
+
<date>2015-02-26</date>
|
| 32 |
+
<time>07:35:04</time>
|
| 33 |
+
<contents><target name="mageetc"><dir name="modules"><file name="EmizenTech_MobileAdmin.xml" hash="3d9904aebe449343c74004cd160e0b89"/></dir></target><target name="magelocal"><dir name="EmizenTech"><dir name="MobileAdmin"><dir><dir name="Block"><file name="Index.php" hash="76f331d88fb83bbe3135c494d084e4b7"/></dir><dir name="Helper"><file name="Data.php" hash="050f273a8167c77d433a4299d72cebf4"/></dir><dir name="Model"><file name="Api.php" hash="1139274252b522c02ad26655ca1fc641"/><file name="Emizenmob.php" hash="0b2018dfc93072b5712d20ed676c8a30"/><dir name="Mysql4"><dir name="Emizenmob"><file name="Collection.php" hash="6b958aa1ddc5d96955dbdf4bdd7f6976"/></dir><file name="Emizenmob.php" hash="1285e93887bc67933f0bac32bed8b762"/></dir><file name="Observer.php" hash="515e8170f58026548ec871e5d35d9e01"/></dir><dir name="controllers"><file name="IndexController.php" hash="92521ef8f54734a897d72d04fb880729"/></dir><dir name="etc"><file name="adminhtml.xml" hash="53c7b1eb3b23e2cf8b899309517a1c14"/><file name="api.xml" hash="c81e576c36f189af6dffefca1a746622"/><file name="config.xml" hash="fc55154f0afa4f68e7c501cdf6145b27"/><file name="system.xml" hash="6f7e1b090d771a29e5d2d4777d7e4304"/></dir><dir name="sql"><dir name="mobileadmin_setup"><file name="mysql4-install-0.1.0.php" hash="3faa6e0c9146571ac842f5aeeedf961c"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="mobileadmin"><file name="index.phtml" hash="395b5512423d31a9526f94e3d7dcc13a"/></dir></dir><dir name="layout"><file name="mobileadmin.xml" hash="bf0ff6a1d30dfeb5b159c72eff4311ae"/></dir></dir></dir></dir></target></contents>
|
| 34 |
+
<compatible/>
|
| 35 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 36 |
+
</package>
|
