Version Notes
-Provided theme change from Dashboard
-Enhanced Notification
Download this release
Release Info
Developer | Biztech |
Extension | magento_mobile_assistant_manager |
Version | 0.2.1 |
Comparing to | |
See all releases |
Code changes from version 0.2.0 to 0.2.1
- app/code/local/Biztech/All/Model/Update.php +33 -39
- app/code/local/Biztech/All/etc/config.xml +30 -57
- app/code/local/Biztech/Authentication/controllers/IndexController.php +199 -0
- app/code/local/Biztech/Authentication/etc/config.xml +31 -0
- app/code/local/Biztech/Mobileassistant/controllers/CustomerController.php +236 -201
- app/code/local/Biztech/Mobileassistant/controllers/DashboardController.php +664 -656
- app/code/local/Biztech/Mobileassistant/controllers/OrderController.php +359 -307
- app/code/local/Biztech/Mobileassistant/controllers/ProductController.php +316 -247
- app/code/local/Biztech/Mobileassistant/etc/config.xml +1 -1
- app/etc/modules/Biztech_Authentication.xml +17 -0
- package.xml +6 -6
app/code/local/Biztech/All/Model/Update.php
CHANGED
@@ -34,56 +34,50 @@
|
|
34 |
$feedData = array();
|
35 |
$extensio_module = array();
|
36 |
try{
|
37 |
-
$xml
|
38 |
-
$limit_context = stream_context_create(array('http'=>array('timeout' => 5)));
|
39 |
-
$xml = file_get_contents(self::UPDATE_NOTIFICATION_FEED_URL,true,$limit_context);
|
40 |
$xml = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);//LIBXML_NOCDATA LIBXML_NOWARNING
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
$extensions_name = (string)$extensions->update_notifications->extensions;
|
52 |
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
'severity' => 4,
|
58 |
-
'date_added' => (string) $extensions->update_notifications->date,
|
59 |
-
'title' => (string)$extensions->update_notifications->extension_title,
|
60 |
-
'description' => (string)$extensions->update_notifications->extension_content,
|
61 |
-
'url' => (string)$extensions->update_notifications->product_url,
|
62 |
-
);
|
63 |
-
}
|
64 |
-
} else{
|
65 |
-
$feedData[] = array(
|
66 |
'severity' => 4,
|
67 |
-
'date_added' => (string)$extensions->update_notifications->date,
|
68 |
'title' => (string)$extensions->update_notifications->extension_title,
|
69 |
'description' => (string)$extensions->update_notifications->extension_content,
|
70 |
'url' => (string)$extensions->update_notifications->product_url,
|
71 |
);
|
72 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
}
|
74 |
}
|
75 |
-
if ($feedData) {
|
76 |
-
foreach($feedData as $data){
|
77 |
-
if ((array_intersect($types,$interests) && $isInterestedInSelfUpgrades)) {
|
78 |
-
Mage::getModel('adminnotification/inbox')->parse(array_reverse(array($data)));
|
79 |
-
}
|
80 |
-
}
|
81 |
-
}
|
82 |
-
Mage::app()->saveCache(time(), 'biztech_all_updates_feed_lastcheck');
|
83 |
-
return true;
|
84 |
}
|
85 |
-
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
}
|
88 |
}catch (Exception $e) {
|
89 |
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
34 |
$feedData = array();
|
35 |
$extensio_module = array();
|
36 |
try{
|
37 |
+
$xml = file_get_contents(self::UPDATE_NOTIFICATION_FEED_URL);
|
|
|
|
|
38 |
$xml = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);//LIBXML_NOCDATA LIBXML_NOWARNING
|
39 |
|
40 |
+
$interests = $this->getInterests();
|
41 |
+
if(!empty($interests[0])){
|
42 |
+
$isInterestedInSelfUpgrades = in_array(Biztech_All_Model_Source_Updates_Type::TYPE_INSTALLED_UPDATE, $interests);
|
43 |
+
$isInterestedInAllUpgrades = in_array(Biztech_All_Model_Source_Updates_Type::TYPE_UPDATE_RELEASE, $interests);
|
44 |
+
$modules = Mage::getConfig()->getNode('modules')->children();
|
45 |
+
$modulesArray = (array)$modules;
|
46 |
+
foreach($xml->channel->item as $keys=>$extensions) {
|
47 |
+
$types[] = (string) $extensions->update_notifications->type;
|
48 |
+
$extensions_name = (string)$extensions->update_notifications->extensions;
|
|
|
49 |
|
50 |
+
if((string)$extensions->update_notifications->date!=""&&(string)$extensions->update_notifications->extension_title!=""&&(string)$extensions->update_notifications->extension_content!=""&&(string)$extensions->update_notifications->product_url!=""){
|
51 |
+
if(!$isInterestedInAllUpgrades){
|
52 |
+
if ($this->isExtensionInstalled($extensions_name)) {
|
53 |
+
$feedData[] = array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
'severity' => 4,
|
55 |
+
'date_added' => (string) $extensions->update_notifications->date,
|
56 |
'title' => (string)$extensions->update_notifications->extension_title,
|
57 |
'description' => (string)$extensions->update_notifications->extension_content,
|
58 |
'url' => (string)$extensions->update_notifications->product_url,
|
59 |
);
|
60 |
+
}
|
61 |
+
} else{
|
62 |
+
$feedData[] = array(
|
63 |
+
'severity' => 4,
|
64 |
+
'date_added' => (string)$extensions->update_notifications->date,
|
65 |
+
'title' => (string)$extensions->update_notifications->extension_title,
|
66 |
+
'description' => (string)$extensions->update_notifications->extension_content,
|
67 |
+
'url' => (string)$extensions->update_notifications->product_url,
|
68 |
+
);
|
69 |
}
|
70 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
}
|
72 |
+
if ($feedData) {
|
73 |
+
foreach($feedData as $data){
|
74 |
+
if ((array_intersect($types,$interests) && $isInterestedInSelfUpgrades)) {
|
75 |
+
Mage::getModel('adminnotification/inbox')->parse(array_reverse(array($data)));
|
76 |
+
}
|
77 |
+
}
|
78 |
+
}
|
79 |
+
Mage::app()->saveCache(time(), 'biztech_all_updates_feed_lastcheck');
|
80 |
+
return true;
|
81 |
}
|
82 |
}catch (Exception $e) {
|
83 |
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
app/code/local/Biztech/All/etc/config.xml
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<!--
|
3 |
/**
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
<config>
|
11 |
<modules>
|
12 |
<Biztech_All>
|
13 |
-
<version>0.1.
|
14 |
</Biztech_All>
|
15 |
</modules>
|
16 |
<frontend>
|
@@ -23,58 +23,38 @@
|
|
23 |
</args>
|
24 |
</all>
|
25 |
</routers>
|
26 |
-
<!--<layout>
|
27 |
-
<updates>
|
28 |
-
<all>
|
29 |
-
<file>all.xml</file>
|
30 |
-
</all>
|
31 |
-
</updates>
|
32 |
-
</layout>-->
|
33 |
</frontend>
|
34 |
<admin>
|
35 |
<routers>
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
</routers>
|
44 |
</admin>
|
45 |
<adminhtml>
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
<all>
|
62 |
-
<title>Allow Everything</title>
|
63 |
-
</all>
|
64 |
-
<admin>
|
65 |
-
<children>
|
66 |
-
<Biztech_All>
|
67 |
-
<title>All Module</title>
|
68 |
-
<sort_order>10</sort_order>
|
69 |
-
</Biztech_All>
|
70 |
-
</children>
|
71 |
-
</admin>
|
72 |
-
</resources>
|
73 |
-
</acl>
|
74 |
<events>
|
75 |
<controller_action_predispatch>
|
76 |
<observers>
|
77 |
-
|
78 |
<bzall_upds>
|
79 |
<type>singleton</type>
|
80 |
<class>all/update</class>
|
@@ -83,13 +63,6 @@
|
|
83 |
</observers>
|
84 |
</controller_action_predispatch>
|
85 |
</events>
|
86 |
-
<!--<layout>
|
87 |
-
<updates>
|
88 |
-
<all>
|
89 |
-
<file>all.xml</file>
|
90 |
-
</all>
|
91 |
-
</updates>
|
92 |
-
</layout> -->
|
93 |
</adminhtml>
|
94 |
<global>
|
95 |
<models>
|
1 |
<?xml version="1.0"?>
|
2 |
<!--
|
3 |
/**
|
4 |
+
* @category Biztech
|
5 |
+
* @package Biztech_All
|
6 |
+
* @author ModuleCreator
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
-->
|
10 |
<config>
|
11 |
<modules>
|
12 |
<Biztech_All>
|
13 |
+
<version>0.1.1</version>
|
14 |
</Biztech_All>
|
15 |
</modules>
|
16 |
<frontend>
|
23 |
</args>
|
24 |
</all>
|
25 |
</routers>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
</frontend>
|
27 |
<admin>
|
28 |
<routers>
|
29 |
+
<adminhtml>
|
30 |
+
<args>
|
31 |
+
<module>
|
32 |
+
<all>Biztech_All_Adminhtml</all>
|
33 |
+
</module>
|
34 |
+
</args>
|
35 |
+
</adminhtml>
|
36 |
</routers>
|
37 |
</admin>
|
38 |
<adminhtml>
|
39 |
+
<acl>
|
40 |
+
<resources>
|
41 |
+
<all>
|
42 |
+
<title>Allow Everything</title>
|
43 |
+
</all>
|
44 |
+
<admin>
|
45 |
+
<children>
|
46 |
+
<Biztech_All>
|
47 |
+
<title>All Module</title>
|
48 |
+
<sort_order>10</sort_order>
|
49 |
+
</Biztech_All>
|
50 |
+
</children>
|
51 |
+
</admin>
|
52 |
+
</resources>
|
53 |
+
</acl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
<events>
|
55 |
<controller_action_predispatch>
|
56 |
<observers>
|
57 |
+
|
58 |
<bzall_upds>
|
59 |
<type>singleton</type>
|
60 |
<class>all/update</class>
|
63 |
</observers>
|
64 |
</controller_action_predispatch>
|
65 |
</events>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
</adminhtml>
|
67 |
<global>
|
68 |
<models>
|
app/code/local/Biztech/Authentication/controllers/IndexController.php
ADDED
@@ -0,0 +1,199 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Biztech_Authentication_IndexController extends Mage_Core_Controller_Front_Action {
|
4 |
+
|
5 |
+
public function indexAction() {
|
6 |
+
if (Mage::getStoreConfig('mobileassistant/mobileassistant_general/enabled')) {
|
7 |
+
|
8 |
+
$isSecure = Mage::app()->getFrontController()->getRequest()->isSecure();
|
9 |
+
$validate_url = false;
|
10 |
+
if ($isSecure) {
|
11 |
+
if (Mage::getStoreConfig('web/secure/base_url') == Mage::getStoreConfig('web/secure/base_link_url')) {
|
12 |
+
$validate_url = true;
|
13 |
+
}
|
14 |
+
} else {
|
15 |
+
if (Mage::getStoreConfig('web/unsecure/base_url') == Mage::getStoreConfig('web/unsecure/base_link_url')) {
|
16 |
+
$validate_url = true;
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
20 |
+
if ($validate_url) {
|
21 |
+
|
22 |
+
$details = Mage::app()->getRequest()->getParams();
|
23 |
+
|
24 |
+
$username = $details['userapi'];
|
25 |
+
$password = $details['keyapi'];
|
26 |
+
$deviceToken = $details['token'];
|
27 |
+
$flag = $details['notification_flag'];
|
28 |
+
$device_type = $details['device_type'];
|
29 |
+
|
30 |
+
Mage::register('isSecureArea', true);
|
31 |
+
|
32 |
+
$config = Mage::getStoreConfigFlag('admin/security/use_case_sensitive_login');
|
33 |
+
Mage::getSingleton('core/session', array('name' => 'adminhtml'));
|
34 |
+
$user = Mage::getModel('admin/user')->loadByUsername($username);
|
35 |
+
|
36 |
+
$sensitive = ($config) ? $username == $user->getUsername() : true;
|
37 |
+
|
38 |
+
if ($sensitive && $user->getId() && Mage::helper('core')->validateHash($password, $user->getPassword())) {
|
39 |
+
if ($user->getIsActive() != '1') {
|
40 |
+
$result['error'] = Mage::helper('adminhtml')->__('This account is inactive.');
|
41 |
+
}
|
42 |
+
if (!$user->hasAssigned2Role($user->getId())) {
|
43 |
+
$result['error'] = Mage::helper('adminhtml')->__('Access denied.');
|
44 |
+
}
|
45 |
+
} else {
|
46 |
+
$result['error'] = $this->__('Invalid User Name or Password.');
|
47 |
+
$jsonData = Mage::helper('core')->jsonEncode($result);
|
48 |
+
return Mage::app()->getResponse()->setBody($jsonData);
|
49 |
+
}
|
50 |
+
if (Mage::getSingleton('adminhtml/url')->useSecretKey()) {
|
51 |
+
Mage::getSingleton('adminhtml/url')->renewSecretUrls();
|
52 |
+
}
|
53 |
+
$session = Mage::getSingleton('admin/session');
|
54 |
+
|
55 |
+
$session->setIsFirstVisit(true);
|
56 |
+
$session->setUser($user);
|
57 |
+
$session->setAcl(Mage::getResourceModel('admin/acl')->loadAcl());
|
58 |
+
$session_id = $user->getId() . '_' . md5($username);
|
59 |
+
|
60 |
+
Mage::dispatchEvent('admin_session_user_login_success', array('user' => $user));
|
61 |
+
|
62 |
+
Mage::unregister('isSecureArea');
|
63 |
+
|
64 |
+
if ($session_id) {
|
65 |
+
$data = array('username' => $username, 'password' => $user->getPassword(), 'devicetoken' => $deviceToken, 'session_id' => $session_id, 'notification_flag' => $flag, 'device_type' => $device_type, 'is_logout' => 0);
|
66 |
+
$result = Mage::helper('mobileassistant')->create($data);
|
67 |
+
|
68 |
+
|
69 |
+
$jsonData = Mage::helper('core')->jsonEncode($result);
|
70 |
+
return Mage::app()->getResponse()->setBody($jsonData);
|
71 |
+
}
|
72 |
+
} else {
|
73 |
+
$result['error'] = $this->__('There seems some difference between the Based URL & Magento Based URL(on the store). Please check & if issue persists, Contact our Support Team.');
|
74 |
+
}
|
75 |
+
} else {
|
76 |
+
$result['error'] = $this->__('Please activate the Mobile Assistant Extension on the Magento Store.');
|
77 |
+
}
|
78 |
+
$jsonData = Mage::helper('core')->jsonEncode($result);
|
79 |
+
return Mage::app()->getResponse()->setBody($jsonData);
|
80 |
+
}
|
81 |
+
|
82 |
+
public function testModuleAction() {
|
83 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
84 |
+
$url = $post_data['magento_url'];
|
85 |
+
$url_info = parse_url($url);
|
86 |
+
|
87 |
+
if (Mage::getConfig()->getModuleConfig('Biztech_Mobileassistant')->is('active', 'true') && Mage::getStoreConfig('mobileassistant/mobileassistant_general/enabled')) {
|
88 |
+
|
89 |
+
$isSecure = Mage::app()->getFrontController()->getRequest()->isSecure();
|
90 |
+
$validate_url = false;
|
91 |
+
if ($isSecure) {
|
92 |
+
if (Mage::getStoreConfig('web/secure/base_url') == Mage::getStoreConfig('web/secure/base_link_url')) {
|
93 |
+
$validate_url = true;
|
94 |
+
}
|
95 |
+
|
96 |
+
if ($url_info['scheme'] == 'http') {
|
97 |
+
$result['error'] = $this->__('It seems you use secure url for your store. So please use "https". ');
|
98 |
+
$jsonData = Mage::helper('core')->jsonEncode($result);
|
99 |
+
return Mage::app()->getResponse()->setBody($jsonData);
|
100 |
+
}
|
101 |
+
} else {
|
102 |
+
if (Mage::getStoreConfig('web/unsecure/base_url') == Mage::getStoreConfig('web/unsecure/base_link_url')) {
|
103 |
+
$validate_url = true;
|
104 |
+
}
|
105 |
+
}
|
106 |
+
if ($validate_url) {
|
107 |
+
|
108 |
+
$is_index = Mage::getStoreConfig('web/seo/use_rewrites');
|
109 |
+
if (!$is_index && basename($url) != 'index.php') {
|
110 |
+
$result['error'] = $this->__('Please add "index.php" after your url.');
|
111 |
+
$jsonData = Mage::helper('core')->jsonEncode($result);
|
112 |
+
return Mage::app()->getResponse()->setBody($jsonData);
|
113 |
+
}
|
114 |
+
|
115 |
+
$result['success'] = $this->__('Hurray! The connection with the Magento Site worked out fine & you can start using the App.');
|
116 |
+
} else {
|
117 |
+
$result['error'] = $this->__('There seems some difference between the Based URL & Magento Based URL(on the store). Please check & if issue persists, Contact our Support Team.');
|
118 |
+
}
|
119 |
+
} else {
|
120 |
+
$result['error'] = $this->__('Please activate the Mobile Assistant Extension on the Magento Store.');
|
121 |
+
}
|
122 |
+
$jsonData = Mage::helper('core')->jsonEncode($result);
|
123 |
+
return Mage::app()->getResponse()->setBody($jsonData);
|
124 |
+
}
|
125 |
+
|
126 |
+
public function changeSettingsAction() {
|
127 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
128 |
+
$user = $post_data['userapi'];
|
129 |
+
$deviceToken = $post_data['token'];
|
130 |
+
$flag = $post_data['notification_flag'];
|
131 |
+
$collections = Mage::getModel("mobileassistant/mobileassistant")->getCollection()->addFieldToFilter('username', Array('eq' => $user))->addFieldToFilter('device_token', Array('eq' => $deviceToken));
|
132 |
+
$count = count($collections);
|
133 |
+
|
134 |
+
foreach ($collections as $user) {
|
135 |
+
$user_id = $user->getUserId();
|
136 |
+
}
|
137 |
+
if ($count == 1) {
|
138 |
+
try {
|
139 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
140 |
+
$connection->beginTransaction();
|
141 |
+
$fields = array();
|
142 |
+
$fields['notification_flag'] = $flag;
|
143 |
+
$where = $connection->quoteInto('user_id =?', $user_id);
|
144 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
145 |
+
$connection->update($prefix . 'mobileassistant', $fields, $where);
|
146 |
+
$connection->commit();
|
147 |
+
} catch (Exception $e) {
|
148 |
+
return $e->getMessage();
|
149 |
+
}
|
150 |
+
$successArr[] = array('success_msg' => 'Settings updated sucessfully');
|
151 |
+
$result = Mage::helper('core')->jsonEncode($successArr);
|
152 |
+
return Mage::app()->getResponse()->setBody($result);
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
public function getLogoAndCurrencyAction() {
|
157 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
158 |
+
$storeId = $post_data['storeid'];
|
159 |
+
$block = new Mage_Page_Block_Html_Header();
|
160 |
+
$logo = $block->getLogoSrc();
|
161 |
+
|
162 |
+
$currency_code = Mage::getModel('core/store')->load($storeId)->getCurrentCurrencyCode();
|
163 |
+
|
164 |
+
$isPos = 0;
|
165 |
+
$resultArr = array('logo' => $logo, 'currency_symbol' => Mage::app()->getLocale()->currency($currency_code)->getSymbol(), 'is_pos' => $isPos, 'is_inventory'=>1);
|
166 |
+
$result = Mage::helper('core')->jsonEncode($resultArr);
|
167 |
+
return Mage::app()->getResponse()->setBody($result);
|
168 |
+
}
|
169 |
+
|
170 |
+
public function logoutAction() {
|
171 |
+
|
172 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
173 |
+
$user = $post_data['userapi'];
|
174 |
+
$deviceToken = $post_data['token'];
|
175 |
+
$collections = Mage::getModel("mobileassistant/mobileassistant")->getCollection()->addFieldToFilter('device_token', Array('eq' => $deviceToken));
|
176 |
+
$count = count($collections);
|
177 |
+
|
178 |
+
foreach ($collections as $user) {
|
179 |
+
$device_token = $user->getDeviceToken();
|
180 |
+
|
181 |
+
try {
|
182 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
183 |
+
$connection->beginTransaction();
|
184 |
+
$fields = array();
|
185 |
+
$fields['is_logout'] = 1;
|
186 |
+
$where = $connection->quoteInto('device_token =?', $device_token);
|
187 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
188 |
+
$connection->update($prefix . 'mobileassistant', $fields, $where);
|
189 |
+
$connection->commit();
|
190 |
+
} catch (Exception $e) {
|
191 |
+
return $e->getMessage();
|
192 |
+
}
|
193 |
+
$successArr[] = array('success_msg' => 'User logout successfully.');
|
194 |
+
$result = Mage::helper('core')->jsonEncode($successArr);
|
195 |
+
return Mage::app()->getResponse()->setBody($result);
|
196 |
+
}
|
197 |
+
}
|
198 |
+
|
199 |
+
}
|
app/code/local/Biztech/Authentication/etc/config.xml
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<config>
|
4 |
+
<modules>
|
5 |
+
<Biztech_Authentication>
|
6 |
+
<version>0.1.0</version>
|
7 |
+
</Biztech_Authentication>
|
8 |
+
</modules>
|
9 |
+
<frontend>
|
10 |
+
<routers>
|
11 |
+
<authentication>
|
12 |
+
<use>standard</use>
|
13 |
+
<args>
|
14 |
+
<module>Biztech_Authentication</module>
|
15 |
+
<frontName>authentication</frontName>
|
16 |
+
</args>
|
17 |
+
</authentication>
|
18 |
+
</routers>
|
19 |
+
</frontend>
|
20 |
+
<admin>
|
21 |
+
<routers>
|
22 |
+
<adminhtml>
|
23 |
+
<args>
|
24 |
+
<modules>
|
25 |
+
<authentication after="Mage_Adminhtml">Biztech_Authentication_Adminhtml</authentication>
|
26 |
+
</modules>
|
27 |
+
</args>
|
28 |
+
</adminhtml>
|
29 |
+
</routers>
|
30 |
+
</admin>
|
31 |
+
</config>
|
app/code/local/Biztech/Mobileassistant/controllers/CustomerController.php
CHANGED
@@ -1,201 +1,236 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
$
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
$
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
}
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
'
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
'
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Biztech_Mobileassistant_CustomerController extends Mage_Core_Controller_Front_Action {
|
4 |
+
|
5 |
+
public function getCustomerListAction() {
|
6 |
+
if (Mage::helper('mobileassistant')->isEnable()) {
|
7 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
8 |
+
|
9 |
+
$sessionId = '';
|
10 |
+
$limit = '';
|
11 |
+
$offset = '';
|
12 |
+
$new_customers = '';
|
13 |
+
$is_refresh = '';
|
14 |
+
$last_fetch_customer = '';
|
15 |
+
$min_fetch_customer = '';
|
16 |
+
if (isset($post_data['session'])) {
|
17 |
+
$sessionId = $post_data['session'];
|
18 |
+
}
|
19 |
+
|
20 |
+
if (!$sessionId || $sessionId == NULL) {
|
21 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
22 |
+
return false;
|
23 |
+
}
|
24 |
+
|
25 |
+
if (isset($post_data['limit'])) {
|
26 |
+
$limit = $post_data['limit'];
|
27 |
+
}
|
28 |
+
if (isset($post_data['offset'])) {
|
29 |
+
$offset = $post_data['offset'];
|
30 |
+
}
|
31 |
+
if (isset($post_data['last_fetch_customer'])) {
|
32 |
+
$new_customers = $post_data['last_fetch_customer'];
|
33 |
+
}
|
34 |
+
if (isset($post_data['is_refresh'])) {
|
35 |
+
$is_refresh = $post_data['is_refresh'];
|
36 |
+
}
|
37 |
+
$customers = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*')->setOrder('entity_id', 'desc');
|
38 |
+
|
39 |
+
if ($offset != null) {
|
40 |
+
$customers->addAttributeToFilter('entity_id', array('lt' => $offset));
|
41 |
+
}
|
42 |
+
|
43 |
+
if ($is_refresh == 1) {
|
44 |
+
if (isset($post_data['last_fetch_customer'])) {
|
45 |
+
$last_fetch_customer = $post_data['last_fetch_customer'];
|
46 |
+
}
|
47 |
+
if (isset($post_data['min_fetch_customer'])) {
|
48 |
+
$min_fetch_customer = $post_data['min_fetch_customer'];
|
49 |
+
}
|
50 |
+
$last_updated = Mage::helper('mobileassistant')->getActualDate($post_data['last_updated']);
|
51 |
+
$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 . "'");
|
52 |
+
}
|
53 |
+
|
54 |
+
$customers->getSelect()->limit($limit);
|
55 |
+
foreach ($customers as $customer) {
|
56 |
+
$billing_address = Mage::getModel('customer/address')->load($customer->getDefaultBilling());
|
57 |
+
$shipping_address = Mage::getModel('customer/address')->load($customer->getDefaultShipping());
|
58 |
+
|
59 |
+
$customer_list[] = array(
|
60 |
+
'entity_id' => $customer->getEntityId(),
|
61 |
+
'firstname' => $customer->getFirstname(),
|
62 |
+
'lastname' => $customer->getLastname(),
|
63 |
+
'email_id' => $customer->getEmail(),
|
64 |
+
'telephone' => $billing_address->getData('telephone'),
|
65 |
+
'billing_address_id' => $billing_address->getId(),
|
66 |
+
'shipping_address_id' => $shipping_address->getId()
|
67 |
+
);
|
68 |
+
}
|
69 |
+
$updated_time = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
|
70 |
+
$customerListResultArr = array('customerlistdata' => $customer_list, 'updated_time' => $updated_time);
|
71 |
+
$customerListResult = Mage::helper('core')->jsonEncode($customerListResultArr);
|
72 |
+
return Mage::app()->getResponse()->setBody($customerListResult);
|
73 |
+
} else {
|
74 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
75 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
+
public function getCustomerDetailAction() {
|
80 |
+
if (Mage::helper('mobileassistant')->isEnable()) {
|
81 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
82 |
+
|
83 |
+
$sessionId = '';
|
84 |
+
$customer_id = '';
|
85 |
+
if (isset($post_data['session'])) {
|
86 |
+
$sessionId = $post_data['session'];
|
87 |
+
}
|
88 |
+
|
89 |
+
if (!$sessionId || $sessionId == NULL) {
|
90 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
91 |
+
return false;
|
92 |
+
}
|
93 |
+
if (isset($post_data['customer_id'])) {
|
94 |
+
$customer_id = $post_data['customer_id'];
|
95 |
+
}
|
96 |
+
$customerData = Mage::getModel('customer/customer')->load($customer_id);
|
97 |
+
|
98 |
+
|
99 |
+
$basic_detail = array(
|
100 |
+
'entity_id' => $customerData->getEntityId(),
|
101 |
+
'firstname' => $customerData->getFirstname(),
|
102 |
+
'lastname' => $customerData->getLastname(),
|
103 |
+
'email' => $customerData->getEmail(),
|
104 |
+
);
|
105 |
+
|
106 |
+
foreach ($customerData->getAddresses() as $address) {
|
107 |
+
$billing_type = 0;
|
108 |
+
$shipping_type = 0;
|
109 |
+
$billing_country_name = null;
|
110 |
+
|
111 |
+
if ($address->getCountryId()) {
|
112 |
+
$billing_country_name = Mage::getModel('directory/country')->loadByCode($address->getCountryId())->getName();
|
113 |
+
}
|
114 |
+
|
115 |
+
if ($address->getId() == $customerData->getDefaultBilling())
|
116 |
+
$billing_type = 1;
|
117 |
+
|
118 |
+
if ($address->getId() == $customerData->getDefaultShipping())
|
119 |
+
$shipping_type = 1;
|
120 |
+
|
121 |
+
$billing_address_detail[] = array(
|
122 |
+
'firstname' => $address->getFirstname(),
|
123 |
+
'lastname' => $address->getLastname(),
|
124 |
+
'street' => $address->getData('street'),
|
125 |
+
'city' => $address->getCity(),
|
126 |
+
'region_id' => $address->getRegionId() ? $address->getRegionId() : '',
|
127 |
+
'region' => $address->getRegion(),
|
128 |
+
'postcode' => $address->getPostcode(),
|
129 |
+
'country' => $billing_country_name,
|
130 |
+
'country_id' => $address->getCountryId(),
|
131 |
+
'telephone' => $address->getTelephone(),
|
132 |
+
'address_id' => $address->getId(),
|
133 |
+
'billing_type' => $billing_type,
|
134 |
+
'shipping_type' => $shipping_type
|
135 |
+
);
|
136 |
+
}
|
137 |
+
|
138 |
+
$customer_detail = array(
|
139 |
+
'basic_details' => $basic_detail,
|
140 |
+
'address' => $billing_address_detail,
|
141 |
+
);
|
142 |
+
$order_detail = $this->_getCustomerOrderList($customer_id);
|
143 |
+
|
144 |
+
$customerDetailResultArr = array('customerDetails' => $customer_detail, 'customerOrderDetail' => $order_detail);
|
145 |
+
$customerDetailResult = Mage::helper('core')->jsonEncode($customerDetailResultArr);
|
146 |
+
return Mage::app()->getResponse()->setBody($customerDetailResult);
|
147 |
+
}else {
|
148 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
149 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
protected function _getCustomerOrderList($customer_id) {
|
154 |
+
$orderListData = array();
|
155 |
+
$orderCollection = Mage::getResourceModel('sales/order_grid_collection')->addFieldToFilter('customer_id', Array('eq' => $customer_id))->setOrder('entity_id', 'desc');
|
156 |
+
$limit = 5;
|
157 |
+
$orderCollection->getSelect()->limit($limit);
|
158 |
+
|
159 |
+
foreach ($orderCollection as $order) {
|
160 |
+
|
161 |
+
$orderListData[] = array(
|
162 |
+
'entity_id' => $order->getEntityId(),
|
163 |
+
'increment_id' => $order->getIncrementId(),
|
164 |
+
'store_id' => $order->getStoreId(),
|
165 |
+
'customer_name' => $order->getBillingName(),
|
166 |
+
'status' => $order->getStatus(),
|
167 |
+
'order_date' => date('Y-m-d H:i:s', strtotime($order->getCreatedAt())),
|
168 |
+
'grand_total' => Mage::helper('mobileassistant')->getPrice($order->getGrandTotal(), $order->getStoreId(), $order->getOrderCurrencyCode()),
|
169 |
+
'toal_qty' => Mage::getModel('sales/order')->load($order->getEntityId())->getTotalQtyOrdered()
|
170 |
+
);
|
171 |
+
}
|
172 |
+
return $orderListData;
|
173 |
+
}
|
174 |
+
|
175 |
+
public function getFilterCustomerListAction() {
|
176 |
+
if (Mage::helper('mobileassistant')->isEnable()) {
|
177 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
178 |
+
|
179 |
+
$sessionId = '';
|
180 |
+
$search = '';
|
181 |
+
if (isset($post_data['session'])) {
|
182 |
+
$sessionId = $post_data['session'];
|
183 |
+
}
|
184 |
+
|
185 |
+
if (!$sessionId || $sessionId == NULL) {
|
186 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
187 |
+
return false;
|
188 |
+
}
|
189 |
+
|
190 |
+
if (isset($post_data['search_content'])) {
|
191 |
+
$search = $post_data['search_content'];
|
192 |
+
}
|
193 |
+
$customers = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*')->setOrder('entity_id', 'desc');
|
194 |
+
|
195 |
+
if ($search != null) {
|
196 |
+
$customers->addAttributeToFilter(array(
|
197 |
+
array(
|
198 |
+
'attribute' => 'firstname',
|
199 |
+
'like' => '%' . $search . '%'
|
200 |
+
),
|
201 |
+
array(
|
202 |
+
'attribute' => 'lastname',
|
203 |
+
'like' => '%' . $search . '%'
|
204 |
+
),
|
205 |
+
array(
|
206 |
+
'attribute' => 'email',
|
207 |
+
'like' => '%' . $search . '%'
|
208 |
+
)
|
209 |
+
));
|
210 |
+
}
|
211 |
+
|
212 |
+
|
213 |
+
foreach ($customers as $customer) {
|
214 |
+
$billing_address = Mage::getModel('customer/address')->load($customer->getDefaultBilling());
|
215 |
+
$shipping_address = Mage::getModel('customer/address')->load($customer->getDefaultShipping());
|
216 |
+
|
217 |
+
$customer_list[] = array(
|
218 |
+
'entity_id' => $customer->getEntityId(),
|
219 |
+
'firstname' => $customer->getFirstname(),
|
220 |
+
'lastname' => $customer->getLastname(),
|
221 |
+
'email_id' => $customer->getEmail(),
|
222 |
+
'telephone' => $billing_address->getData('telephone'),
|
223 |
+
'billing_address_id' => $billing_address->getId(),
|
224 |
+
'shipping_address_id' => $shipping_address->getId(),
|
225 |
+
);
|
226 |
+
}
|
227 |
+
$customerListResultArr = array('customerlistdata' => $customer_list);
|
228 |
+
$customerListResult = Mage::helper('core')->jsonEncode($customerListResultArr);
|
229 |
+
return Mage::app()->getResponse()->setBody($customerListResult);
|
230 |
+
} else {
|
231 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
232 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
233 |
+
}
|
234 |
+
}
|
235 |
+
|
236 |
+
}
|
app/code/local/Biztech/Mobileassistant/controllers/DashboardController.php
CHANGED
@@ -1,656 +1,664 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
$
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
$
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
$
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
{
|
159 |
-
$
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
$
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
$
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
}
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
$
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
$
|
301 |
-
$
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
$
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
$
|
337 |
-
$
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
}
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
$
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
$
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
$
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
if(
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
$
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
$
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
$
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Biztech_Mobileassistant_DashboardController extends Mage_Core_Controller_Front_Action {
|
4 |
+
|
5 |
+
public function dashboardAction() {
|
6 |
+
if (Mage::helper('mobileassistant')->isEnable()) {
|
7 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
8 |
+
|
9 |
+
$sessionId = '';
|
10 |
+
$storeId = '';
|
11 |
+
$type_id = '';
|
12 |
+
if (isset($post_data['session'])) {
|
13 |
+
$sessionId = $post_data['session'];
|
14 |
+
}
|
15 |
+
|
16 |
+
if (!$sessionId || $sessionId == NULL) {
|
17 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
18 |
+
return false;
|
19 |
+
}
|
20 |
+
|
21 |
+
if (isset($post_data['storeid'])) {
|
22 |
+
$storeId = $post_data['storeid'];
|
23 |
+
}
|
24 |
+
if (isset($post_data['days_for_dashboard'])) {
|
25 |
+
$type_id = $post_data['days_for_dashboard'];
|
26 |
+
}
|
27 |
+
|
28 |
+
$now = Mage::getModel('core/date')->timestamp(time());
|
29 |
+
$end_date = date('Y-m-d 23:59:59', $now);
|
30 |
+
$start_date = '';
|
31 |
+
$orderCollection = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id', Array('eq' => $storeId))->addFieldToFilter('status', Array('eq' => 'complete'))->setOrder('entity_id', 'desc');
|
32 |
+
if ($type_id == 7) {
|
33 |
+
$start_date = date('Y-m-d 00:00:00', strtotime('-6 days'));
|
34 |
+
} elseif ($type_id == 30) {
|
35 |
+
$start_date = date('Y-m-d 00:00:00', strtotime('-29 days'));
|
36 |
+
} elseif ($type_id == 90) {
|
37 |
+
$start_date = date('Y-m-d 00:00:00', strtotime('-89 days'));
|
38 |
+
} else if ($type_id == 24) {
|
39 |
+
$end_date = date("Y-m-d H:m:s");
|
40 |
+
$start_date = date("Y-m-d H:m:s", strtotime('-24 hours', time()));
|
41 |
+
$timezoneLocal = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
|
42 |
+
|
43 |
+
list ($dateStart, $dateEnd) = Mage::getResourceModel('reports/order_collection')
|
44 |
+
->getDateRange('24h', '', '', true);
|
45 |
+
|
46 |
+
$dateStart->setTimezone($timezoneLocal);
|
47 |
+
$dateEnd->setTimezone($timezoneLocal);
|
48 |
+
|
49 |
+
$dates = array();
|
50 |
+
|
51 |
+
while ($dateStart->compare($dateEnd) < 0) {
|
52 |
+
$d = $dateStart->toString('yyyy-MM-dd HH:mm:ss');
|
53 |
+
$dateStart->addHour(1);
|
54 |
+
$dates[] = $d;
|
55 |
+
}
|
56 |
+
|
57 |
+
$start_date = $dates[0];
|
58 |
+
$end_date = $dates[count($dates) - 1];
|
59 |
+
|
60 |
+
$orderCollection->addAttributeToFilter('created_at', array('from' => $start_date, 'to' => $end_date));
|
61 |
+
$total_count = count($orderCollection);
|
62 |
+
}
|
63 |
+
|
64 |
+
if ($type_id != 'year') {
|
65 |
+
if ($type_id == 'month') {
|
66 |
+
$end_date = date("Y-m-d H:m:s");
|
67 |
+
$start_date = date('Y-m-01 H:m:s');
|
68 |
+
}
|
69 |
+
|
70 |
+
if ($type_id != 24) {
|
71 |
+
$orderCollection->addAttributeToFilter('created_at', array('from' => $start_date, 'to' => $end_date));
|
72 |
+
$total_count = count($orderCollection);
|
73 |
+
$dates = $this->getDatesFromRange($start_date, $end_date);
|
74 |
+
}
|
75 |
+
$count = 0;
|
76 |
+
foreach ($dates as $date) {
|
77 |
+
$orderCollectionByDate = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id', Array('eq' => $storeId))->addFieldToFilter('status', Array('eq' => 'complete'))->setOrder('entity_id', 'desc');
|
78 |
+
|
79 |
+
if ($type_id == 24) {
|
80 |
+
if ($count == 23) {
|
81 |
+
continue;
|
82 |
+
}
|
83 |
+
$dateStart = $dates[$count];
|
84 |
+
$dateEnd = $dates[$count + 1];
|
85 |
+
} else {
|
86 |
+
|
87 |
+
$dateStart = date('Y-m-d 00:00:00', strtotime($date));
|
88 |
+
$dateEnd = date('Y-m-d 23:59:59', strtotime($date));
|
89 |
+
}
|
90 |
+
$orderByDate = $orderCollectionByDate->addAttributeToFilter('created_at', array('from' => $dateStart, 'to' => $dateEnd));
|
91 |
+
$orderByDate->getSelect()->columns('SUM(grand_total) AS grand_total_sum');
|
92 |
+
$orderByDate->getSelect()->group(array('store_id'));
|
93 |
+
$orderdata = $orderByDate->getData();
|
94 |
+
if (count($orderByDate) == 0) {
|
95 |
+
if ($type_id == 24) {
|
96 |
+
$orderTotalByDate[date("Y-m-d H:i", strtotime($date))] = 0;
|
97 |
+
} else if ($type_id == 'month') {
|
98 |
+
$orderTotalByDate[date('d', strtotime($date))] = 0;
|
99 |
+
} else {
|
100 |
+
$orderTotalByDate[$date] = 0;
|
101 |
+
}
|
102 |
+
} else {
|
103 |
+
if ($type_id == 24) {
|
104 |
+
$ordersByDate[date("Y-m-d H:i", strtotime($date))][] = $orderdata[0]['grand_total_sum'];
|
105 |
+
$orderTotalByDate[date("Y-m-d H:i", strtotime($date))] = array_sum($ordersByDate[date("Y-m-d H:i", strtotime($date))]);
|
106 |
+
} else if ($type_id == 'month') {
|
107 |
+
$ordersByDate[date('d', strtotime($date))][] = $orderdata[0]['grand_total_sum'];
|
108 |
+
$orderTotalByDate[date('d', strtotime($date))] = array_sum($ordersByDate[date('d', strtotime($date))]);
|
109 |
+
} else {
|
110 |
+
$ordersByDate[$date][] = $orderdata[0]['grand_total_sum'];
|
111 |
+
$orderTotalByDate[$date] = array_sum($ordersByDate[$date]);
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
$count++;
|
116 |
+
}
|
117 |
+
} else {
|
118 |
+
$end_date = date('Y-m-d');
|
119 |
+
$start_date = date('Y-01-01');
|
120 |
+
$orderCollection->addAttributeToFilter('created_at', array('from' => $start_date, 'to' => $end_date));
|
121 |
+
$total_count = count($orderCollection);
|
122 |
+
$months = $this->get_months($start_date, $end_date);
|
123 |
+
$current_year = date("Y");
|
124 |
+
foreach ($months as $month) {
|
125 |
+
$first_day = $this->firstDay($month, $current_year);
|
126 |
+
$ordersByDate = array();
|
127 |
+
if ($month == date('F'))
|
128 |
+
$last_day = date('Y-m-d');
|
129 |
+
else
|
130 |
+
$last_day = $this->lastday($month, $current_year);
|
131 |
+
|
132 |
+
$dates = $this->getDatesFromRange($first_day, $last_day);
|
133 |
+
|
134 |
+
foreach ($dates as $date) {
|
135 |
+
$orderCollectionByDate = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id', Array('eq' => $storeId))->addFieldToFilter('status', Array('eq' => 'complete'))->setOrder('entity_id', 'desc');
|
136 |
+
$dateStart = date('Y-m-d 00:00:00', strtotime($date));
|
137 |
+
$dateEnd = date('Y-m-d 23:59:59', strtotime($date));
|
138 |
+
$orderByDate = $orderCollectionByDate->addAttributeToFilter('created_at', array('from' => $dateStart, 'to' => $dateEnd));
|
139 |
+
$orderByDate->getSelect()->columns('SUM(grand_total) AS grand_total_sum');
|
140 |
+
$orderByDate->getSelect()->group(array('store_id'));
|
141 |
+
$orderdata = $orderByDate->getData();
|
142 |
+
$ordersByDate[] = $orderdata[0]['grand_total_sum'];
|
143 |
+
}
|
144 |
+
|
145 |
+
$orderTotalByDate[$month] = array_sum($ordersByDate);
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
$baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
|
150 |
+
|
151 |
+
$orderGrandTotal = strip_tags(Mage::app()->getLocale()->currency($baseCurrencyCode)->toCurrency(array_sum($orderTotalByDate)));
|
152 |
+
$lifeTimeSales = strip_tags(Mage::app()->getLocale()->currency($baseCurrencyCode)->toCurrency(round(Mage::getResourceModel('reports/order_collection')->addFieldToFilter('store_id', $storeId)->calculateSales()->load()->getFirstItem()->getLifetime(), 2)));
|
153 |
+
$averageOrder = strip_tags(Mage::app()->getLocale()->currency($baseCurrencyCode)->toCurrency(round(Mage::getResourceModel('reports/order_collection')->addFieldToFilter('store_id', $storeId)->calculateSales()->load()->getFirstItem()->getAverage(), 2)));
|
154 |
+
|
155 |
+
$orderTotalResultArr = array('dashboard_result' => array('ordertotalbydate' => $orderTotalByDate, 'ordergrandtotal' => $orderGrandTotal, 'totalordercount' => $total_count, 'lifetimesales' => $lifeTimeSales, 'averageorder' => $averageOrder));
|
156 |
+
$orderDashboardResult = Mage::helper('core')->jsonEncode($orderTotalResultArr);
|
157 |
+
return Mage::app()->getResponse()->setBody($orderDashboardResult);
|
158 |
+
} else {
|
159 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
160 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
public function getDatesFromRange($start_date, $end_date) {
|
165 |
+
$date_from = strtotime(date('Y-m-d', strtotime($start_date)));
|
166 |
+
$date_to = strtotime(date('Y-m-d', strtotime($end_date)));
|
167 |
+
|
168 |
+
for ($i = $date_from; $i <= $date_to; $i+=86400) {
|
169 |
+
$dates[] = date("Y-m-d", $i);
|
170 |
+
}
|
171 |
+
return $dates;
|
172 |
+
}
|
173 |
+
|
174 |
+
public function getNewestCustomerAction() {
|
175 |
+
if (Mage::helper('mobileassistant')->isEnable()) {
|
176 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
177 |
+
|
178 |
+
$sessionId = '';
|
179 |
+
$storeId = '';
|
180 |
+
if (isset($post_data['session'])) {
|
181 |
+
$sessionId = $post_data['session'];
|
182 |
+
}
|
183 |
+
|
184 |
+
if (!$sessionId || $sessionId == NULL) {
|
185 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
186 |
+
return false;
|
187 |
+
}
|
188 |
+
|
189 |
+
if (isset($post_data['storeid'])) {
|
190 |
+
$storeId = $post_data['storeid'];
|
191 |
+
}
|
192 |
+
$baseCurrencyCode = (string) Mage::app()->getStore($storeId)->getBaseCurrencyCode();
|
193 |
+
|
194 |
+
$collection = Mage::getResourceModel('reports/customer_collection')->addCustomerName();
|
195 |
+
$storeFilter = 0;
|
196 |
+
if ($storeId) {
|
197 |
+
$collection->addAttributeToFilter('store_id', $storeId);
|
198 |
+
$storeFilter = 1;
|
199 |
+
}
|
200 |
+
$collection->addOrdersStatistics($storeFilter)->orderByCustomerRegistration();
|
201 |
+
|
202 |
+
foreach ($collection as $_collection) {
|
203 |
+
$newestCustomer[] = array(
|
204 |
+
'name' => $_collection->getName(),
|
205 |
+
'email' => $_collection->getEmail(),
|
206 |
+
'orders_count' => $_collection->getOrdersCount(),
|
207 |
+
'average_order_amount' => Mage::app()->getLocale()->currency($baseCurrencyCode)->toCurrency(Mage::helper('mobileassistant')->getPriceFormat($_collection->getOrdersAvgAmount())),
|
208 |
+
'total_order_amount' => Mage::app()->getLocale()->currency($baseCurrencyCode)->toCurrency(Mage::helper('mobileassistant')->getPriceFormat($_collection->getOrdersSumAmount()))
|
209 |
+
);
|
210 |
+
}
|
211 |
+
|
212 |
+
$NewestCustomerResult = Mage::helper('core')->jsonEncode($newestCustomer);
|
213 |
+
return Mage::app()->getResponse()->setBody($NewestCustomerResult);
|
214 |
+
} else {
|
215 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
216 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
220 |
+
function get_months($date1, $date2) {
|
221 |
+
$time1 = strtotime($date1);
|
222 |
+
$time2 = strtotime($date2);
|
223 |
+
$my = date('mY', $time2);
|
224 |
+
$months = array();
|
225 |
+
$f = '';
|
226 |
+
|
227 |
+
while ($time1 < $time2) {
|
228 |
+
$time1 = strtotime((date('Y-m-d', $time1) . ' +15days'));
|
229 |
+
|
230 |
+
if (date('m', $time1) != $f) {
|
231 |
+
$f = date('m', $time1);
|
232 |
+
|
233 |
+
if (date('mY', $time1) != $my && ($time1 < $time2))
|
234 |
+
$months[] = date('m', $time1);
|
235 |
+
}
|
236 |
+
}
|
237 |
+
|
238 |
+
$months[] = date('m', $time2);
|
239 |
+
return $months;
|
240 |
+
}
|
241 |
+
|
242 |
+
function lastday($month = '', $year = '') {
|
243 |
+
if (empty($month)) {
|
244 |
+
$month = date('m');
|
245 |
+
}
|
246 |
+
if (empty($year)) {
|
247 |
+
$year = date('Y');
|
248 |
+
}
|
249 |
+
$result = strtotime("{$year}-{$month}-01");
|
250 |
+
$result = strtotime('-1 day', strtotime('+1 month', $result));
|
251 |
+
return date('Y-m-d', $result);
|
252 |
+
}
|
253 |
+
|
254 |
+
function firstDay($month = '', $year = '') {
|
255 |
+
if (empty($month)) {
|
256 |
+
$month = date('m');
|
257 |
+
}
|
258 |
+
if (empty($year)) {
|
259 |
+
$year = date('Y');
|
260 |
+
}
|
261 |
+
$result = strtotime("{$year}-{$month}-01");
|
262 |
+
return date('Y-m-d', $result);
|
263 |
+
}
|
264 |
+
|
265 |
+
protected function getorderetails($storeId, $type_id, $tab = null, $source = null, $limit = null) {
|
266 |
+
$orderTotalByDate = array();
|
267 |
+
$now = Mage::getModel('core/date')->timestamp(time());
|
268 |
+
$end_date = date('Y-m-d 23:59:59', $now);
|
269 |
+
$start_date = '';
|
270 |
+
$orderListData = array();
|
271 |
+
|
272 |
+
if ($source == 'widget') {
|
273 |
+
$orderCollection = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id', Array('eq' => $storeId))->setOrder('entity_id', 'desc');
|
274 |
+
} else {
|
275 |
+
$orderCollection = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id', Array('eq' => $storeId))->addFieldToFilter('status', Array('eq' => 'complete'))->setOrder('entity_id', 'desc');
|
276 |
+
}
|
277 |
+
|
278 |
+
|
279 |
+
|
280 |
+
if ($type_id == 7) {
|
281 |
+
$start_date = date('Y-m-d 00:00:00', strtotime('-6 days'));
|
282 |
+
} elseif ($type_id == 30) {
|
283 |
+
$start_date = date('Y-m-d 00:00:00', strtotime('-29 days'));
|
284 |
+
} elseif ($type_id == 90) {
|
285 |
+
$start_date = date('Y-m-d 00:00:00', strtotime('-89 days'));
|
286 |
+
} else if ($type_id == 24) {
|
287 |
+
$end_date = date("Y-m-d H:m:s");
|
288 |
+
$start_date = date("Y-m-d H:m:s", strtotime('-24 hours', time()));
|
289 |
+
$timezoneLocal = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
|
290 |
+
|
291 |
+
list ($dateStart, $dateEnd) = Mage::getResourceModel('reports/order_collection')
|
292 |
+
->getDateRange('24h', '', '', true);
|
293 |
+
|
294 |
+
$dateStart->setTimezone($timezoneLocal);
|
295 |
+
$dateEnd->setTimezone($timezoneLocal);
|
296 |
+
|
297 |
+
$dates = array();
|
298 |
+
|
299 |
+
while ($dateStart->compare($dateEnd) < 0) {
|
300 |
+
$d = $dateStart->toString('yyyy-MM-dd HH:mm:ss');
|
301 |
+
$dateStart->addHour(1);
|
302 |
+
$dates[] = $d;
|
303 |
+
}
|
304 |
+
|
305 |
+
$start_date = $dates[0];
|
306 |
+
$end_date = $dates[count($dates) - 1];
|
307 |
+
|
308 |
+
$orderCollection->addAttributeToFilter('created_at', array('from' => $start_date, 'to' => $end_date));
|
309 |
+
$total_count = count($orderCollection);
|
310 |
+
}
|
311 |
+
|
312 |
+
if ($type_id != 'year') {
|
313 |
+
if ($type_id == 'month') {
|
314 |
+
$end_date = date("Y-m-d H:m:s");
|
315 |
+
$start_date = date('Y-m-01 H:m:s');
|
316 |
+
}
|
317 |
+
|
318 |
+
if ($type_id != 24) {
|
319 |
+
$orderCollection->addAttributeToFilter('created_at', array('from' => $start_date, 'to' => $end_date));
|
320 |
+
$total_count = count($orderCollection);
|
321 |
+
$dates = $this->getDatesFromRange($start_date, $end_date);
|
322 |
+
}
|
323 |
+
$count = 0;
|
324 |
+
foreach ($dates as $date) {
|
325 |
+
if ($source == 'widget') {
|
326 |
+
$orderCollectionByDate = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id', Array('eq' => $storeId))->setOrder('entity_id', 'desc');
|
327 |
+
} else {
|
328 |
+
$orderCollectionByDate = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id', Array('eq' => $storeId))->addFieldToFilter('status', Array('eq' => 'complete'))->setOrder('entity_id', 'desc');
|
329 |
+
}
|
330 |
+
|
331 |
+
|
332 |
+
if ($type_id == 24) {
|
333 |
+
if ($count == 23) {
|
334 |
+
continue;
|
335 |
+
}
|
336 |
+
$dateStart = $dates[$count];
|
337 |
+
$dateEnd = $dates[$count + 1];
|
338 |
+
} else {
|
339 |
+
|
340 |
+
$dateStart = date('Y-m-d 00:00:00', strtotime($date));
|
341 |
+
$dateEnd = date('Y-m-d 23:59:59', strtotime($date));
|
342 |
+
}
|
343 |
+
$orderByDate = $orderCollectionByDate->addAttributeToFilter('created_at', array('from' => $dateStart, 'to' => $dateEnd));
|
344 |
+
$orderByDate->getSelect()->columns('SUM(grand_total) AS grand_total_sum');
|
345 |
+
$orderByDate->getSelect()->group(array('store_id'));
|
346 |
+
$orderdata = $orderByDate->getData();
|
347 |
+
if (count($orderByDate) == 0) {
|
348 |
+
if ($type_id == 24) {
|
349 |
+
$orderTotalByDate[date("Y-m-d H:i", strtotime($date))] = 0;
|
350 |
+
} else if ($type_id == 'month') {
|
351 |
+
$orderTotalByDate[date('d', strtotime($date))] = 0;
|
352 |
+
} else {
|
353 |
+
$orderTotalByDate[$date] = 0;
|
354 |
+
}
|
355 |
+
} else {
|
356 |
+
if ($type_id == 24) {
|
357 |
+
$ordersByDate[date("Y-m-d H:i", strtotime($date))][] = $orderdata[0]['grand_total_sum'];
|
358 |
+
$orderTotalByDate[date("Y-m-d H:i", strtotime($date))] = array_sum($ordersByDate[date("Y-m-d H:i", strtotime($date))]);
|
359 |
+
} else if ($type_id == 'month') {
|
360 |
+
$ordersByDate[date('d', strtotime($date))][] = $orderdata[0]['grand_total_sum'];
|
361 |
+
$orderTotalByDate[date('d', strtotime($date))] = array_sum($ordersByDate[date('d', strtotime($date))]);
|
362 |
+
} else {
|
363 |
+
$ordersByDate[$date][] = $orderdata[0]['grand_total_sum'];
|
364 |
+
$orderTotalByDate[$date] = array_sum($ordersByDate[$date]);
|
365 |
+
}
|
366 |
+
}
|
367 |
+
|
368 |
+
$count++;
|
369 |
+
}
|
370 |
+
} else {
|
371 |
+
$end_date = date('Y-m-d');
|
372 |
+
$start_date = date('Y-01-01');
|
373 |
+
$orderCollection->addAttributeToFilter('created_at', array('from' => $start_date, 'to' => $end_date));
|
374 |
+
$total_count = count($orderCollection);
|
375 |
+
$months = $this->get_months($start_date, $end_date);
|
376 |
+
$current_year = date("Y");
|
377 |
+
foreach ($months as $month) {
|
378 |
+
$first_day = $this->firstDay($month, $current_year);
|
379 |
+
$ordersByDate = array();
|
380 |
+
if ($month == date('F'))
|
381 |
+
$last_day = date('Y-m-d');
|
382 |
+
else
|
383 |
+
$last_day = $this->lastday($month, $current_year);
|
384 |
+
|
385 |
+
$dates = $this->getDatesFromRange($first_day, $last_day);
|
386 |
+
|
387 |
+
foreach ($dates as $date) {
|
388 |
+
|
389 |
+
if ($source == 'widget') {
|
390 |
+
$orderCollectionByDate = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id', Array('eq' => $storeId))->setOrder('entity_id', 'desc');
|
391 |
+
} else {
|
392 |
+
$orderCollectionByDate = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id', Array('eq' => $storeId))->addFieldToFilter('status', Array('eq' => 'complete'))->setOrder('entity_id', 'desc');
|
393 |
+
}
|
394 |
+
$dateStart = date('Y-m-d 00:00:00', strtotime($date));
|
395 |
+
$dateEnd = date('Y-m-d 23:59:59', strtotime($date));
|
396 |
+
$orderByDate = $orderCollectionByDate->addAttributeToFilter('created_at', array('from' => $dateStart, 'to' => $dateEnd));
|
397 |
+
$orderByDate->getSelect()->columns('SUM(grand_total) AS grand_total_sum');
|
398 |
+
$orderByDate->getSelect()->group(array('store_id'));
|
399 |
+
$orderdata = $orderByDate->getData();
|
400 |
+
$ordersByDate[] = $orderdata[0]['grand_total_sum'];
|
401 |
+
}
|
402 |
+
|
403 |
+
$orderTotalByDate[$month] = array_sum($ordersByDate);
|
404 |
+
}
|
405 |
+
}
|
406 |
+
|
407 |
+
|
408 |
+
$result = array('ordertotalbydate' => $orderTotalByDate, 'ordertotalcount' => $total_count);
|
409 |
+
|
410 |
+
$orderCollection->getSelect()->limit($limit);
|
411 |
+
|
412 |
+
if ($tab == 'order') {
|
413 |
+
|
414 |
+
foreach ($orderCollection->getData() as $_order) {
|
415 |
+
$grand_total = Mage::helper('mobileassistant')->getPrice($_order['grand_total'], $_order['store_id'], $_order['order_currency_code']);
|
416 |
+
|
417 |
+
|
418 |
+
$orderListData[] = array(
|
419 |
+
'entity_id' => $_order['entity_id'],
|
420 |
+
'increment_id' => $_order['increment_id'],
|
421 |
+
'store_id' => $_order['store_id'],
|
422 |
+
'customer_name' => $_order['customer_firstname'] . ' ' . $_order['customer_lastname'],
|
423 |
+
'status' => $_order['status'],
|
424 |
+
'order_date' => Mage::helper('mobileassistant')->getActualOrderDate($_order['create_at']),
|
425 |
+
'grand_total' => $grand_total,
|
426 |
+
'toal_qty' => Mage::getModel('sales/order')->load($_order['entity_id'])->getTotalQtyOrdered(),
|
427 |
+
'total_items' => $_order['total_item_count']
|
428 |
+
);
|
429 |
+
}
|
430 |
+
|
431 |
+
$result['ordercollection'] = $orderListData;
|
432 |
+
}
|
433 |
+
|
434 |
+
return $result;
|
435 |
+
}
|
436 |
+
|
437 |
+
protected function getcustomerdetails($storeId, $type_id, $limit = null, $tab = null) {
|
438 |
+
$collection = Mage::getResourceModel('reports/customer_collection')->addCustomerName();
|
439 |
+
$storeFilter = 0;
|
440 |
+
if ($storeId) {
|
441 |
+
$collection->addAttributeToFilter('store_id', $storeId);
|
442 |
+
$storeFilter = 1;
|
443 |
+
}
|
444 |
+
$collection->addOrdersStatistics($storeFilter)->orderByCustomerRegistration();
|
445 |
+
$total = $collection->getSize();
|
446 |
+
|
447 |
+
if (isset($type_id) && $type_id != null) {
|
448 |
+
if ($type_id == 7) {
|
449 |
+
$start_date = date('Y-m-d 00:00:00', strtotime('-6 days'));
|
450 |
+
} elseif ($type_id == 30) {
|
451 |
+
$start_date = date('Y-m-d 00:00:00', strtotime('-29 days'));
|
452 |
+
} elseif ($type_id == 90) {
|
453 |
+
$start_date = date('Y-m-d 00:00:00', strtotime('-89 days'));
|
454 |
+
} else if ($type_id == 24) {
|
455 |
+
$end_date = date("Y-m-d H:m:s");
|
456 |
+
$start_date = date("Y-m-d H:m:s", strtotime('-24 hours', time()));
|
457 |
+
$timezoneLocal = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
|
458 |
+
|
459 |
+
list ($dateStart, $dateEnd) = Mage::getResourceModel('reports/order_collection')
|
460 |
+
->getDateRange('24h', '', '', true);
|
461 |
+
|
462 |
+
$dateStart->setTimezone($timezoneLocal);
|
463 |
+
$dateEnd->setTimezone($timezoneLocal);
|
464 |
+
|
465 |
+
$dates = array();
|
466 |
+
|
467 |
+
while ($dateStart->compare($dateEnd) < 0) {
|
468 |
+
$d = $dateStart->toString('yyyy-MM-dd HH:mm:ss');
|
469 |
+
$dateStart->addHour(1);
|
470 |
+
$dates[] = $d;
|
471 |
+
}
|
472 |
+
|
473 |
+
$start_date = $dates[0];
|
474 |
+
$end_date = $dates[count($dates) - 1];
|
475 |
+
|
476 |
+
$collection->addAttributeToFilter('created_at', array('from' => $start_date, 'to' => $end_date));
|
477 |
+
$total_count = count($collection);
|
478 |
+
}
|
479 |
+
|
480 |
+
if ($type_id != 'year') {
|
481 |
+
if ($type_id == 'month') {
|
482 |
+
$end_date = date("Y-m-d H:m:s");
|
483 |
+
$start_date = date('Y-m-01 H:m:s');
|
484 |
+
}
|
485 |
+
|
486 |
+
if ($type_id != 24) {
|
487 |
+
$collection->addAttributeToFilter('created_at', array('from' => $start_date, 'to' => $end_date));
|
488 |
+
$total_count = count($collection);
|
489 |
+
$dates = $this->getDatesFromRange($start_date, $end_date);
|
490 |
+
}
|
491 |
+
} else {
|
492 |
+
$end_date = date('Y-m-d');
|
493 |
+
$start_date = date('Y-01-01');
|
494 |
+
$collection->addAttributeToFilter('created_at', array('from' => $start_date, 'to' => $end_date));
|
495 |
+
$total_count = count($collection);
|
496 |
+
}
|
497 |
+
}
|
498 |
+
if ($tab == 'customer' && isset($limit)) {
|
499 |
+
$collection->clear();
|
500 |
+
$collection->getSelect()->limit($limit);
|
501 |
+
}
|
502 |
+
$resultWidget = array('customercollection' => $collection, 'customertotal' => $total_count);
|
503 |
+
return $resultWidget;
|
504 |
+
}
|
505 |
+
|
506 |
+
protected function getlowstockproducts($tab, $storeId, $limit) {
|
507 |
+
$product_list = array();
|
508 |
+
|
509 |
+
$products = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($storeId)->setOrder('entity_id', 'desc')
|
510 |
+
->joinField(
|
511 |
+
'is_in_stock', 'cataloginventory/stock_item', 'is_in_stock', 'product_id=entity_id', '{{table}}.stock_id=1', 'left'
|
512 |
+
)->addAttributeToFilter('is_in_stock', array('eq' => 0));
|
513 |
+
|
514 |
+
$productResultArr['totalproducts'] = $products->getSize();
|
515 |
+
|
516 |
+
$products->getSelect()->limit($limit);
|
517 |
+
if ($tab == 'product') {
|
518 |
+
foreach ($products as $product) {
|
519 |
+
$product_data = Mage::getModel('catalog/product')->load($product->getId());
|
520 |
+
$status = $product_data->getStatus();
|
521 |
+
$qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product_data)->getQty();
|
522 |
+
if ($status == 1) {
|
523 |
+
$status = 'Enabled';
|
524 |
+
} else {
|
525 |
+
$status = 'Disabled';
|
526 |
+
}
|
527 |
+
$product_list[] = array(
|
528 |
+
'id' => $product->getId(),
|
529 |
+
'sku' => $product_data->getSku(),
|
530 |
+
'name' => $product_data->getName(),
|
531 |
+
'status' => $status,
|
532 |
+
'qty' => $qty,
|
533 |
+
'price' => Mage::helper('mobileassistant')->getPrice($product_data->getPrice(), $storeId, Mage::app()->getStore()->getCurrentCurrencyCode()),
|
534 |
+
'image' => ($product_data->getImage()) ? Mage::helper('catalog/image')->init($product, 'image', $product_data->getImage())->resize(300, 330)->keepAspectRatio(true)->constrainOnly(true)->__toString() : 'N/A',
|
535 |
+
'type' => $product->getTypeId()
|
536 |
+
);
|
537 |
+
}
|
538 |
+
}
|
539 |
+
|
540 |
+
$productResultArr['productlistdata'] = $product_list;
|
541 |
+
|
542 |
+
return $productResultArr;
|
543 |
+
}
|
544 |
+
|
545 |
+
public function getwidgetdetailsAction() {
|
546 |
+
if (Mage::helper('mobileassistant')->isEnable()) {
|
547 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
548 |
+
|
549 |
+
$sessionId = '';
|
550 |
+
$storeId = '';
|
551 |
+
$type_id = '';
|
552 |
+
$tab = '';
|
553 |
+
$limit = '';
|
554 |
+
$newestCustomer = array();
|
555 |
+
if (isset($post_data['session'])) {
|
556 |
+
$sessionId = $post_data['session'];
|
557 |
+
}
|
558 |
+
if (!$sessionId || $sessionId == NULL) {
|
559 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
560 |
+
return false;
|
561 |
+
}
|
562 |
+
|
563 |
+
if (isset($post_data['storeid'])) {
|
564 |
+
$storeId = $post_data['storeid'];
|
565 |
+
}
|
566 |
+
if (isset($post_data['days_for_dashboard'])) {
|
567 |
+
$type_id = $post_data['days_for_dashboard'];
|
568 |
+
}
|
569 |
+
if (isset($post_data['tab'])) {
|
570 |
+
$tab = $post_data['tab'];
|
571 |
+
}
|
572 |
+
if (isset($post_data['limit'])) {
|
573 |
+
$limit = $post_data['limit'];
|
574 |
+
}
|
575 |
+
$source = 'widget';
|
576 |
+
|
577 |
+
$baseCurrencyCode = (string) Mage::app()->getStore($storeId)->getBaseCurrencyCode();
|
578 |
+
|
579 |
+
/* order detail */
|
580 |
+
$orderDetails = $this->getorderetails($storeId, $type_id, $tab, $source, $limit);
|
581 |
+
$orderTotalByDate = $orderDetails['ordertotalbydate'];
|
582 |
+
$orderGrandTotal = strip_tags(Mage::app()->getLocale()->currency($baseCurrencyCode)->toCurrency(array_sum($orderTotalByDate)));
|
583 |
+
|
584 |
+
|
585 |
+
$widgetResultArr['widget_order'] = array('ordergrandtotal' => $orderGrandTotal, 'totalordercount' => $orderDetails['ordertotalcount'], 'ordercollection' => $orderDetails['ordercollection']);
|
586 |
+
|
587 |
+
/* customer detail */
|
588 |
+
$customerDetails = $this->getcustomerdetails($storeId, $type_id, $limit, $tab);
|
589 |
+
$customertotal = $customerDetails['customertotal'];
|
590 |
+
|
591 |
+
if ($tab == 'customer') {
|
592 |
+
|
593 |
+
$collection = $customerDetails['customercollection'];
|
594 |
+
|
595 |
+
foreach ($collection as $_collection) {
|
596 |
+
$newestCustomer[] = array(
|
597 |
+
'entity_id' => $_collection->getEntityId(),
|
598 |
+
'name' => $_collection->getName(),
|
599 |
+
'email' => $_collection->getEmail(),
|
600 |
+
);
|
601 |
+
}
|
602 |
+
}
|
603 |
+
|
604 |
+
$widgetResultArr['widget_customer'] = array('totalcustomer' => $customertotal, 'customers_detail' => $newestCustomer);
|
605 |
+
|
606 |
+
/* products detail */
|
607 |
+
$productDetails = $this->getlowstockproducts($tab, $storeId, $limit);
|
608 |
+
$totalProduct = $productDetails['totalproducts'];
|
609 |
+
$productdata = $productDetails['productlistdata'];
|
610 |
+
|
611 |
+
$widgetResultArr['widget_product'] = array('totalproduct' => $totalProduct, 'product_detail' => $productdata);
|
612 |
+
|
613 |
+
$widgetResult = Mage::helper('core')->jsonEncode($widgetResultArr);
|
614 |
+
return Mage::app()->getResponse()->setBody($widgetResult);
|
615 |
+
} else {
|
616 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
617 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
618 |
+
}
|
619 |
+
}
|
620 |
+
|
621 |
+
public function sendfeedbackAction() {
|
622 |
+
if (Mage::helper('mobileassistant')->isEnable()) {
|
623 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
624 |
+
|
625 |
+
$sessionId = '';
|
626 |
+
if (isset($post_data['session'])) {
|
627 |
+
$sessionId = $post_data['session'];
|
628 |
+
}
|
629 |
+
if (!$sessionId || $sessionId == NULL) {
|
630 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
631 |
+
return false;
|
632 |
+
}
|
633 |
+
|
634 |
+
$to = "support@biztechconsultancy.com";
|
635 |
+
$subject = "Feedback For MobileAssistant";
|
636 |
+
|
637 |
+
$message = "<div>
|
638 |
+
<p>Hi there. This is just test email.</p>
|
639 |
+
<p>Below is ratings given by user: " . $post_data['nickname'] . "</p>
|
640 |
+
<p>Ratings: " . $post_data['rating'] . "</p>" . " \r\n" . "
|
641 |
+
<p>Comments: " . $post_data['comment'] . "</p>" . " \r\n" . "
|
642 |
+
<p>Please find application link:</p>" . " \r\n" . "
|
643 |
+
<a href='" . Mage::getBaseUrl() . "'>Click here</a>" . " \r\n" . "
|
644 |
+
</div>";
|
645 |
+
|
646 |
+
$header = "From:" . Mage::getStoreConfig('trans_email/ident_general/email') . " \r\n";
|
647 |
+
$header .= "MIME-Version: 1.0\r\n";
|
648 |
+
$header .= "Content-type: text/html\r\n";
|
649 |
+
$retval = mail($to, $subject, $message, $header);
|
650 |
+
if ($retval == true) {
|
651 |
+
$result = array('status' => true, 'message' => 'Message sent successfully');
|
652 |
+
} else {
|
653 |
+
$result = array('status' => false, 'message' => 'Message could not be sent');
|
654 |
+
}
|
655 |
+
|
656 |
+
$NewestCustomerResult = Mage::helper('core')->jsonEncode($result);
|
657 |
+
return Mage::app()->getResponse()->setBody($NewestCustomerResult);
|
658 |
+
} else {
|
659 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
660 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
661 |
+
}
|
662 |
+
}
|
663 |
+
|
664 |
+
}
|
app/code/local/Biztech/Mobileassistant/controllers/OrderController.php
CHANGED
@@ -1,307 +1,359 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
$
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
$
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
$
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
$
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
}
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
$
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
'
|
159 |
-
'
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
'
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
$
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
$
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
{
|
302 |
-
|
303 |
-
$
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Biztech_Mobileassistant_OrderController extends Mage_Core_Controller_Front_Action {
|
4 |
+
|
5 |
+
public function getOrderListAction() {
|
6 |
+
if (Mage::helper('mobileassistant')->isEnable()) {
|
7 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
8 |
+
|
9 |
+
$sessionId = '';
|
10 |
+
$limit = '';
|
11 |
+
$storeId = '';
|
12 |
+
$offset = '';
|
13 |
+
$is_refresh = '';
|
14 |
+
$source = '';
|
15 |
+
$last_fetch_order = '';
|
16 |
+
$min_fetch_order = '';
|
17 |
+
$last_updated = '';
|
18 |
+
if (isset($post_data['session'])) {
|
19 |
+
$sessionId = $post_data['session'];
|
20 |
+
}
|
21 |
+
|
22 |
+
if (!$sessionId || $sessionId == NULL) {
|
23 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
24 |
+
return false;
|
25 |
+
}
|
26 |
+
|
27 |
+
if (isset($post_data['limit'])) {
|
28 |
+
$limit = $post_data['limit'];
|
29 |
+
}
|
30 |
+
if (isset($post_data['storeid'])) {
|
31 |
+
$storeId = $post_data['storeid'];
|
32 |
+
}
|
33 |
+
if (isset($post_data['offset'])) {
|
34 |
+
$offset = $post_data['offset'];
|
35 |
+
}
|
36 |
+
if (isset($post_data['is_refresh'])) {
|
37 |
+
$is_refresh = $post_data['is_refresh'];
|
38 |
+
}
|
39 |
+
if (isset($post_data['source'])) {
|
40 |
+
$source = $post_data['source'];
|
41 |
+
}
|
42 |
+
|
43 |
+
$orderCollection = Mage::getResourceModel('sales/order_grid_collection')->addFieldToFilter('store_id', Array('eq' => $storeId))->setOrder('entity_id', 'desc');
|
44 |
+
if ($offset != null) {
|
45 |
+
$orderCollection->addAttributeToFilter('entity_id', array('lt' => $offset));
|
46 |
+
}
|
47 |
+
if ($is_refresh == 1) {
|
48 |
+
if (isset($post_data['last_fetch_order'])) {
|
49 |
+
$last_fetch_order = $post_data['last_fetch_order'];
|
50 |
+
}
|
51 |
+
if (isset($post_data['min_fetch_order'])) {
|
52 |
+
$min_fetch_order = $post_data['min_fetch_order'];
|
53 |
+
}
|
54 |
+
if (isset($post_data['last_updated'])) {
|
55 |
+
$last_updated = Mage::helper('mobileassistant')->getActualDate($post_data['last_updated']);
|
56 |
+
}
|
57 |
+
|
58 |
+
$orderCollection->getSelect()->where("(entity_id BETWEEN '" . $min_fetch_order . "'AND '" . $last_fetch_order . "' AND updated_at > '" . $last_updated . "') OR entity_id >'" . $last_fetch_order . "'");
|
59 |
+
}
|
60 |
+
|
61 |
+
$orderCollection->getSelect()->limit($limit);
|
62 |
+
|
63 |
+
foreach ($orderCollection as $order) {
|
64 |
+
if ($source == 'dashboard') {
|
65 |
+
$grand_total = Mage::helper('mobileassistant')->getPrice($order->getBaseGrandTotal(), $order->getStoreId(), $order->getBaseCurrencyCode());
|
66 |
+
} else {
|
67 |
+
$grand_total = Mage::helper('mobileassistant')->getPrice($order->getGrandTotal(), $order->getStoreId(), $order->getOrderCurrencyCode());
|
68 |
+
}
|
69 |
+
|
70 |
+
$orderListData[] = array(
|
71 |
+
'entity_id' => $order->getEntityId(),
|
72 |
+
'increment_id' => $order->getIncrementId(),
|
73 |
+
'store_id' => $order->getStoreId(),
|
74 |
+
'customer_name' => $order->getBillingName(),
|
75 |
+
'status' => $order->getStatus(),
|
76 |
+
'order_date' => Mage::helper('mobileassistant')->getActualOrderDate($order->getCreatedAt()),
|
77 |
+
'grand_total' => $grand_total,
|
78 |
+
'toal_qty' => Mage::getModel('sales/order')->load($order->getEntityId())->getTotalQtyOrdered(),
|
79 |
+
'total_items' => count($order->getAllItems())
|
80 |
+
);
|
81 |
+
}
|
82 |
+
|
83 |
+
$updated_time = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
|
84 |
+
$orderListResultArr = array('orderlistdata' => $orderListData, 'updated_time' => $updated_time);
|
85 |
+
$orderListResult = Mage::helper('core')->jsonEncode($orderListResultArr);
|
86 |
+
return Mage::app()->getResponse()->setBody($orderListResult);
|
87 |
+
} else {
|
88 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
89 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
public function getFilterOrderListAction() {
|
94 |
+
if (Mage::helper('mobileassistant')->isEnable()) {
|
95 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
96 |
+
|
97 |
+
$sessionId = '';
|
98 |
+
$storeId = '';
|
99 |
+
$filter_by_date = '';
|
100 |
+
$filter_by_status = '';
|
101 |
+
$search_by_id = '';
|
102 |
+
$orderListData = array();
|
103 |
+
if (isset($post_data['storeid'])) {
|
104 |
+
$storeId = $post_data['storeid'];
|
105 |
+
}
|
106 |
+
if (isset($post_data['storeid'])) {
|
107 |
+
$sessionId = $post_data['session'];
|
108 |
+
}
|
109 |
+
|
110 |
+
if (!$sessionId || $sessionId == NULL) {
|
111 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
112 |
+
return false;
|
113 |
+
}
|
114 |
+
|
115 |
+
if (isset($post_data['filter_by_date'])) {
|
116 |
+
$filter_by_date = $post_data['filter_by_date'];
|
117 |
+
}
|
118 |
+
if (isset($post_data['filter_by_status'])) {
|
119 |
+
$filter_by_status = $post_data['filter_by_status'];
|
120 |
+
}
|
121 |
+
if (isset($post_data['search_by_id'])) {
|
122 |
+
$search_by_id = $post_data['search_by_id'];
|
123 |
+
}
|
124 |
+
$now = Mage::getModel('core/date')->timestamp(time());
|
125 |
+
$orderCollection = Mage::getResourceModel('sales/order_grid_collection')->addFieldToFilter('store_id', Array('eq' => $storeId))->setOrder('entity_id', 'desc');
|
126 |
+
|
127 |
+
if ($filter_by_date != null) {
|
128 |
+
$dateEnd = date('Y-m-d 23:59:59', $now);
|
129 |
+
if ($filter_by_date == 1) {
|
130 |
+
$dateStart = date('Y-m-d 00:00:00', $now);
|
131 |
+
$orderCollection->addAttributeToFilter('created_at', array('from' => $dateStart, 'to' => $dateEnd));
|
132 |
+
} elseif ($filter_by_date == 2) {
|
133 |
+
$dateStart = date('Y-m-d 00:00:00', strtotime('-6 days'));
|
134 |
+
$orderCollection->addAttributeToFilter('created_at', array('from' => $dateStart, 'to' => $dateEnd));
|
135 |
+
} elseif ($filter_by_date == 3) {
|
136 |
+
$dateStart = date('Y-m-01 00:00:00');
|
137 |
+
$orderCollection->addAttributeToFilter('created_at', array('from' => $dateStart, 'to' => $dateEnd));
|
138 |
+
} elseif ($filter_by_date == 4) {
|
139 |
+
$orderCollection->addAttributeToFilter('created_at', array("lt" => $post_data['before_date'] . " 00:00:00"));
|
140 |
+
} elseif ($filter_by_date == 5) {
|
141 |
+
$dateStart = $post_data['start_date'] . " 00:00:00";
|
142 |
+
$dateEnd = $post_data['end_date'] . " 23:59:59";
|
143 |
+
$orderCollection->addAttributeToFilter('created_at', array('from' => $dateStart, 'to' => $dateEnd));
|
144 |
+
} elseif ($filter_by_date == 6) {
|
145 |
+
$orderCollection->addAttributeToFilter('created_at', array("gt" => $post_data['after_date'] . " 23:59:59"));
|
146 |
+
}
|
147 |
+
}
|
148 |
+
if ($filter_by_status != null) {
|
149 |
+
$orderCollection->addFieldToFilter('status', Array('eq' => $filter_by_status));
|
150 |
+
}
|
151 |
+
|
152 |
+
if ($search_by_id != null) {
|
153 |
+
$orderCollection->addFieldToFilter('increment_id', Array('like' => '%' . $search_by_id . '%'));
|
154 |
+
}
|
155 |
+
foreach ($orderCollection as $order) {
|
156 |
+
|
157 |
+
$orderListData[] = array(
|
158 |
+
'entity_id' => $order->getEntityId(),
|
159 |
+
'increment_id' => $order->getIncrementId(),
|
160 |
+
'store_id' => $order->getStoreId(),
|
161 |
+
'customer_name' => $order->getBillingName(),
|
162 |
+
'status' => $order->getStatus(),
|
163 |
+
'order_date' => Mage::helper('mobileassistant')->getActualOrderDate($order->getCreatedAt()),
|
164 |
+
'grand_total' => Mage::helper('mobileassistant')->getPrice($order->getGrandTotal(), $order->getStoreId(), $order->getOrderCurrencyCode()),
|
165 |
+
'toal_qty' => Mage::getModel('sales/order')->load($order->getEntityId())->getTotalQtyOrdered(),
|
166 |
+
'total_items' => count($order->getAllItems())
|
167 |
+
);
|
168 |
+
}
|
169 |
+
$orderListResultArr = array('orderlistdata' => $orderListData);
|
170 |
+
$orderListResult = Mage::helper('core')->jsonEncode($orderListResultArr);
|
171 |
+
return Mage::app()->getResponse()->setBody($orderListResult);
|
172 |
+
} else {
|
173 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
174 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
175 |
+
}
|
176 |
+
}
|
177 |
+
|
178 |
+
public function getOrderDetailAction() {
|
179 |
+
if (Mage::helper('mobileassistant')->isEnable()) {
|
180 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
181 |
+
|
182 |
+
$sessionId = '';
|
183 |
+
$storeId = '';
|
184 |
+
$order_id = '';
|
185 |
+
if (isset($post_data['session'])) {
|
186 |
+
$sessionId = $post_data['session'];
|
187 |
+
}
|
188 |
+
if (isset($post_data['storeid'])) {
|
189 |
+
$storeId = $post_data['storeid'];
|
190 |
+
}
|
191 |
+
|
192 |
+
if (!$sessionId || $sessionId == NULL) {
|
193 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
194 |
+
return false;
|
195 |
+
}
|
196 |
+
|
197 |
+
if (isset($post_data['entity_id'])) {
|
198 |
+
$order_id = $post_data['entity_id'];
|
199 |
+
}
|
200 |
+
$order = Mage::getModel('sales/order')->load($order_id);
|
201 |
+
|
202 |
+
$order_detail = array(
|
203 |
+
'entity_id' => $order->getEntityId(),
|
204 |
+
'increment_id' => $order->getIncrementId(),
|
205 |
+
'status' => $order->getStatus(),
|
206 |
+
'order_date' => Mage::helper('mobileassistant')->getActualOrderDate($order->getCreatedAt()),
|
207 |
+
'total_qty' => $order->getTotalQtyOrdered(),
|
208 |
+
'total_items' => count($order->getAllItems()),
|
209 |
+
'grand_total' => Mage::helper('mobileassistant')->getPrice($order->getGrandTotal(), $order->getStoreId(), $order->getOrderCurrencyCode()),
|
210 |
+
'sub_total' => Mage::helper('mobileassistant')->getPrice($order->getSubtotal(), $order->getStoreId(), $order->getOrderCurrencyCode()),
|
211 |
+
'discount' => Mage::helper('mobileassistant')->getPrice($order->getDiscountAmount(), $order->getStoreId(), $order->getOrderCurrencyCode()),
|
212 |
+
'tax' => Mage::helper('mobileassistant')->getPrice($order->getTax(), $order->getStoreId(), $order->getOrderCurrencyCode())
|
213 |
+
);
|
214 |
+
|
215 |
+
$customer_id = $order->getCustomerId();
|
216 |
+
$customer_name = $order->getCustomerFirstname() . " " . $order->getCustomerLastname();
|
217 |
+
if ($customer_id == null) {
|
218 |
+
$customer_name = $order->getCustomerName();
|
219 |
+
}
|
220 |
+
$customer_detail = array(
|
221 |
+
'customer_id' => $customer_id,
|
222 |
+
'customer_name' => $customer_name,
|
223 |
+
'customer_email' => $order->getCustomerEmail()
|
224 |
+
);
|
225 |
+
|
226 |
+
$billing_address = $order->getBillingAddress();
|
227 |
+
$billing_address_data = array(
|
228 |
+
'name' => $billing_address->getFirstname() . ' ' . $billing_address->getLastname(),
|
229 |
+
'street' => $billing_address->getData('street'),
|
230 |
+
'city' => $billing_address->getCity(),
|
231 |
+
'region' => $billing_address->getRegion(),
|
232 |
+
'postcode' => $billing_address->getPostcode(),
|
233 |
+
'country' => Mage::getModel('directory/country')->loadByCode($billing_address->getCountryId())->getName(),
|
234 |
+
'telephone' => $billing_address->getTelephone()
|
235 |
+
);
|
236 |
+
$shipping_address = $order->getShippingAddress();
|
237 |
+
if ($shipping_address) {
|
238 |
+
$shipping_address_data = array(
|
239 |
+
'name' => $shipping_address->getFirstname() . ' ' . $shipping_address->getLastname(),
|
240 |
+
'street' => $shipping_address->getData('street'),
|
241 |
+
'city' => $shipping_address->getCity(),
|
242 |
+
'region' => $shipping_address->getRegion(),
|
243 |
+
'postcode' => $shipping_address->getPostcode(),
|
244 |
+
'country' => Mage::getModel('directory/country')->loadByCode($shipping_address->getCountryId())->getName(),
|
245 |
+
'telephone' => $shipping_address->getTelephone()
|
246 |
+
);
|
247 |
+
}
|
248 |
+
|
249 |
+
$payment_info = array(
|
250 |
+
'payment_method' => $order->getPayment()->getMethodInstance()->getTitle()
|
251 |
+
);
|
252 |
+
|
253 |
+
$shipping_info = array(
|
254 |
+
'shipping_method' => $order->getShippingDescription(),
|
255 |
+
'shipping_charge' => Mage::helper('mobileassistant')->getPrice($order->getShippingAmount(), $order->getStoreId(), $order->getOrderCurrencyCode())
|
256 |
+
);
|
257 |
+
|
258 |
+
$products_detail = $this->_orderedProductDetails($order_id);
|
259 |
+
|
260 |
+
$full_order_detail = array(
|
261 |
+
'basic_order_detail' => $order_detail,
|
262 |
+
'customer_detail' => $customer_detail,
|
263 |
+
'billing_address' => $billing_address_data,
|
264 |
+
'shipping_address' => $shipping_address_data,
|
265 |
+
'payment_info' => $payment_info,
|
266 |
+
'shipping_info' => $shipping_info,
|
267 |
+
'product_detail' => $products_detail
|
268 |
+
);
|
269 |
+
$orderDetailResultArr = array('orderlistdata' => $full_order_detail);
|
270 |
+
$orderDetailResult = Mage::helper('core')->jsonEncode($orderDetailResultArr);
|
271 |
+
return Mage::app()->getResponse()->setBody($orderDetailResult);
|
272 |
+
} else {
|
273 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
274 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
275 |
+
}
|
276 |
+
}
|
277 |
+
|
278 |
+
protected function _orderedProductDetails($order_id) {
|
279 |
+
$order = Mage::getModel('sales/order')->load($order_id);
|
280 |
+
foreach ($order->getItemsCollection() as $item) {
|
281 |
+
$options = $item->getProductOptions();
|
282 |
+
if ($item->getProductType() == "downloadable") {
|
283 |
+
$obj = new Mage_Downloadable_Block_Adminhtml_Sales_Items_Column_Downloadable_Name();
|
284 |
+
foreach ($options['links'] as $links) {
|
285 |
+
|
286 |
+
$this->_purchased = Mage::getModel('downloadable/link_purchased')
|
287 |
+
->load($order_id, 'order_id');
|
288 |
+
$purchasedItem = Mage::getModel('downloadable/link_purchased_item')->getCollection()
|
289 |
+
->addFieldToFilter('order_item_id', $item->getId());
|
290 |
+
$this->_purchased->setPurchasedItems($purchasedItem);
|
291 |
+
|
292 |
+
foreach ($this->_purchased->getPurchasedItems() as $_link) {
|
293 |
+
$links_value[] = $_link->getLinkTitle() . '(' . $_link->getNumberOfDownloadsUsed() . ' / ' . ($_link->getNumberOfDownloadsBought() ? $_link->getNumberOfDownloadsBought() : Mage::helper('downloadable')->__('U')) . ')';
|
294 |
+
}
|
295 |
+
|
296 |
+
$info = array(array(
|
297 |
+
'label' => $obj->getLinksTitle(),
|
298 |
+
'value' => implode(',', $links_value)
|
299 |
+
));
|
300 |
+
}
|
301 |
+
} else {
|
302 |
+
|
303 |
+
$result = array();
|
304 |
+
if ($options = $item->getProductOptions()) {
|
305 |
+
if (isset($options['options'])) {
|
306 |
+
$result = array_merge($result, $options['options']);
|
307 |
+
}
|
308 |
+
if (isset($options['additional_options'])) {
|
309 |
+
$result = array_merge($result, $options['additional_options']);
|
310 |
+
}
|
311 |
+
if (!empty($options['attributes_info'])) {
|
312 |
+
$result = array_merge($options['attributes_info'], $result);
|
313 |
+
}
|
314 |
+
}
|
315 |
+
|
316 |
+
$info = array();
|
317 |
+
if ($result) {
|
318 |
+
foreach ($result as $_option) {
|
319 |
+
$info[] = array(
|
320 |
+
'label' => $_option['label'],
|
321 |
+
'value' => $_option['value']
|
322 |
+
);
|
323 |
+
}
|
324 |
+
}
|
325 |
+
}
|
326 |
+
$skus = '';
|
327 |
+
$product = Mage::getModel('catalog/product')->load($item->getProductId());
|
328 |
+
if ($item->getParentItem())
|
329 |
+
continue;
|
330 |
+
if ($_options = $this->_getItemOptions($item)) {
|
331 |
+
$skus = $_options;
|
332 |
+
}
|
333 |
+
$products_detail[] = array(
|
334 |
+
'product_id' => $item->getProductId(),
|
335 |
+
'name' => $item->getName(),
|
336 |
+
'sku' => $item->getSku(),
|
337 |
+
'unit_price' => Mage::helper('mobileassistant')->getPrice($item->getOriginalPrice(), $order->getStoreId(), $order->getOrderCurrencyCode()),
|
338 |
+
'ordered_qty' => round($item->getQtyOrdered(), 2),
|
339 |
+
'row_total' => Mage::helper('mobileassistant')->getPrice($item->getRowTotal(), $order->getStoreId(), $order->getOrderCurrencyCode()),
|
340 |
+
'options' => $skus ? $skus : '',
|
341 |
+
'image' => ($product->getImage()) ? Mage::helper('catalog/image')->init($product, 'image', $product->getImage())->resize(300, 330)->keepAspectRatio(true)->constrainOnly(true)->__toString() : 'N/A',
|
342 |
+
'attribute_info' => $info ? $info : ''
|
343 |
+
);
|
344 |
+
}
|
345 |
+
return $products_detail;
|
346 |
+
}
|
347 |
+
|
348 |
+
private function _getItemOptions($item) {
|
349 |
+
$skus = '';
|
350 |
+
$id = array('id' => $item->getItemId());
|
351 |
+
$order_items = Mage::getModel('sales/order_item')->getCollection()->addFieldToFilter('parent_item_id', Array('eq' => $id));
|
352 |
+
foreach ($order_items as $order_item) {
|
353 |
+
$product_data = Mage::getModel('catalog/product')->load($order_item->getProductId());
|
354 |
+
$skus[] = $product_data->getSku();
|
355 |
+
}
|
356 |
+
return $skus;
|
357 |
+
}
|
358 |
+
|
359 |
+
}
|
app/code/local/Biztech/Mobileassistant/controllers/ProductController.php
CHANGED
@@ -1,294 +1,363 @@
|
|
1 |
<?php
|
2 |
-
class Biztech_Mobileassistant_ProductController extends Mage_Core_Controller_Front_Action
|
3 |
-
{
|
4 |
-
public function getProductListAction()
|
5 |
-
{
|
6 |
-
if(Mage::helper('mobileassistant')->isEnable()){
|
7 |
|
8 |
-
|
9 |
-
$sessionId = $post_data['session'];
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
|
17 |
-
$
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
$is_refresh = $post_data['is_refresh'];
|
|
|
21 |
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
$
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
34 |
}
|
|
|
|
|
35 |
|
36 |
-
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
$
|
46 |
-
'id' => $product->getId(),
|
47 |
-
'sku' => $product_data->getSku(),
|
48 |
-
'name' => $product_data->getName(),
|
49 |
-
'status' => $status,
|
50 |
-
'qty' => $qty,
|
51 |
-
'price' => Mage::helper('mobileassistant')->getPrice($product_data->getPrice(),$storeId),
|
52 |
-
'image' => ($product_data->getImage())?Mage::helper('catalog/image')->init($product, 'image',$product_data->getImage())->resize(300,330)->keepAspectRatio(true)->constrainOnly(true)->__toString():'N/A',
|
53 |
-
'type' => $product->getTypeId()
|
54 |
-
);
|
55 |
}
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
}
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
$sessionId = $post_data['session'];
|
|
|
|
|
|
|
71 |
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
}
|
75 |
-
|
76 |
-
$
|
77 |
-
$
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $productSku);
|
83 |
-
if($product)
|
84 |
-
{
|
85 |
-
$product_data = Mage::getModel('catalog/product')->load($product->getId());
|
86 |
-
}else{
|
87 |
-
$result = Mage::helper('core')->jsonEncode(array('mesage' => 'No product found.'));
|
88 |
-
return Mage::app()->getResponse()->setBody($result);
|
89 |
-
}
|
90 |
-
|
91 |
-
}else{
|
92 |
-
$product_data = Mage::getModel('catalog/product')->load($productId);
|
93 |
}
|
|
|
|
|
|
|
94 |
|
95 |
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
$
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
|
|
104 |
}
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
}
|
114 |
-
|
115 |
-
|
116 |
-
$status = $associated_product->getStatus();
|
117 |
-
$qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($associated_product)->getQty();
|
118 |
-
if($status == 1){$status = 'Enabled';}else{$status = 'Disabled';}
|
119 |
-
if($qty == 0 || $associated_product->getIsInStock() == 0){$qty = 'Out of Stock';}
|
120 |
-
$associated_products_details[] = array(
|
121 |
-
'id' => $associated_product->getId(),
|
122 |
-
'sku' => $associated_product->getSku()
|
123 |
-
);
|
124 |
-
|
125 |
-
$associated_products_list[] = array(
|
126 |
-
'id' => $associated_product->getId(),
|
127 |
-
'sku' => $associated_product->getSku(),
|
128 |
-
'name' => $associated_product->getName(),
|
129 |
-
'status' => $status,
|
130 |
-
'qty' => $qty,
|
131 |
-
'price' => Mage::helper('mobileassistant')->getPrice($associated_product->getPrice(),$storeId),
|
132 |
-
);
|
133 |
}
|
|
|
|
|
|
|
|
|
134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
|
136 |
|
137 |
|
138 |
-
$product_details[] = array(
|
139 |
-
'id' => $product_data->getId(),
|
140 |
-
'sku' => $product_data->getSku(),
|
141 |
-
'name' => $product_data->getName(),
|
142 |
-
'status' => $pro_status,
|
143 |
-
'qty' => $pro_qty,
|
144 |
-
'price' => Mage::helper('mobileassistant')->getPrice($product_data->getPrice(),$storeId),
|
145 |
-
'desc' => $product_data->getDescription(),
|
146 |
-
'type' => $product_data->getTypeId(),
|
147 |
-
'special_price' => Mage::helper('mobileassistant')->getPrice($product_data->getSpecialPrice(),$storeId),
|
148 |
-
'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',
|
149 |
-
'associated_skus' => $associated_products_details,
|
150 |
-
'all_images' => $images,
|
151 |
-
|
152 |
-
);
|
153 |
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
)
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
}
|
|
|
|
|
|
|
168 |
}
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
$sessionId = $post_data['session'];
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
}
|
180 |
-
try{
|
181 |
-
$storeId = $post_data['storeid'];
|
182 |
-
$filter_by_name = $post_data['filter_by_name'];
|
183 |
-
$filter_by_type = $post_data['product_type'];
|
184 |
-
$filter_by_qty = $post_data['filter_by_qty'];
|
185 |
-
|
186 |
-
$products = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($storeId)->setOrder('entity_id', 'desc');
|
187 |
-
|
188 |
-
if($filter_by_name != null){
|
189 |
-
$products->addAttributeToFilter(array(
|
190 |
-
array(
|
191 |
-
'attribute' => 'name',
|
192 |
-
'like' => '%'.$filter_by_name.'%'
|
193 |
-
),
|
194 |
-
array(
|
195 |
-
'attribute' => 'sku',
|
196 |
-
'like' => '%'.$filter_by_name.'%'
|
197 |
-
)
|
198 |
-
));
|
199 |
-
}
|
200 |
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
}
|
218 |
}
|
|
|
219 |
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
$
|
228 |
-
'id' => $product->getId(),
|
229 |
-
'sku' => $product_data->getSku(),
|
230 |
-
'name' => $product_data->getName(),
|
231 |
-
'status' => $status,
|
232 |
-
'qty' => $qty,
|
233 |
-
'price' => Mage::helper('mobileassistant')->getPrice($product_data->getPrice(),$storeId),
|
234 |
-
'type' => $product->getTypeId(),
|
235 |
-
'image' => ($product_data->getImage())?Mage::helper('catalog/image')->init($product, 'image',$product_data->getImage())->resize(300,330)->keepAspectRatio(true)->constrainOnly(true)->__toString():'N/A',
|
236 |
-
);
|
237 |
}
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
'
|
245 |
-
'
|
|
|
|
|
|
|
|
|
246 |
);
|
247 |
-
return Mage::app()->getResponse()->setBody(Mage::helper('core')->jsonEncode($product_list));
|
248 |
}
|
249 |
-
|
250 |
-
$
|
251 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
}
|
|
|
|
|
|
|
253 |
}
|
|
|
254 |
|
255 |
-
|
256 |
-
{
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
}elseif($current_status != $new_status && $new_status == 2){
|
276 |
-
Mage::getModel('catalog/product_status')->updateProductStatus($productId, $storeId, Mage_Catalog_Model_Product_Status::STATUS_DISABLED);
|
277 |
-
}
|
278 |
-
$productResultArr = array('message' => 'Product has been successfully updated.');
|
279 |
-
$productDetailResult = Mage::helper('core')->jsonEncode($productResultArr);
|
280 |
-
return Mage::app()->getResponse()->setBody($productDetailResult);
|
281 |
-
}catch (Exception $e){
|
282 |
-
$product_details = array (
|
283 |
-
'status' => 'error',
|
284 |
-
'message' => $e->getMessage()
|
285 |
-
);
|
286 |
-
return Mage::app()->getResponse()->setBody(Mage::helper('core')->jsonEncode($product_details));
|
287 |
}
|
288 |
-
|
289 |
-
$
|
290 |
-
return Mage::app()->getResponse()->setBody($
|
|
|
|
|
|
|
|
|
|
|
|
|
291 |
}
|
|
|
|
|
|
|
292 |
}
|
|
|
293 |
|
294 |
-
}
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
class Biztech_Mobileassistant_ProductController extends Mage_Core_Controller_Front_Action {
|
|
|
4 |
|
5 |
+
public function getProductListAction() {
|
6 |
+
if (Mage::helper('mobileassistant')->isEnable()) {
|
7 |
+
|
8 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
9 |
+
$sessionId = '';
|
10 |
+
$offset = '';
|
11 |
+
$limit = '';
|
12 |
+
$new_products = '';
|
13 |
+
$is_refresh = '';
|
14 |
+
$last_fetch_product = '';
|
15 |
+
$min_fetch_product = '';
|
16 |
+
$last_updated = '';
|
17 |
|
18 |
+
if (isset($post_data['session'])) {
|
19 |
+
$sessionId = $post_data['session'];
|
20 |
+
}
|
21 |
+
if (!$sessionId || $sessionId == NULL) {
|
22 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
23 |
+
return false;
|
24 |
+
}
|
25 |
+
if (isset($post_data['storeid'])) {
|
26 |
+
$storeId = $post_data['storeid'];
|
27 |
+
}
|
28 |
+
if (isset($post_data['limit'])) {
|
29 |
+
$limit = $post_data['limit'];
|
30 |
+
}
|
31 |
+
if (isset($post_data['offset'])) {
|
32 |
+
$offset = $post_data['offset'];
|
33 |
+
}
|
34 |
+
if (isset($post_data['last_fetch_product'])) {
|
35 |
+
$new_products = $post_data['last_fetch_product'];
|
36 |
+
}
|
37 |
+
if (isset($post_data['is_refresh'])) {
|
38 |
$is_refresh = $post_data['is_refresh'];
|
39 |
+
}
|
40 |
|
41 |
|
42 |
+
$products = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($storeId)->setOrder('entity_id', 'desc');
|
43 |
+
if ($offset != null) {
|
44 |
+
$products->addAttributeToFilter('entity_id', array('lt' => $offset));
|
45 |
+
}
|
46 |
|
47 |
|
48 |
+
if ($is_refresh == 1) {
|
49 |
+
if (isset($post_data['last_fetch_product'])) {
|
50 |
+
$last_fetch_product = $post_data['last_fetch_product'];
|
51 |
+
}
|
52 |
+
if (isset($post_data['min_fetch_product'])) {
|
53 |
+
$min_fetch_product = $post_data['min_fetch_product'];
|
54 |
+
}
|
55 |
+
if (isset($post_data['last_updated'])) {
|
56 |
+
$last_updated = $post_data['last_updated'];
|
57 |
}
|
58 |
+
$products->getSelect()->where("(entity_id BETWEEN '" . $min_fetch_product . "'AND '" . $last_fetch_product . "' AND updated_at > '" . $last_updated . "') OR entity_id >'" . $last_fetch_product . "'");
|
59 |
+
}
|
60 |
|
61 |
+
$products->getSelect()->limit($limit);
|
62 |
|
63 |
+
foreach ($products as $product) {
|
64 |
+
$product_data = Mage::getModel('catalog/product')->load($product->getId());
|
65 |
+
$status = $product_data->getStatus();
|
66 |
+
$qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product_data)->getQty();
|
67 |
+
if ($status == 1) {
|
68 |
+
$status = 'Enabled';
|
69 |
+
} else {
|
70 |
+
$status = 'Disabled';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
}
|
72 |
+
if ($qty < 0 || $product_data->getIsInStock() == 0) {
|
73 |
+
$qty = 'Out of Stock';
|
74 |
+
}
|
75 |
+
$product_list[] = array(
|
76 |
+
'id' => $product->getId(),
|
77 |
+
'sku' => $product_data->getSku(),
|
78 |
+
'name' => $product_data->getName(),
|
79 |
+
'status' => $status,
|
80 |
+
'qty' => $qty,
|
81 |
+
'price' => Mage::helper('mobileassistant')->getPrice($product_data->getPrice(), $storeId, Mage::app()->getStore()->getCurrentCurrencyCode()),
|
82 |
+
'image' => ($product_data->getImage()) ? Mage::helper('catalog/image')->init($product, 'image', $product_data->getImage())->resize(300, 330)->keepAspectRatio(true)->constrainOnly(true)->__toString() : 'N/A',
|
83 |
+
'type' => $product->getTypeId()
|
84 |
+
);
|
85 |
}
|
86 |
+
$updated_time = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
|
87 |
+
$productResultArr = array('productlistdata' => $product_list, 'updated_time' => $updated_time);
|
88 |
+
$productListResult = Mage::helper('core')->jsonEncode($productResultArr);
|
89 |
+
return Mage::app()->getResponse()->setBody($productListResult);
|
90 |
+
} else {
|
91 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
92 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
93 |
}
|
94 |
+
}
|
95 |
+
|
96 |
+
public function getProductDetailAction() {
|
97 |
+
if (Mage::helper('mobileassistant')->isEnable()) {
|
98 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
99 |
+
|
100 |
+
$storeId = '';
|
101 |
+
$productId = '';
|
102 |
+
$productSku = '';
|
103 |
+
$associated_products = array();
|
104 |
+
$associated_products_list = '';
|
105 |
+
$associated_products_details = '';
|
106 |
+
$images = '';
|
107 |
+
if (isset($post_data['session'])) {
|
108 |
$sessionId = $post_data['session'];
|
109 |
+
}
|
110 |
+
|
111 |
+
if (!$sessionId || $sessionId == NULL) {
|
112 |
|
113 |
+
}
|
114 |
+
try {
|
115 |
+
if (isset($post_data['storeid'])) {
|
116 |
+
$storeId = $post_data['storeid'];
|
117 |
+
}
|
118 |
+
if (isset($post_data['productid'])) {
|
119 |
+
$productId = $post_data['productid'];
|
120 |
+
}
|
121 |
+
if (isset($post_data['sku'])) {
|
122 |
+
$productSku = $post_data['sku'];
|
123 |
}
|
124 |
+
if (isset($productSku) && $productSku != null) {
|
125 |
+
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $productSku);
|
126 |
+
if ($product) {
|
127 |
+
$product_data = Mage::getModel('catalog/product')->load($product->getId());
|
128 |
+
} else {
|
129 |
+
$result = Mage::helper('core')->jsonEncode(array('mesage' => 'No product found.'));
|
130 |
+
return Mage::app()->getResponse()->setBody($result);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
}
|
132 |
+
} else {
|
133 |
+
$product_data = Mage::getModel('catalog/product')->load($productId);
|
134 |
+
}
|
135 |
|
136 |
|
137 |
+
$pro_status = $product_data->getStatus();
|
138 |
+
$pro_qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product_data)->getQty();
|
139 |
+
if ($pro_qty < 0 || $product_data->getIsInStock() == 0) {
|
140 |
+
$pro_qty = 'Out of Stock';
|
141 |
+
}
|
142 |
+
$_images = $product_data->getMediaGalleryImages();
|
143 |
+
if ($_images) {
|
144 |
+
foreach ($_images as $_image) {
|
145 |
+
$images[] = Mage::helper('catalog/image')->init($product_data, 'thumbnail', $_image->getFile())->resize(300, 330)->keepAspectRatio(true)->constrainOnly(true)->__toString();
|
146 |
}
|
147 |
+
}
|
148 |
+
if ($pro_status == 1) {
|
149 |
+
$pro_status = 'Enabled';
|
150 |
+
} else {
|
151 |
+
$pro_status = 'Disabled';
|
152 |
+
}
|
153 |
+
|
154 |
+
if ($product_data->getTypeId() == 'grouped') {
|
155 |
+
$associated_products = $product_data->getTypeInstance(true)->getAssociatedProducts($product_data);
|
156 |
+
} elseif ($product_data->getTypeId() == 'configurable') {
|
157 |
+
$associated_products = $product_data->getTypeInstance()->getUsedProducts();
|
158 |
+
} elseif ($product_data->getTypeId() == 'bundle') {
|
159 |
+
$associated_products = $product_data->getTypeInstance(true)->getSelectionsCollection($product_data->getTypeInstance(true)->getOptionsIds($product_data), $product_data);
|
160 |
+
}
|
161 |
+
foreach ($associated_products as $associated_product) {
|
162 |
+
$status = $associated_product->getStatus();
|
163 |
+
$qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($associated_product)->getQty();
|
164 |
+
if ($status == 1) {
|
165 |
+
$status = 'Enabled';
|
166 |
+
} else {
|
167 |
+
$status = 'Disabled';
|
168 |
}
|
169 |
+
if ($qty == 0 || $associated_product->getIsInStock() == 0) {
|
170 |
+
$qty = 'Out of Stock';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
}
|
172 |
+
$associated_products_details[] = array(
|
173 |
+
'id' => $associated_product->getId(),
|
174 |
+
'sku' => $associated_product->getSku()
|
175 |
+
);
|
176 |
|
177 |
+
$associated_products_list[] = array(
|
178 |
+
'id' => $associated_product->getId(),
|
179 |
+
'sku' => $associated_product->getSku(),
|
180 |
+
'name' => $associated_product->getName(),
|
181 |
+
'status' => $status,
|
182 |
+
'qty' => $qty,
|
183 |
+
'price' => Mage::helper('mobileassistant')->getPrice($associated_product->getPrice(), $storeId),
|
184 |
+
);
|
185 |
+
}
|
186 |
|
187 |
|
188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
|
190 |
+
$product_details[] = array(
|
191 |
+
'id' => $product_data->getId(),
|
192 |
+
'sku' => $product_data->getSku(),
|
193 |
+
'name' => $product_data->getName(),
|
194 |
+
'status' => $pro_status,
|
195 |
+
'qty' => $pro_qty,
|
196 |
+
'price' => Mage::helper('mobileassistant')->getPrice($product_data->getPrice(), $storeId),
|
197 |
+
'desc' => $product_data->getDescription(),
|
198 |
+
'type' => $product_data->getTypeId(),
|
199 |
+
'special_price' => Mage::helper('mobileassistant')->getPrice($product_data->getSpecialPrice(), $storeId),
|
200 |
+
'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',
|
201 |
+
'associated_skus' => $associated_products_details,
|
202 |
+
'all_images' => $images,
|
203 |
+
);
|
204 |
+
|
205 |
+
$productResultArr = array('productdata' => $product_details, 'associated_products_list' => $associated_products_list);
|
206 |
+
$productDetailResult = Mage::helper('core')->jsonEncode($productResultArr);
|
207 |
+
return Mage::app()->getResponse()->setBody($productDetailResult);
|
208 |
+
} catch (Exception $e) {
|
209 |
+
$product_details = array(
|
210 |
+
'status' => 'error',
|
211 |
+
'message' => $e->getMessage()
|
212 |
+
);
|
213 |
+
return Mage::app()->getResponse()->setBody(Mage::helper('core')->jsonEncode($product_details));
|
214 |
}
|
215 |
+
} else {
|
216 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
217 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
218 |
}
|
219 |
+
}
|
220 |
+
|
221 |
+
public function filterProductAction() {
|
222 |
+
if (Mage::helper('mobileassistant')->isEnable()) {
|
223 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
224 |
+
|
225 |
+
$sessionId = '';
|
226 |
+
$storeId = '';
|
227 |
+
$filter_by_name = '';
|
228 |
+
$filter_by_type = '';
|
229 |
+
$filter_by_qty = '';
|
230 |
+
$product_list = '';
|
231 |
+
if (isset($post_data['session'])) {
|
232 |
$sessionId = $post_data['session'];
|
233 |
+
}
|
234 |
+
|
235 |
+
if (!$sessionId || $sessionId == NULL) {
|
236 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
237 |
+
return false;
|
238 |
+
}
|
239 |
+
try {
|
240 |
+
if (isset($post_data['storeid'])) {
|
241 |
+
$storeId = $post_data['storeid'];
|
242 |
+
}
|
243 |
+
if (isset($post_data['filter_by_name'])) {
|
244 |
+
$filter_by_name = $post_data['filter_by_name'];
|
245 |
+
}
|
246 |
+
if (isset($post_data['product_type'])) {
|
247 |
+
$filter_by_type = $post_data['product_type'];
|
248 |
+
}
|
249 |
+
if (isset($post_data['filter_by_qty'])) {
|
250 |
+
$filter_by_qty = $post_data['filter_by_qty'];
|
251 |
+
}
|
252 |
+
$products = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($storeId)->setOrder('entity_id', 'desc');
|
253 |
+
|
254 |
+
if ($filter_by_name != null) {
|
255 |
+
$products->addAttributeToFilter(array(
|
256 |
+
array(
|
257 |
+
'attribute' => 'name',
|
258 |
+
'like' => '%' . $filter_by_name . '%'
|
259 |
+
),
|
260 |
+
array(
|
261 |
+
'attribute' => 'sku',
|
262 |
+
'like' => '%' . $filter_by_name . '%'
|
263 |
+
)
|
264 |
+
));
|
265 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
|
267 |
+
if ($filter_by_type != null) {
|
268 |
+
$products->addFieldToFilter('type_id', Array('eq' => $filter_by_type));
|
269 |
+
}
|
270 |
|
271 |
+
if ($filter_by_qty != null) {
|
272 |
+
$products->joinField('qty', 'cataloginventory/stock_item', 'qty', 'product_id=entity_id', '{{table}}.stock_id=1', 'left');
|
273 |
+
if ($filter_by_qty == 'gteq') {
|
274 |
+
$qty = $post_data['qty'];
|
275 |
+
$products->addFieldToFilter('qty', Array('gteq' => $qty));
|
276 |
+
} elseif ($filter_by_qty == 'lteq') {
|
277 |
+
$qty = $post_data['qty'];
|
278 |
+
$products->addFieldToFilter('qty', Array('lteq' => $qty));
|
279 |
+
} elseif ($filter_by_qty == 'btwn') {
|
280 |
+
$from_qty = $post_data['from_qty'];
|
281 |
+
$to_qty = $post_data['to_qty'];
|
282 |
+
$products->addFieldToFilter('qty', array('from' => $from_qty, 'to' => $to_qty));
|
|
|
283 |
}
|
284 |
+
}
|
285 |
|
286 |
+
foreach ($products as $product) {
|
287 |
+
$product_data = Mage::getModel('catalog/product')->load($product->getId());
|
288 |
+
$status = $product_data->getStatus();
|
289 |
+
$qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product_data)->getQty();
|
290 |
+
if ($status == 1) {
|
291 |
+
$status = 'Enabled';
|
292 |
+
} else {
|
293 |
+
$status = 'Disabled';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
294 |
}
|
295 |
+
if ($qty < 0 || $product_data->getIsInStock() == 0) {
|
296 |
+
$qty = 'Out of Stock';
|
297 |
+
}
|
298 |
+
$product_list[] = array(
|
299 |
+
'id' => $product->getId(),
|
300 |
+
'sku' => $product_data->getSku(),
|
301 |
+
'name' => $product_data->getName(),
|
302 |
+
'status' => $status,
|
303 |
+
'qty' => $qty,
|
304 |
+
'price' => Mage::helper('mobileassistant')->getPrice($product_data->getPrice(), $storeId),
|
305 |
+
'type' => $product->getTypeId(),
|
306 |
+
'image' => ($product_data->getImage()) ? Mage::helper('catalog/image')->init($product, 'image', $product_data->getImage())->resize(300, 330)->keepAspectRatio(true)->constrainOnly(true)->__toString() : 'N/A',
|
307 |
);
|
|
|
308 |
}
|
309 |
+
|
310 |
+
$productListResultArr = array('productlistdata' => $product_list);
|
311 |
+
$productListResult = Mage::helper('core')->jsonEncode($productListResultArr);
|
312 |
+
return Mage::app()->getResponse()->setBody($productListResult);
|
313 |
+
} catch (Exception $e) {
|
314 |
+
$product_list = array(
|
315 |
+
'status' => 'error',
|
316 |
+
'message' => $e->getMessage()
|
317 |
+
);
|
318 |
+
return Mage::app()->getResponse()->setBody(Mage::helper('core')->jsonEncode($product_list));
|
319 |
}
|
320 |
+
} else {
|
321 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
322 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
323 |
}
|
324 |
+
}
|
325 |
|
326 |
+
public function ChangeProductStatusAction() {
|
327 |
+
if (Mage::helper('mobileassistant')->isEnable()) {
|
328 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
329 |
+
$sessionId = $post_data['session'];
|
330 |
+
|
331 |
+
if (!$sessionId || $sessionId == NULL) {
|
332 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
333 |
+
return false;
|
334 |
+
}
|
335 |
+
try {
|
336 |
+
$storeId = $post_data['storeid'];
|
337 |
+
$productId = $post_data['productid'];
|
338 |
+
$current_status = $post_data['current_status'];
|
339 |
+
$new_status = $post_data['new_status'];
|
340 |
+
|
341 |
+
|
342 |
+
if ($current_status != $new_status && $new_status == 1) {
|
343 |
+
Mage::getModel('catalog/product_status')->updateProductStatus($productId, $storeId, Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
|
344 |
+
} elseif ($current_status != $new_status && $new_status == 2) {
|
345 |
+
Mage::getModel('catalog/product_status')->updateProductStatus($productId, $storeId, Mage_Catalog_Model_Product_Status::STATUS_DISABLED);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
346 |
}
|
347 |
+
$productResultArr = array('message' => 'Product has been successfully updated.');
|
348 |
+
$productDetailResult = Mage::helper('core')->jsonEncode($productResultArr);
|
349 |
+
return Mage::app()->getResponse()->setBody($productDetailResult);
|
350 |
+
} catch (Exception $e) {
|
351 |
+
$product_details = array(
|
352 |
+
'status' => 'error',
|
353 |
+
'message' => $e->getMessage()
|
354 |
+
);
|
355 |
+
return Mage::app()->getResponse()->setBody(Mage::helper('core')->jsonEncode($product_details));
|
356 |
}
|
357 |
+
} else {
|
358 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
359 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
360 |
}
|
361 |
+
}
|
362 |
|
363 |
+
}
|
app/code/local/Biztech/Mobileassistant/etc/config.xml
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
<config>
|
11 |
<modules>
|
12 |
<Biztech_Mobileassistant>
|
13 |
-
<version>0.2.
|
14 |
</Biztech_Mobileassistant>
|
15 |
</modules>
|
16 |
<frontend>
|
10 |
<config>
|
11 |
<modules>
|
12 |
<Biztech_Mobileassistant>
|
13 |
+
<version>0.2.1</version>
|
14 |
</Biztech_Mobileassistant>
|
15 |
</modules>
|
16 |
<frontend>
|
app/etc/modules/Biztech_Authentication.xml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category Biztech
|
5 |
+
* @package Biztech_Inventorysystementerprise
|
6 |
+
* @author ModuleCreator
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<modules>
|
12 |
+
<Biztech_Authentication>
|
13 |
+
<active>true</active>
|
14 |
+
<codePool>local</codePool>
|
15 |
+
</Biztech_Authentication>
|
16 |
+
</modules>
|
17 |
+
</config>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>magento_mobile_assistant_manager</name>
|
4 |
-
<version>0.2.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
@@ -25,12 +25,12 @@ To ensure smooth working of this extension you need to download this extension i
|
|
25 |
Application Download Link:
|
26 |
https://itunes.apple.com/us/app/magentomobilemanager/id695074519?mt=8&ign-mpt=uo%3D4
|
27 |
</description>
|
28 |
-
<notes>-
|
29 |
-
-Notification
|
30 |
<authors><author><name>Biztech</name><user>biztechcon</user><email>sales@biztechconsultancy.com</email></author></authors>
|
31 |
-
<date>
|
32 |
-
<time>
|
33 |
-
<contents><target name="
|
34 |
<compatible/>
|
35 |
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
36 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>magento_mobile_assistant_manager</name>
|
4 |
+
<version>0.2.1</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
25 |
Application Download Link:
|
26 |
https://itunes.apple.com/us/app/magentomobilemanager/id695074519?mt=8&ign-mpt=uo%3D4
|
27 |
</description>
|
28 |
+
<notes>-Provided theme change from Dashboard
|
29 |
+
-Enhanced Notification</notes>
|
30 |
<authors><author><name>Biztech</name><user>biztechcon</user><email>sales@biztechconsultancy.com</email></author></authors>
|
31 |
+
<date>2016-01-07</date>
|
32 |
+
<time>06:04:25</time>
|
33 |
+
<contents><target name="magelocal"><dir name="Biztech"><dir name="All"><dir name="Helper"><file name="Data.php" hash="e856726fd089e7f73ca7de450b696419"/></dir><dir name="Model"><file name="All.php" hash="a9aeeb9c6d7be9cf20414f405efc878d"/><dir name="Mysql4"><dir name="All"><file name="Collection.php" hash="a1909236183d126f38e628b85bb57e81"/></dir><file name="All.php" hash="f02542393eb26eadfb9b92d901d2ac12"/></dir><dir name="Source"><dir name="Updates"><file name="Type.php" hash="fa695bf4764c2d93c7436ed54bde89ba"/></dir></dir><file name="Status.php" hash="30a6f0da7d9d45e1082da532d5f8dabc"/><file name="Update.php" hash="83ceddbab4d621545b9c7c4bccdec7c0"/></dir><dir name="etc"><file name="config.xml" hash="8e46b7e9f47d565a9ff54fea30d034cc"/><file name="system.xml" hash="17262087dc933d934e09ac04cafb4c51"/></dir></dir><dir name="Authentication"><dir name="controllers"><file name="IndexController.php" hash="d5e9bcb327c8b4e41dde53948c16d329"/></dir><dir name="etc"><file name="config.xml" hash="d12ebc10e7781ff82323e54ff7713dae"/></dir></dir><dir name="Mobileassistant"><dir name="Block"><dir name="Config"><file name="Barcodeurl.php" hash="6dc63c4a9f259cb5fb854d39c9057eaa"/></dir></dir><dir name="Helper"><file name="Data.php" hash="48ab9efe6677c3066a245864174c4f4a"/></dir><dir name="Model"><dir name="Mobileassistant"><file name="Api.php" hash="4e8e1f556fc8f1d9e6c2f520a3a84e52"/></dir><file name="Mobileassistant.php" hash="68e160bf752ec8c1facc514389c00849"/><dir name="Mysql4"><dir name="Mobileassistant"><file name="Collection.php" hash="e9319365535ec2c42429ea1d9dbdc097"/></dir><file name="Mobileassistant.php" hash="62dc51f43aa6dff1dc762646b71cd600"/></dir><file name="Observer.php" hash="5962e33fc0b1048151144465958cdcbd"/></dir><dir name="controllers"><file name="CustomerController.php" hash="ec59b629f4d34dee388df2ebb4e36ca8"/><file name="DashboardController.php" hash="80032f6c96af8e7884a84441a2c9d3a4"/><file name="IndexController.php" hash="67599a94a41762b9624069f63d8dace0"/><file name="OrderController.php" hash="2f7265fdaec17ec0285e0ba6e281d632"/><file name="ProductController.php" hash="2b2c994a6a6e2a740a54eedaaadcebbf"/></dir><dir name="etc"><file name="api.xml" hash="7860c9fe0f121148eb2a3a498d1879b1"/><file name="config.xml" hash="65bac894f725fcd4886f5a95a3abb980"/><file name="system.xml" hash="0f75afd9196108912b700c6d07f44b68"/></dir><dir name="sql"><dir name="mobileassistant_setup"><file name="mysql4-install-0.1.0.php" hash="4f06ae1c3c5362b88fae1b1951a6b02a"/><file name="mysql4-upgrade-0.1.0-0.1.4.php" hash="172e9ecba3b5b385cef1c257b2af4bfa"/><file name="mysql4-upgrade-0.1.10-0.2.0.php" hash="dcb5288e356d3c36838446bbcadf6a2e"/><file name="mysql4-upgrade-0.1.4-0.1.5.php" hash="bd4adba7146d89fed6c548dd46a30a81"/><file name="mysql4-upgrade-0.1.5-0.1.6.php" hash="88ea6198ef876da921faebb1aa067485"/><file name="mysql4-upgrade-0.1.6-0.1.10.php" hash="88ea6198ef876da921faebb1aa067485"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Biztech_All.xml" hash="f4c3b9c029e56da8f09d7d71336c00f7"/><file name="Biztech_Mobileassistant.xml" hash="18d9cf7b8e516db899336adfd8210621"/><file name="Biztech_Authentication.xml" hash="149998e1599f43939f13cbc059123c8f"/></dir></target><target name="mage"><dir name="lib"><dir name="mobileassistant"><file name="pushcert.pem" hash="8199227be504f504a5dcc516025962f6"/></dir></dir><dir name="."><file name="MageMobAdmin.pdf" hash="a8f3d6830b1fc710be0c73de5f278bc2"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="mobileassistant"><dir name="system"><dir name="config"><file name="barcode.phtml" hash="1d24add024ce2297841ef826e345cad0"/></dir></dir></dir></dir></dir></dir></dir></target></contents>
|
34 |
<compatible/>
|
35 |
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
36 |
</package>
|