magento_mobile_assistant_manager - Version 0.2.1

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 CHANGED
@@ -34,56 +34,50 @@
34
  $feedData = array();
35
  $extensio_module = array();
36
  try{
37
- $xml = false;
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
- if($xml != false){
43
- $interests = $this->getInterests();
44
- if(!empty($interests[0])){
45
- $isInterestedInSelfUpgrades = in_array(Biztech_All_Model_Source_Updates_Type::TYPE_INSTALLED_UPDATE, $interests);
46
- $isInterestedInAllUpgrades = in_array(Biztech_All_Model_Source_Updates_Type::TYPE_UPDATE_RELEASE, $interests);
47
- $modules = Mage::getConfig()->getNode('modules')->children();
48
- $modulesArray = (array)$modules;
49
- foreach($xml->channel->item as $keys=>$extensions) {
50
- $types[] = (string) $extensions->update_notifications->type;
51
- $extensions_name = (string)$extensions->update_notifications->extensions;
52
 
53
- if((string)$extensions->update_notifications->date!=""&&(string)$extensions->update_notifications->extension_title!=""&&(string)$extensions->update_notifications->extension_content!=""&&(string)$extensions->update_notifications->product_url!=""){
54
- if(!$isInterestedInAllUpgrades){
55
- if ($this->isExtensionInstalled($extensions_name)) {
56
- $feedData[] = array(
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
- } else{
86
- return false;
 
 
 
 
 
 
 
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
- * @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.0</version>
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
- <all>
37
- <use>admin</use>
38
- <args>
39
- <module>Biztech_All</module>
40
- <frontName>all</frontName>
41
- </args>
42
- </all>
43
  </routers>
44
  </admin>
45
  <adminhtml>
46
- <!--<menu>
47
- <all module="all">
48
- <title>All</title>
49
- <sort_order>71</sort_order>
50
- <children>
51
- <items module="all">
52
- <title>Manage Items</title>
53
- <sort_order>0</sort_order>
54
- <action>all/adminhtml_all</action>
55
- </items>
56
- </children>
57
- </all>
58
- </menu> -->
59
- <acl>
60
- <resources>
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
- class Biztech_Mobileassistant_CustomerController extends Mage_Core_Controller_Front_Action
3
- {
4
- public function getCustomerListAction()
5
- {
6
- if(Mage::helper('mobileassistant')->isEnable()){
7
- $post_data = Mage::app()->getRequest()->getParams();
8
- $sessionId = $post_data['session'];
9
-
10
- if (!$sessionId || $sessionId == NULL) {
11
- echo $this->__("The Login has expired. Please try log in again.");
12
- return false;
13
- }
14
-
15
- $limit = $post_data['limit'];
16
- $offset = $post_data['offset'];
17
- $new_customers = $post_data['last_fetch_customer'];
18
- $is_refresh = $post_data['is_refresh'];
19
- $customers = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*')->setOrder('entity_id', 'desc');
20
-
21
- if($offset != null){
22
- $customers->addAttributeToFilter('entity_id', array('lt' => $offset));
23
- }
24
-
25
- if($is_refresh == 1){
26
- $last_fetch_customer = $post_data['last_fetch_customer'];
27
- $min_fetch_customer = $post_data['min_fetch_customer'];
28
- $last_updated = Mage::helper('mobileassistant')->getActualDate($post_data['last_updated']);
29
- $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."'");
30
- }
31
-
32
- $customers->getSelect()->limit($limit);
33
- foreach($customers as $customer){
34
- $billing_address = Mage::getModel('customer/address')->load($customer->getDefaultBilling());
35
- $shipping_address = Mage::getModel('customer/address')->load($customer->getDefaultShipping());
36
-
37
- $customer_list[] = array(
38
- 'entity_id' => $customer->getEntityId(),
39
- 'firstname' => $customer->getFirstname(),
40
- 'lastname' => $customer->getLastname(),
41
- 'email_id' => $customer->getEmail(),
42
- 'telephone' => $billing_address->getData('telephone'),
43
- 'billing_address_id' => $billing_address->getId(),
44
- 'shipping_address_id' => $shipping_address->getId()
45
- );
46
- }
47
- $updated_time = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
48
- $customerListResultArr = array('customerlistdata' => $customer_list,'updated_time' =>$updated_time);
49
- $customerListResult = Mage::helper('core')->jsonEncode($customerListResultArr);
50
- return Mage::app()->getResponse()->setBody($customerListResult);
51
- }else{
52
- $isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
53
- return Mage::app()->getResponse()->setBody($isEnable);
54
- }
55
- }
56
-
57
- public function getCustomerDetailAction()
58
- {
59
- if(Mage::helper('mobileassistant')->isEnable()){
60
- $post_data = Mage::app()->getRequest()->getParams();
61
- $sessionId = $post_data['session'];
62
-
63
- if (!$sessionId || $sessionId == NULL) {
64
- echo $this->__("The Login has expired. Please try log in again.");
65
- return false;
66
- }
67
- $customer_id = $post_data['customer_id'];
68
- $customerData = Mage::getModel('customer/customer')->load($customer_id);
69
-
70
-
71
- $basic_detail = array(
72
- 'entity_id' => $customerData->getEntityId(),
73
- 'firstname' => $customerData->getFirstname(),
74
- 'lastname' => $customerData->getLastname(),
75
- 'email' => $customerData->getEmail(),
76
- );
77
-
78
- foreach ($customerData->getAddresses() as $address) {
79
- $billing_type = 0;
80
- $shipping_type = 0;
81
- $billing_country_name = null;
82
-
83
- if($address->getCountryId()){
84
- $billing_country_name = Mage::getModel('directory/country')->loadByCode($address->getCountryId())->getName();
85
- }
86
-
87
- if ($address->getId()==$customerData->getDefaultBilling())
88
- $billing_type=1;
89
-
90
- if ($address->getId()==$customerData->getDefaultShipping())
91
- $shipping_type=1;
92
-
93
- $billing_address_detail[] = array(
94
- 'firstname' => $address->getFirstname(),
95
- 'lastname' => $address->getLastname(),
96
- 'street' => $address->getData('street'),
97
- 'city' => $address->getCity(),
98
- 'region_id' => $address->getRegionId() ? $address->getRegionId() : '',
99
- 'region' => $address->getRegion(),
100
- 'postcode' => $address->getPostcode(),
101
- 'country' => $billing_country_name,
102
- 'country_id' => $address->getCountryId(),
103
- 'telephone' => $address->getTelephone(),
104
- 'address_id' => $address->getId(),
105
- 'billing_type' => $billing_type,
106
- 'shipping_type' => $shipping_type
107
- );
108
- }
109
-
110
- $customer_detail = array(
111
- 'basic_details' => $basic_detail,
112
- 'address' => $billing_address_detail,
113
- );
114
- $order_detail = $this->_getCustomerOrderList($customer_id);
115
-
116
- $customerDetailResultArr = array('customerDetails' => $customer_detail,'customerOrderDetail' =>$order_detail);
117
- $customerDetailResult = Mage::helper('core')->jsonEncode($customerDetailResultArr);
118
- return Mage::app()->getResponse()->setBody($customerDetailResult);
119
- }else{
120
- $isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
121
- return Mage::app()->getResponse()->setBody($isEnable);
122
- }
123
- }
124
-
125
- protected function _getCustomerOrderList($customer_id)
126
- {
127
- $orderCollection = Mage::getResourceModel('sales/order_grid_collection')->addFieldToFilter('customer_id',Array('eq'=>$customer_id))->setOrder('entity_id', 'desc');
128
- $limit = 5;
129
- $orderCollection->getSelect()->limit($limit);
130
-
131
- foreach($orderCollection as $order){
132
-
133
- $orderListData[] = array(
134
- 'entity_id' => $order->getEntityId(),
135
- 'increment_id' => $order->getIncrementId(),
136
- 'store_id' => $order->getStoreId(),
137
- 'customer_name' => $order->getBillingName(),
138
- 'status' => $order->getStatus(),
139
- 'order_date' => date('Y-m-d H:i:s', strtotime($order->getCreatedAt())),
140
- 'grand_total' => Mage::helper('mobileassistant')->getPrice($order->getGrandTotal(),$order->getStoreId(),$order->getOrderCurrencyCode()),
141
- 'toal_qty' => Mage::getModel('sales/order')->load($order->getEntityId())->getTotalQtyOrdered()
142
- );
143
- }
144
- return $orderListData;
145
- }
146
-
147
- public function getFilterCustomerListAction()
148
- {
149
- if(Mage::helper('mobileassistant')->isEnable()){
150
- $post_data = Mage::app()->getRequest()->getParams();
151
- $sessionId = $post_data['session'];
152
-
153
- if (!$sessionId || $sessionId == NULL) {
154
- echo $this->__("The Login has expired. Please try log in again.");
155
- return false;
156
- }
157
- $search = $post_data['search_content'];
158
- $customers = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*')->setOrder('entity_id', 'desc');
159
-
160
- if($search != null)
161
- {
162
- $customers->addAttributeToFilter(array(
163
- array(
164
- 'attribute' => 'firstname',
165
- 'like' => '%'.$search.'%'
166
- ),
167
- array(
168
- 'attribute' => 'lastname',
169
- 'like' => '%'.$search.'%'
170
- ),
171
- array(
172
- 'attribute' => 'email',
173
- 'like' => '%'.$search.'%'
174
- )
175
- ));
176
- }
177
-
178
-
179
- foreach($customers as $customer){
180
- $billing_address = Mage::getModel('customer/address')->load($customer->getDefaultBilling());
181
- $shipping_address = Mage::getModel('customer/address')->load($customer->getDefaultShipping());
182
-
183
- $customer_list[] = array(
184
- 'entity_id' => $customer->getEntityId(),
185
- 'firstname' => $customer->getFirstname(),
186
- 'lastname' => $customer->getLastname(),
187
- 'email_id' => $customer->getEmail(),
188
- 'telephone' => $billing_address->getData('telephone'),
189
- 'billing_address_id' => $billing_address->getId(),
190
- 'shipping_address_id' => $shipping_address->getId(),
191
- );
192
- }
193
- $customerListResultArr = array('customerlistdata' => $customer_list);
194
- $customerListResult = Mage::helper('core')->jsonEncode($customerListResultArr);
195
- return Mage::app()->getResponse()->setBody($customerListResult);
196
- }else{
197
- $isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
198
- return Mage::app()->getResponse()->setBody($isEnable);
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
- class Biztech_Mobileassistant_DashboardController extends Mage_Core_Controller_Front_Action
3
- {
4
- public function dashboardAction()
5
- {
6
- if(Mage::helper('mobileassistant')->isEnable()){
7
- $post_data = Mage::app()->getRequest()->getParams();
8
- $sessionId = $post_data['session'];
9
-
10
- if (!$sessionId || $sessionId == NULL) {
11
- echo $this->__("The Login has expired. Please try log in again.");
12
- return false;
13
- }
14
-
15
- $storeId = $post_data['storeid'];
16
- $type_id = $post_data['days_for_dashboard'];
17
-
18
- $now = Mage::getModel('core/date')->timestamp(time());
19
- $end_date = date('Y-m-d 23:59:59', $now);
20
- $start_date = '';
21
- $orderCollection = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id',Array('eq'=>$storeId))->addFieldToFilter('status',Array('eq'=>'complete'))->setOrder('entity_id', 'desc');
22
- if($type_id == 7){
23
- $start_date = date('Y-m-d 00:00:00', strtotime('-6 days'));
24
- }elseif($type_id == 30){
25
- $start_date = date('Y-m-d 00:00:00', strtotime('-29 days'));
26
- }elseif($type_id == 90){
27
- $start_date = date('Y-m-d 00:00:00', strtotime('-89 days'));
28
- } else if ($type_id == 24){
29
- $end_date = date("Y-m-d H:m:s");
30
- $start_date = date("Y-m-d H:m:s", strtotime('-24 hours', time()));
31
- $timezoneLocal = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
32
-
33
- list ($dateStart, $dateEnd) = Mage::getResourceModel('reports/order_collection')
34
- ->getDateRange('24h', '', '', true);
35
-
36
- $dateStart->setTimezone($timezoneLocal);
37
- $dateEnd->setTimezone($timezoneLocal);
38
-
39
- $dates = array();
40
-
41
- while($dateStart->compare($dateEnd) < 0){
42
- $d = $dateStart->toString('yyyy-MM-dd HH:mm:ss');
43
- $dateStart->addHour(1);
44
- $dates[] = $d;
45
- }
46
-
47
- $start_date = $dates[0];
48
- $end_date = $dates[count($dates)-1];
49
-
50
- $orderCollection->addAttributeToFilter('created_at', array('from'=>$start_date, 'to'=>$end_date));
51
- $total_count = count($orderCollection);
52
- }
53
-
54
- if ($type_id!='year'){
55
- if ($type_id=='month'){
56
- $end_date = date("Y-m-d H:m:s");
57
- $start_date = date('Y-m-01 H:m:s');
58
- }
59
-
60
- if ($type_id!=24){
61
- $orderCollection->addAttributeToFilter('created_at', array('from'=>$start_date, 'to'=>$end_date));
62
- $total_count = count($orderCollection);
63
- $dates = $this->getDatesFromRange($start_date, $end_date);
64
- }
65
- $count = 0;
66
- foreach($dates as $date)
67
- {
68
- $orderCollectionByDate = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id',Array('eq'=>$storeId))->addFieldToFilter('status',Array('eq'=>'complete'))->setOrder('entity_id', 'desc');
69
-
70
- if ($type_id == 24){
71
- $dateStart = $dates[$count];
72
- $dateEnd = $dates[$count+1];
73
- }else{
74
-
75
- $dateStart = date('Y-m-d 00:00:00',strtotime($date));
76
- $dateEnd = date('Y-m-d 23:59:59',strtotime($date));
77
- }
78
- $orderByDate = $orderCollectionByDate->addAttributeToFilter('created_at', array('from'=>$dateStart, 'to'=>$dateEnd));
79
- $orderByDate->getSelect()->columns('SUM(grand_total) AS grand_total_sum');
80
- $orderByDate->getSelect()->group(array('store_id'));
81
- $orderdata= $orderByDate->getData();
82
- if(count($orderByDate) == 0)
83
- {
84
- if ($type_id==24){
85
- $orderTotalByDate[date("Y-m-d H:i",strtotime($date))] = 0;
86
- }else if ($type_id=='month'){
87
- $orderTotalByDate[date('d',strtotime($date))] = 0;
88
- }else{
89
- $orderTotalByDate[$date] = 0;
90
- }
91
- }
92
- else{
93
- if ($type_id==24){
94
- $ordersByDate[date("Y-m-d H:i",strtotime($date))][] = $orderdata[0]['grand_total_sum'];
95
- $orderTotalByDate[date("Y-m-d H:i",strtotime($date))] = array_sum($ordersByDate[date("Y-m-d H:i",strtotime($date))]);
96
- }else if ($type_id=='month'){
97
- $ordersByDate[date('d',strtotime($date))][] = $orderdata[0]['grand_total_sum'];
98
- $orderTotalByDate[date('d',strtotime($date))] = array_sum($ordersByDate[date('d',strtotime($date))]);
99
- }else{
100
- $ordersByDate[$date][] = $orderdata[0]['grand_total_sum'];
101
- $orderTotalByDate[$date] = array_sum($ordersByDate[$date]);
102
- }
103
-
104
-
105
- }
106
-
107
- $count++;
108
- }
109
- }else{
110
- $end_date = date ('Y-m-d');
111
- $start_date = date ('Y-01-01');
112
- $orderCollection->addAttributeToFilter('created_at', array('from'=>$start_date, 'to'=>$end_date));
113
- $total_count = count($orderCollection);
114
- $months = $this->get_months($start_date, $end_date);
115
- $current_year = date("Y");
116
- foreach ($months as $month){
117
- $first_day = $this->firstDay($month,$current_year);
118
- $ordersByDate = array();
119
- if ($month==date('F'))
120
- $last_day = date ('Y-m-d');
121
- else
122
- $last_day = $this->lastday($month,$current_year);
123
-
124
- $dates = $this->getDatesFromRange($first_day, $last_day);
125
-
126
- foreach($dates as $date)
127
- {
128
- $orderCollectionByDate = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id',Array('eq'=>$storeId))->addFieldToFilter('status',Array('eq'=>'complete'))->setOrder('entity_id', 'desc');
129
- $dateStart = date('Y-m-d 00:00:00',strtotime($date));
130
- $dateEnd = date('Y-m-d 23:59:59',strtotime($date));
131
- $orderByDate = $orderCollectionByDate->addAttributeToFilter('created_at', array('from'=>$dateStart, 'to'=>$dateEnd));
132
- $orderByDate->getSelect()->columns('SUM(grand_total) AS grand_total_sum');
133
- $orderByDate->getSelect()->group(array('store_id'));
134
- $orderdata= $orderByDate->getData();
135
- $ordersByDate[] = $orderdata[0]['grand_total_sum'];
136
- }
137
-
138
- $orderTotalByDate[$month] = array_sum($ordersByDate);
139
- }
140
- }
141
-
142
- $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
143
-
144
- $orderGrandTotal = strip_tags(Mage::app()->getLocale()->currency($baseCurrencyCode)->toCurrency(array_sum($orderTotalByDate)));
145
- $lifeTimeSales = strip_tags(Mage::app()->getLocale()->currency($baseCurrencyCode)->toCurrency(round(Mage::getResourceModel('reports/order_collection')->addFieldToFilter('store_id', $storeId)->calculateSales()->load()->getFirstItem()->getLifetime(),2)));
146
- $averageOrder = strip_tags(Mage::app()->getLocale()->currency($baseCurrencyCode)->toCurrency(round(Mage::getResourceModel('reports/order_collection')->addFieldToFilter('store_id', $storeId)->calculateSales()->load()->getFirstItem()->getAverage(),2)));
147
-
148
- $orderTotalResultArr = array('dashboard_result' =>array('ordertotalbydate' => $orderTotalByDate,'ordergrandtotal' => $orderGrandTotal,'totalordercount' => $total_count,'lifetimesales' => $lifeTimeSales,'averageorder' => $averageOrder));
149
- $orderDashboardResult = Mage::helper('core')->jsonEncode($orderTotalResultArr);
150
- return Mage::app()->getResponse()->setBody($orderDashboardResult);
151
- }else{
152
- $isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
153
- return Mage::app()->getResponse()->setBody($isEnable);
154
- }
155
- }
156
-
157
- public function getDatesFromRange($start_date, $end_date)
158
- {
159
- $date_from = strtotime(date('Y-m-d', strtotime($start_date)));
160
- $date_to = strtotime(date('Y-m-d', strtotime($end_date)));
161
-
162
- for ($i=$date_from; $i<=$date_to; $i+=86400) {
163
- $dates[] = date("Y-m-d", $i);
164
- }
165
- return $dates;
166
- }
167
-
168
- public function getNewestCustomerAction()
169
- {
170
- if(Mage::helper('mobileassistant')->isEnable()){
171
- $post_data = Mage::app()->getRequest()->getParams();
172
- $sessionId = $post_data['session'];
173
-
174
- if (!$sessionId || $sessionId == NULL) {
175
- echo $this->__("The Login has expired. Please try log in again.");
176
- return false;
177
- }
178
-
179
- $storeId =$post_data['storeid'];
180
- $baseCurrencyCode = (string) Mage::app()->getStore($storeId)->getBaseCurrencyCode();
181
-
182
- $collection = Mage::getResourceModel('reports/customer_collection')->addCustomerName();
183
- $storeFilter = 0;
184
- if ($storeId) {
185
- $collection->addAttributeToFilter('store_id', $storeId);
186
- $storeFilter = 1;
187
- }
188
- $collection->addOrdersStatistics($storeFilter)->orderByCustomerRegistration();
189
-
190
- foreach($collection as $_collection)
191
- {
192
- $newestCustomer[] = array(
193
- 'name' => $_collection->getName(),
194
- 'email' => $_collection->getEmail(),
195
- 'orders_count' => $_collection->getOrdersCount(),
196
- 'average_order_amount'=>Mage::app()->getLocale()->currency($baseCurrencyCode)->toCurrency(Mage::helper('mobileassistant')->getPriceFormat($_collection->getOrdersAvgAmount())),
197
- 'total_order_amount' => Mage::app()->getLocale()->currency($baseCurrencyCode)->toCurrency(Mage::helper('mobileassistant')->getPriceFormat($_collection->getOrdersSumAmount()))
198
- );
199
- }
200
-
201
- $NewestCustomerResult = Mage::helper('core')->jsonEncode($newestCustomer);
202
- return Mage::app()->getResponse()->setBody($NewestCustomerResult);
203
- }else{
204
- $isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
205
- return Mage::app()->getResponse()->setBody($isEnable);
206
- }
207
- }
208
-
209
- function get_months($date1, $date2) {
210
- $time1 = strtotime($date1);
211
- $time2 = strtotime($date2);
212
- $my = date('mY', $time2);
213
- $months = array();
214
- $f = '';
215
-
216
- while($time1 < $time2) {
217
- $time1 = strtotime((date('Y-m-d', $time1).' +15days'));
218
-
219
- if(date('m', $time1) != $f) {
220
- $f = date('m', $time1);
221
-
222
- if(date('mY', $time1) != $my && ($time1 < $time2))
223
- $months[] = date('m', $time1);
224
- }
225
-
226
- }
227
-
228
- $months[] = date('m', $time2);
229
- return $months;
230
- }
231
-
232
- function lastday($month = '', $year = '') {
233
- if (empty($month)) {
234
- $month = date('m');
235
- }
236
- if (empty($year)) {
237
- $year = date('Y');
238
- }
239
- $result = strtotime("{$year}-{$month}-01");
240
- $result = strtotime('-1 day', strtotime('+1 month', $result));
241
- return date('Y-m-d', $result);
242
- }
243
-
244
- function firstDay($month = '', $year = '') {
245
- if (empty($month)) {
246
- $month = date('m');
247
- }
248
- if (empty($year)) {
249
- $year = date('Y');
250
- }
251
- $result = strtotime("{$year}-{$month}-01");
252
- return date('Y-m-d', $result);
253
- }
254
-
255
- protected function getorderetails($storeId,$type_id,$tab = null,$source = null,$limit = null)
256
- {
257
- $orderTotalByDate = array();
258
- $now = Mage::getModel('core/date')->timestamp(time());
259
- $end_date = date('Y-m-d 23:59:59', $now);
260
- $start_date = '';
261
-
262
- if($source == 'widget')
263
- {
264
- $orderCollection = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id',Array('eq'=>$storeId))->setOrder('entity_id', 'desc');
265
-
266
- }else{
267
- $orderCollection = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id',Array('eq'=>$storeId))->addFieldToFilter('status',Array('eq'=>'complete'))->setOrder('entity_id', 'desc');
268
- }
269
-
270
-
271
-
272
- if($type_id == 7){
273
- $start_date = date('Y-m-d 00:00:00', strtotime('-6 days'));
274
- }elseif($type_id == 30){
275
- $start_date = date('Y-m-d 00:00:00', strtotime('-29 days'));
276
- }elseif($type_id == 90){
277
- $start_date = date('Y-m-d 00:00:00', strtotime('-89 days'));
278
- } else if ($type_id == 24){
279
- $end_date = date("Y-m-d H:m:s");
280
- $start_date = date("Y-m-d H:m:s", strtotime('-24 hours', time()));
281
- $timezoneLocal = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
282
-
283
- list ($dateStart, $dateEnd) = Mage::getResourceModel('reports/order_collection')
284
- ->getDateRange('24h', '', '', true);
285
-
286
- $dateStart->setTimezone($timezoneLocal);
287
- $dateEnd->setTimezone($timezoneLocal);
288
-
289
- $dates = array();
290
-
291
- while($dateStart->compare($dateEnd) < 0){
292
- $d = $dateStart->toString('yyyy-MM-dd HH:mm:ss');
293
- $dateStart->addHour(1);
294
- $dates[] = $d;
295
- }
296
-
297
- $start_date = $dates[0];
298
- $end_date = $dates[count($dates)-1];
299
-
300
- $orderCollection->addAttributeToFilter('created_at', array('from'=>$start_date, 'to'=>$end_date));
301
- $total_count = count($orderCollection);
302
- }
303
-
304
- if ($type_id!='year'){
305
- if ($type_id=='month'){
306
- $end_date = date("Y-m-d H:m:s");
307
- $start_date = date('Y-m-01 H:m:s');
308
- }
309
-
310
- if ($type_id!=24){
311
- $orderCollection->addAttributeToFilter('created_at', array('from'=>$start_date, 'to'=>$end_date));
312
- $total_count = count($orderCollection);
313
- $dates = $this->getDatesFromRange($start_date, $end_date);
314
- }
315
- $count = 0;
316
- foreach($dates as $date)
317
- {
318
- if($source == 'widget')
319
- {
320
- $orderCollectionByDate = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id',Array('eq'=>$storeId))->setOrder('entity_id', 'desc');
321
-
322
- }else{
323
- $orderCollectionByDate = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id',Array('eq'=>$storeId))->addFieldToFilter('status',Array('eq'=>'complete'))->setOrder('entity_id', 'desc');
324
- }
325
-
326
-
327
- if ($type_id == 24){
328
- $dateStart = $dates[$count];
329
- $dateEnd = $dates[$count+1];
330
- }else{
331
-
332
- $dateStart = date('Y-m-d 00:00:00',strtotime($date));
333
- $dateEnd = date('Y-m-d 23:59:59',strtotime($date));
334
- }
335
- $orderByDate = $orderCollectionByDate->addAttributeToFilter('created_at', array('from'=>$dateStart, 'to'=>$dateEnd));
336
- $orderByDate->getSelect()->columns('SUM(grand_total) AS grand_total_sum');
337
- $orderByDate->getSelect()->group(array('store_id'));
338
- $orderdata= $orderByDate->getData();
339
- if(count($orderByDate) == 0)
340
- {
341
- if ($type_id==24){
342
- $orderTotalByDate[date("Y-m-d H:i",strtotime($date))] = 0;
343
- }else if ($type_id=='month'){
344
- $orderTotalByDate[date('d',strtotime($date))] = 0;
345
- }else{
346
- $orderTotalByDate[$date] = 0;
347
- }
348
- }
349
- else{
350
- if ($type_id==24){
351
- $ordersByDate[date("Y-m-d H:i",strtotime($date))][] = $orderdata[0]['grand_total_sum'];
352
- $orderTotalByDate[date("Y-m-d H:i",strtotime($date))] = array_sum($ordersByDate[date("Y-m-d H:i",strtotime($date))]);
353
- }else if ($type_id=='month'){
354
- $ordersByDate[date('d',strtotime($date))][] = $orderdata[0]['grand_total_sum'];
355
- $orderTotalByDate[date('d',strtotime($date))] = array_sum($ordersByDate[date('d',strtotime($date))]);
356
- }else{
357
- $ordersByDate[$date][] = $orderdata[0]['grand_total_sum'];
358
- $orderTotalByDate[$date] = array_sum($ordersByDate[$date]);
359
- }
360
-
361
-
362
- }
363
-
364
- $count++;
365
- }
366
- }else{
367
- $end_date = date ('Y-m-d');
368
- $start_date = date ('Y-01-01');
369
- $orderCollection->addAttributeToFilter('created_at', array('from'=>$start_date, 'to'=>$end_date));
370
- $total_count = count($orderCollection);
371
- $months = $this->get_months($start_date, $end_date);
372
- $current_year = date("Y");
373
- foreach ($months as $month){
374
- $first_day = $this->firstDay($month,$current_year);
375
- $ordersByDate = array();
376
- if ($month==date('F'))
377
- $last_day = date ('Y-m-d');
378
- else
379
- $last_day = $this->lastday($month,$current_year);
380
-
381
- $dates = $this->getDatesFromRange($first_day, $last_day);
382
-
383
- foreach($dates as $date)
384
- {
385
-
386
- if($source == 'widget')
387
- {
388
- $orderCollectionByDate = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id',Array('eq'=>$storeId))->setOrder('entity_id', 'desc');
389
- }else{
390
- $orderCollectionByDate = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id',Array('eq'=>$storeId))->addFieldToFilter('status',Array('eq'=>'complete'))->setOrder('entity_id', 'desc');
391
- }
392
- $dateStart = date('Y-m-d 00:00:00',strtotime($date));
393
- $dateEnd = date('Y-m-d 23:59:59',strtotime($date));
394
- $orderByDate = $orderCollectionByDate->addAttributeToFilter('created_at', array('from'=>$dateStart, 'to'=>$dateEnd));
395
- $orderByDate->getSelect()->columns('SUM(grand_total) AS grand_total_sum');
396
- $orderByDate->getSelect()->group(array('store_id'));
397
- $orderdata= $orderByDate->getData();
398
- $ordersByDate[] = $orderdata[0]['grand_total_sum'];
399
- }
400
-
401
- $orderTotalByDate[$month] = array_sum($ordersByDate);
402
- }
403
- }
404
-
405
-
406
- $result = array('ordertotalbydate' => $orderTotalByDate, 'ordertotalcount' => $total_count);
407
-
408
- $orderCollection->getSelect()->limit($limit);
409
-
410
- if($tab == 'order')
411
- {
412
-
413
- foreach($orderCollection->getData() as $_order)
414
- {
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
- {
439
- $collection = Mage::getResourceModel('reports/customer_collection')->addCustomerName();
440
- $storeFilter = 0;
441
- if ($storeId) {
442
- $collection->addAttributeToFilter('store_id', $storeId);
443
- $storeFilter = 1;
444
- }
445
- $collection->addOrdersStatistics($storeFilter)->orderByCustomerRegistration();
446
- $total = $collection->getSize();
447
-
448
- if(isset($type_id) && $type_id != null)
449
- {
450
- if($type_id == 7){
451
- $start_date = date('Y-m-d 00:00:00', strtotime('-6 days'));
452
- }elseif($type_id == 30){
453
- $start_date = date('Y-m-d 00:00:00', strtotime('-29 days'));
454
- }elseif($type_id == 90){
455
- $start_date = date('Y-m-d 00:00:00', strtotime('-89 days'));
456
- } else if ($type_id == 24){
457
- $end_date = date("Y-m-d H:m:s");
458
- $start_date = date("Y-m-d H:m:s", strtotime('-24 hours', time()));
459
- $timezoneLocal = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
460
-
461
- list ($dateStart, $dateEnd) = Mage::getResourceModel('reports/order_collection')
462
- ->getDateRange('24h', '', '', true);
463
-
464
- $dateStart->setTimezone($timezoneLocal);
465
- $dateEnd->setTimezone($timezoneLocal);
466
-
467
- $dates = array();
468
-
469
- while($dateStart->compare($dateEnd) < 0){
470
- $d = $dateStart->toString('yyyy-MM-dd HH:mm:ss');
471
- $dateStart->addHour(1);
472
- $dates[] = $d;
473
- }
474
-
475
- $start_date = $dates[0];
476
- $end_date = $dates[count($dates)-1];
477
-
478
- $collection->addAttributeToFilter('created_at', array('from'=>$start_date, 'to'=>$end_date));
479
- $total_count = count($collection);
480
- }
481
-
482
- if ($type_id!='year'){
483
- if ($type_id=='month'){
484
- $end_date = date("Y-m-d H:m:s");
485
- $start_date = date('Y-m-01 H:m:s');
486
- }
487
-
488
- if ($type_id!=24){
489
- $collection->addAttributeToFilter('created_at', array('from'=>$start_date, 'to'=>$end_date));
490
- $total_count = count($collection);
491
- $dates = $this->getDatesFromRange($start_date, $end_date);
492
- }
493
- }else{
494
- $end_date = date ('Y-m-d');
495
- $start_date = date ('Y-01-01');
496
- $collection->addAttributeToFilter('created_at', array('from'=>$start_date, 'to'=>$end_date));
497
- $total_count = count($collection);
498
- }
499
- }
500
- if($tab == 'customer' && isset($limit)){
501
- $collection->clear();
502
- $collection->getSelect()->limit($limit);
503
- }
504
- $resultWidget = array('customercollection' => $collection,'customertotal' => $total_count);
505
- return $resultWidget;
506
- }
507
-
508
- protected function getlowstockproducts($tab,$storeId,$limit)
509
- {
510
-
511
- $products = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($storeId)->setOrder('entity_id', 'desc')
512
- ->joinField(
513
- 'is_in_stock',
514
- 'cataloginventory/stock_item',
515
- 'is_in_stock',
516
- 'product_id=entity_id',
517
- '{{table}}.stock_id=1',
518
- 'left'
519
- )->addAttributeToFilter('is_in_stock', array('eq' => 0));
520
-
521
- $productResultArr['totalproducts'] = $products->getSize();
522
-
523
- $products->getSelect()->limit($limit);
524
- if($tab == 'product')
525
- {
526
- foreach($products as $product)
527
- {
528
- $product_data = Mage::getModel('catalog/product')->load($product->getId());
529
- $status = $product_data->getStatus();
530
- $qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product_data)->getQty();
531
- if($status == 1){$status = 'Enabled';}else{$status = 'Disabled';}
532
- $product_list[] = array(
533
- 'id' => $product->getId(),
534
- 'sku' => $product_data->getSku(),
535
- 'name' => $product_data->getName(),
536
- 'status' => $status,
537
- 'qty' => $qty,
538
- 'price' => Mage::helper('mobileassistant')->getPrice($product_data->getPrice(),$storeId),
539
- 'image' => ($product_data->getImage())?Mage::helper('catalog/image')->init($product, 'image',$product_data->getImage())->resize(300,330)->keepAspectRatio(true)->constrainOnly(true)->__toString():'N/A',
540
- 'type' => $product->getTypeId()
541
- );
542
- }
543
- }
544
-
545
- $productResultArr['productlistdata'] = $product_list;
546
-
547
- return $productResultArr;
548
- }
549
-
550
- public function getwidgetdetailsAction()
551
- {
552
- if(Mage::helper('mobileassistant')->isEnable()){
553
- $post_data = Mage::app()->getRequest()->getParams();
554
- $sessionId = $post_data['session'];
555
- if (!$sessionId || $sessionId == NULL) {
556
- echo $this->__("The Login has expired. Please try log in again.");
557
- return false;
558
- }
559
-
560
- $storeId = $post_data['storeid'];
561
- $type_id = $post_data['days_for_dashboard'];
562
- $tab = $post_data['tab'];
563
- $limit = $post_data['limit'];
564
- $source = 'widget';
565
-
566
- $baseCurrencyCode = (string) Mage::app()->getStore($storeId)->getBaseCurrencyCode();
567
-
568
- /*order detail*/
569
- $orderDetails = $this->getorderetails($storeId,$type_id,$tab,$source,$limit);
570
- $orderTotalByDate = $orderDetails['ordertotalbydate'];
571
- $orderGrandTotal = strip_tags(Mage::app()->getLocale()->currency($baseCurrencyCode)->toCurrency(array_sum($orderTotalByDate)));
572
-
573
-
574
- $widgetResultArr['widget_order'] = array('ordergrandtotal' => $orderGrandTotal,'totalordercount' => $orderDetails['ordertotalcount'],'ordercollection' => $orderDetails['ordercollection']);
575
-
576
- /*customer detail*/
577
- $customerDetails = $this->getcustomerdetails($storeId,$type_id,$limit,$tab);
578
- $customertotal = $customerDetails['customertotal'];
579
-
580
- if($tab == 'customer')
581
- {
582
-
583
- $collection = $customerDetails['customercollection'];
584
-
585
- foreach($collection as $_collection)
586
- {
587
- $newestCustomer[] = array(
588
- 'entity_id' => $_collection->getEntityId(),
589
- 'name' => $_collection->getName(),
590
- 'email' => $_collection->getEmail(),
591
- );
592
- }
593
- }
594
-
595
- $widgetResultArr['widget_customer'] = array('totalcustomer' => $customertotal,'customers_detail' => $newestCustomer);
596
-
597
- /*products detail*/
598
- $productDetails = $this->getlowstockproducts($tab,$storeId,$limit);
599
- $totalProduct = $productDetails['totalproducts'];
600
- $productdata = $productDetails['productlistdata'];
601
-
602
- $widgetResultArr['widget_product'] = array('totalproduct' => $totalProduct,'product_detail' => $productdata);
603
-
604
- $widgetResult = Mage::helper('core')->jsonEncode($widgetResultArr);
605
- return Mage::app()->getResponse()->setBody($widgetResult);
606
-
607
- }else{
608
- $isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
609
- return Mage::app()->getResponse()->setBody($isEnable);
610
- }
611
- }
612
-
613
- public function sendfeedbackAction()
614
- {
615
- if(Mage::helper('mobileassistant')->isEnable()){
616
- $post_data = Mage::app()->getRequest()->getParams();
617
- $sessionId = $post_data['session'];
618
- if (!$sessionId || $sessionId == NULL) {
619
- echo $this->__("The Login has expired. Please try log in again.");
620
- return false;
621
- }
622
-
623
- $to = "support@biztechconsultancy.com";
624
- $subject = "Feedback For MobileAssistant";
625
-
626
- $message = "<div>
627
- <p>Hi there. This is just test email.</p>
628
- <p>Below is ratings given by user: ".$post_data['nickname']."</p>
629
- <p>Ratings: ".$post_data['rating']."</p>"." \r\n"."
630
- <p>Comments: ".$post_data['comment']."</p>"." \r\n"."
631
- <p>Please find application link:</p>"." \r\n"."
632
- <a href='".Mage::getBaseUrl()."'>Click here</a>"." \r\n"."
633
- </div>";
634
-
635
- $header = "From:". Mage::getStoreConfig('trans_email/ident_general/email')." \r\n";
636
- $header .= "MIME-Version: 1.0\r\n";
637
- $header .= "Content-type: text/html\r\n";
638
- $retval = mail($to,$subject,$message,$header);
639
- if( $retval == true )
640
- {
641
- $result = array('status' => true, 'message' => 'Message sent successfully');
642
- }
643
- else
644
- {
645
- $result = array('status' => false, 'message' => 'Message could not be sent');
646
- }
647
-
648
- $NewestCustomerResult = Mage::helper('core')->jsonEncode($result);
649
- return Mage::app()->getResponse()->setBody($NewestCustomerResult);
650
- }else{
651
- $isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
652
- return Mage::app()->getResponse()->setBody($isEnable);
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
- class Biztech_Mobileassistant_OrderController extends Mage_Core_Controller_Front_Action
3
- {
4
- public function getOrderListAction()
5
- {
6
- if(Mage::helper('mobileassistant')->isEnable()){
7
- $post_data = Mage::app()->getRequest()->getParams();
8
- $sessionId = $post_data['session'];
9
-
10
- if (!$sessionId || $sessionId == NULL) {
11
- echo $this->__("The Login has expired. Please try log in again.");
12
- return false;
13
- }
14
-
15
- $limit = $post_data['limit'];
16
- $storeId = $post_data['storeid'];
17
- $offset = $post_data['offset'];
18
- $is_refresh = $post_data['is_refresh'];
19
- $source = $post_data['source'];
20
-
21
- $orderCollection = Mage::getResourceModel('sales/order_grid_collection')->addFieldToFilter('store_id',Array('eq'=>$storeId))->setOrder('entity_id', 'desc');
22
- if($offset != null){
23
- $orderCollection->addAttributeToFilter('entity_id', array('lt' => $offset));
24
- }
25
- if($is_refresh == 1){
26
- $last_fetch_order = $post_data['last_fetch_order'];
27
- $min_fetch_order = $post_data['min_fetch_order'];
28
- $last_updated = Mage::helper('mobileassistant')->getActualDate($post_data['last_updated']);
29
-
30
- $orderCollection->getSelect()->where("(entity_id BETWEEN '".$min_fetch_order."'AND '".$last_fetch_order ."' AND updated_at > '".$last_updated."') OR entity_id >'".$last_fetch_order."'");
31
- }
32
-
33
- $orderCollection->getSelect()->limit($limit);
34
-
35
- foreach($orderCollection as $order){
36
- if($source == 'dashboard')
37
- {
38
- $grand_total = Mage::helper('mobileassistant')->getPrice($order->getBaseGrandTotal(),$order->getStoreId(),$order->getBaseCurrencyCode());
39
- }else{
40
- $grand_total = Mage::helper('mobileassistant')->getPrice($order->getGrandTotal(),$order->getStoreId(),$order->getOrderCurrencyCode());
41
- }
42
-
43
- $orderListData[] = array(
44
- 'entity_id' => $order->getEntityId(),
45
- 'increment_id' => $order->getIncrementId(),
46
- 'store_id' => $order->getStoreId(),
47
- 'customer_name' => $order->getBillingName(),
48
- 'status' => $order->getStatus(),
49
- 'order_date' => Mage::helper('mobileassistant')->getActualOrderDate($order->getCreatedAt()),
50
- 'grand_total' => $grand_total,
51
- 'toal_qty' => Mage::getModel('sales/order')->load($order->getEntityId())->getTotalQtyOrdered(),
52
- 'total_items' => count($order->getAllItems())
53
- );
54
- }
55
-
56
- $updated_time = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
57
- $orderListResultArr = array('orderlistdata' => $orderListData,'updated_time' =>$updated_time);
58
- $orderListResult = Mage::helper('core')->jsonEncode($orderListResultArr);
59
- return Mage::app()->getResponse()->setBody($orderListResult);
60
- }else{
61
- $isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
62
- return Mage::app()->getResponse()->setBody($isEnable);
63
- }
64
- }
65
-
66
- public function getFilterOrderListAction()
67
- {
68
- if(Mage::helper('mobileassistant')->isEnable()){
69
- $post_data = Mage::app()->getRequest()->getParams();
70
- $storeId = $post_data['storeid'];
71
- $sessionId = $post_data['session'];
72
-
73
- if (!$sessionId || $sessionId == NULL) {
74
- echo $this->__("The Login has expired. Please try log in again.");
75
- return false;
76
- }
77
- $filter_by_date = $post_data['filter_by_date'];
78
- $filter_by_status = $post_data['filter_by_status'];
79
- $search_by_id = $post_data['search_by_id'];
80
- $now = Mage::getModel('core/date')->timestamp(time());
81
- $orderCollection = Mage::getResourceModel('sales/order_grid_collection')->addFieldToFilter('store_id',Array('eq'=>$storeId))->setOrder('entity_id', 'desc');
82
-
83
- if($filter_by_date != null){
84
- $dateEnd = date('Y-m-d 23:59:59', $now);
85
- if($filter_by_date == 1){
86
- $dateStart = date('Y-m-d 00:00:00', $now);
87
- $orderCollection->addAttributeToFilter('created_at', array('from'=>$dateStart, 'to'=>$dateEnd));
88
- }elseif($filter_by_date == 2){
89
- $dateStart = date('Y-m-d 00:00:00', strtotime('-6 days'));
90
- $orderCollection->addAttributeToFilter('created_at', array('from'=>$dateStart, 'to'=>$dateEnd));
91
- }elseif($filter_by_date == 3){
92
- $dateStart = date('Y-m-01 00:00:00');
93
- $orderCollection->addAttributeToFilter('created_at', array('from'=>$dateStart, 'to'=>$dateEnd));
94
- }elseif($filter_by_date == 4){
95
- $orderCollection->addAttributeToFilter('created_at', array("lt"=>$post_data['before_date']." 00:00:00"));
96
- }elseif($filter_by_date == 5){
97
- $dateStart = $post_data['start_date']." 00:00:00";
98
- $dateEnd = $post_data['end_date']." 23:59:59";
99
- $orderCollection->addAttributeToFilter('created_at', array('from'=>$dateStart, 'to'=>$dateEnd));
100
- }elseif($filter_by_date == 6){
101
- $orderCollection->addAttributeToFilter('created_at', array("gt"=>$post_data['after_date']." 23:59:59"));
102
- }
103
- }
104
- if($filter_by_status != null){
105
- $orderCollection->addFieldToFilter('status',Array('eq'=>$filter_by_status));
106
- }
107
-
108
- if($search_by_id != null){
109
- $orderCollection->addFieldToFilter('increment_id',Array('like'=>'%'.$search_by_id.'%'));
110
- }
111
- foreach($orderCollection as $order){
112
-
113
- $orderListData[] = array(
114
- 'entity_id' => $order->getEntityId(),
115
- 'increment_id' => $order->getIncrementId(),
116
- 'store_id' => $order->getStoreId(),
117
- 'customer_name' => $order->getBillingName(),
118
- 'status' => $order->getStatus(),
119
- 'order_date' => Mage::helper('mobileassistant')->getActualOrderDate($order->getCreatedAt()),
120
- 'grand_total' => Mage::helper('mobileassistant')->getPrice($order->getGrandTotal(),$order->getStoreId(),$order->getOrderCurrencyCode()),
121
- 'toal_qty' => Mage::getModel('sales/order')->load($order->getEntityId())->getTotalQtyOrdered(),
122
- 'total_items' => count($order->getAllItems())
123
- );
124
- }
125
- $orderListResultArr = array('orderlistdata' => $orderListData);
126
- $orderListResult = Mage::helper('core')->jsonEncode($orderListResultArr);
127
- return Mage::app()->getResponse()->setBody($orderListResult);
128
- }else{
129
- $isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
130
- return Mage::app()->getResponse()->setBody($isEnable);
131
- }
132
- }
133
-
134
- public function getOrderDetailAction()
135
- {
136
- if(Mage::helper('mobileassistant')->isEnable()){
137
- $post_data = Mage::app()->getRequest()->getParams();
138
- $sessionId = $post_data['session'];
139
- $storeId = $post_data['storeid'];
140
-
141
- if (!$sessionId || $sessionId == NULL) {
142
- echo $this->__("The Login has expired. Please try log in again.");
143
- return false;
144
- }
145
-
146
- $order_id = $post_data['entity_id'];
147
- $order = Mage::getModel('sales/order')->load($order_id);
148
-
149
- $order_detail = array(
150
- 'entity_id' => $order->getEntityId(),
151
- 'increment_id' => $order->getIncrementId(),
152
- 'status' => $order->getStatus(),
153
- 'order_date' => Mage::helper('mobileassistant')->getActualOrderDate($order->getCreatedAt()),
154
- 'total_qty' => $order->getTotalQtyOrdered(),
155
- 'total_items' => count($order->getAllItems()),
156
- 'grand_total' => Mage::helper('mobileassistant')->getPrice($order->getGrandTotal(),$order->getStoreId(),$order->getOrderCurrencyCode()),
157
- 'sub_total' => Mage::helper('mobileassistant')->getPrice($order->getSubtotal(),$order->getStoreId(),$order->getOrderCurrencyCode()),
158
- 'discount' => Mage::helper('mobileassistant')->getPrice($order->getDiscountAmount(),$order->getStoreId(),$order->getOrderCurrencyCode()),
159
- 'tax' => Mage::helper('mobileassistant')->getPrice($order->getTax(),$order->getStoreId(),$order->getOrderCurrencyCode())
160
- );
161
-
162
- $customer_id = $order->getCustomerId();
163
- $customer_name = $order->getCustomerFirstname()." ".$order->getCustomerLastname();
164
- if($customer_id == null){$customer_name = $order->getCustomerName();}
165
- $customer_detail = array(
166
- 'customer_id' => $customer_id,
167
- 'customer_name' => $customer_name,
168
- 'customer_email' => $order->getCustomerEmail()
169
- );
170
-
171
- $billing_address = $order->getBillingAddress();
172
- $billing_address_data = array(
173
- 'name' => $billing_address->getFirstname().' '.$billing_address->getLastname(),
174
- 'street' => $billing_address->getData('street'),
175
- 'city' => $billing_address->getCity(),
176
- 'region' => $billing_address->getRegion(),
177
- 'postcode' => $billing_address->getPostcode(),
178
- 'country' => Mage::getModel('directory/country')->loadByCode($billing_address->getCountryId())->getName(),
179
- 'telephone' => $billing_address->getTelephone()
180
- );
181
- $shipping_address = $order->getShippingAddress();
182
- if($shipping_address){
183
- $shipping_address_data = array(
184
- 'name' => $shipping_address->getFirstname().' '.$shipping_address->getLastname(),
185
- 'street' => $shipping_address->getData('street'),
186
- 'city' => $shipping_address->getCity(),
187
- 'region' => $shipping_address->getRegion(),
188
- 'postcode' => $shipping_address->getPostcode(),
189
- 'country' => Mage::getModel('directory/country')->loadByCode($shipping_address->getCountryId())->getName(),
190
- 'telephone' => $shipping_address->getTelephone()
191
- );
192
- }
193
-
194
- $payment_info = array(
195
- 'payment_method' => $order->getPayment()->getMethodInstance()->getTitle()
196
- );
197
-
198
- $shipping_info = array(
199
- 'shipping_method' => $order->getShippingDescription(),
200
- 'shipping_charge' => Mage::helper('mobileassistant')->getPrice($order->getShippingAmount(),$order->getStoreId(),$order->getOrderCurrencyCode())
201
- );
202
-
203
- $products_detail = $this->_orderedProductDetails($order_id);
204
-
205
- $full_order_detail = array(
206
- 'basic_order_detail' => $order_detail,
207
- 'customer_detail' => $customer_detail,
208
- 'billing_address' => $billing_address_data,
209
- 'shipping_address' => $shipping_address_data,
210
- 'payment_info' => $payment_info,
211
- 'shipping_info' => $shipping_info,
212
- 'product_detail' => $products_detail
213
- );
214
- $orderDetailResultArr = array('orderlistdata' => $full_order_detail);
215
- $orderDetailResult = Mage::helper('core')->jsonEncode($orderDetailResultArr);
216
- return Mage::app()->getResponse()->setBody($orderDetailResult);
217
- }else{
218
- $isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
219
- return Mage::app()->getResponse()->setBody($isEnable);
220
- }
221
- }
222
-
223
- protected function _orderedProductDetails($order_id)
224
- {
225
- $order = Mage::getModel('sales/order')->load($order_id);
226
- foreach ($order->getItemsCollection() as $item) {
227
- $options = $item->getProductOptions();
228
- if($item->getProductType() == "downloadable"){
229
- $obj = new Mage_Downloadable_Block_Adminhtml_Sales_Items_Column_Downloadable_Name();
230
- foreach($options['links'] as $links)
231
- {
232
-
233
- $this->_purchased = Mage::getModel('downloadable/link_purchased')
234
- ->load($order_id, 'order_id');
235
- $purchasedItem = Mage::getModel('downloadable/link_purchased_item')->getCollection()
236
- ->addFieldToFilter('order_item_id', $item->getId());
237
- $this->_purchased->setPurchasedItems($purchasedItem);
238
-
239
- foreach ($this->_purchased->getPurchasedItems() as $_link){
240
- $links_value[] = $_link->getLinkTitle().'('. $_link->getNumberOfDownloadsUsed() . ' / ' . ($_link->getNumberOfDownloadsBought() ? $_link->getNumberOfDownloadsBought() : Mage::helper('downloadable')->__('U')) .')';
241
- }
242
-
243
- $info = array(array(
244
- 'label' => $obj->getLinksTitle(),
245
- 'value' => implode(',',$links_value)
246
- ));
247
- }
248
-
249
- }else{
250
-
251
- $result = array();
252
- if ($options = $item->getProductOptions()) {
253
- if (isset($options['options'])) {
254
- $result = array_merge($result, $options['options']);
255
- }
256
- if (isset($options['additional_options'])) {
257
- $result = array_merge($result, $options['additional_options']);
258
- }
259
- if (!empty($options['attributes_info'])) {
260
- $result = array_merge($options['attributes_info'], $result);
261
- }
262
- }
263
-
264
- $info = array();
265
- if($result)
266
- {
267
- foreach ($result as $_option){
268
- $info[] = array(
269
- 'label' => $_option['label'],
270
- 'value' => $_option['value']
271
- );
272
- }
273
- }
274
- }
275
- $skus = '';
276
- $product = Mage::getModel('catalog/product')->load($item->getProductId());
277
- if ($item->getParentItem()) continue;
278
- if ($_options = $this->_getItemOptions($item)) {
279
- $skus = $_options;
280
- }
281
- $products_detail[] = array(
282
- 'product_id' => $item->getProductId(),
283
- 'name' => $item->getName(),
284
- 'sku' => $item->getSku(),
285
- 'unit_price' => Mage::helper('mobileassistant')->getPrice($item->getOriginalPrice(),$order->getStoreId(),$order->getOrderCurrencyCode()),
286
- 'ordered_qty' => round($item->getQtyOrdered(), 2),
287
- 'row_total' => Mage::helper('mobileassistant')->getPrice($item->getRowTotal(),$order->getStoreId(),$order->getOrderCurrencyCode()),
288
- 'options' => $skus ? $skus : '',
289
- 'image' => ($product->getImage())?Mage::helper('catalog/image')->init($product, 'image',$product->getImage())->resize(300,330)->keepAspectRatio(true)->constrainOnly(true)->__toString():'N/A',
290
- 'attribute_info' => $info ? $info : ''
291
- );
292
- }
293
- return $products_detail;
294
- }
295
-
296
- private function _getItemOptions($item)
297
- {
298
- $id = array('id' => $item->getItemId());
299
- $order_items = Mage::getModel('sales/order_item')->getCollection()->addFieldToFilter('parent_item_id',Array('eq'=>$id));
300
- foreach($order_items as $order_item)
301
- {
302
- $product_data = Mage::getModel('catalog/product')->load($order_item->getProductId());
303
- $skus[] = $product_data->getSku();
304
- }
305
- return $skus;
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
- $post_data = Mage::app()->getRequest()->getParams();
9
- $sessionId = $post_data['session'];
10
 
11
- if (!$sessionId || $sessionId == NULL) {
12
- echo $this->__("The Login has expired. Please try log in again.");
13
- return false;
14
- }
 
 
 
 
 
 
 
 
15
 
16
- $storeId = $post_data['storeid'];
17
- $limit = $post_data['limit'];
18
- $offset = $post_data['offset'];
19
- $new_products = $post_data['last_fetch_product'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  $is_refresh = $post_data['is_refresh'];
 
21
 
22
 
23
- $products = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($storeId)->setOrder('entity_id', 'desc');
24
- if($offset != null){
25
- $products->addAttributeToFilter('entity_id', array('lt' => $offset));
26
- }
27
 
28
 
29
- if($is_refresh == 1){
30
- $last_fetch_product = $post_data['last_fetch_product'];
31
- $min_fetch_product = $post_data['min_fetch_product'];
32
- $last_updated = $post_data['last_updated'];
33
- $products->getSelect()->where("(entity_id BETWEEN '".$min_fetch_product."'AND '".$last_fetch_product ."' AND updated_at > '".$last_updated."') OR entity_id >'".$last_fetch_product."'");
 
 
 
 
34
  }
 
 
35
 
36
- $products->getSelect()->limit($limit);
37
 
38
- foreach($products as $product)
39
- {
40
- $product_data = Mage::getModel('catalog/product')->load($product->getId());
41
- $status = $product_data->getStatus();
42
- $qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product_data)->getQty();
43
- if($status == 1){$status = 'Enabled';}else{$status = 'Disabled';}
44
- if($qty < 0 || $product_data->getIsInStock() == 0){$qty = 'Out of Stock';}
45
- $product_list[] = array(
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
- $updated_time = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
57
- $productResultArr = array('productlistdata' => $product_list,'updated_time' =>$updated_time);
58
- $productListResult = Mage::helper('core')->jsonEncode($productResultArr);
59
- return Mage::app()->getResponse()->setBody($productListResult);
60
- }else{
61
- $isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
62
- return Mage::app()->getResponse()->setBody($isEnable);
 
 
 
 
 
 
63
  }
 
 
 
 
 
 
 
64
  }
65
-
66
- public function getProductDetailAction()
67
- {
68
- if(Mage::helper('mobileassistant')->isEnable()){
69
- $post_data = Mage::app()->getRequest()->getParams();
 
 
 
 
 
 
 
 
 
70
  $sessionId = $post_data['session'];
 
 
 
71
 
72
- if (!$sessionId || $sessionId == NULL) {
73
-
 
 
 
 
 
 
 
 
74
  }
75
- try{
76
- $storeId = $post_data['storeid'];
77
- $productId = $post_data['productid'];
78
- $productSku = $post_data['sku'];
79
-
80
- if(isset($productSku) && $productSku != null)
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
- $pro_status = $product_data->getStatus();
97
- $pro_qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product_data)->getQty();
98
- if($pro_qty < 0 || $product_data->getIsInStock() == 0){$pro_qty = 'Out of Stock';}
99
- $_images = $product_data->getMediaGalleryImages();
100
- if($_images){
101
- foreach($_images as $_image){
102
- $images[] = Mage::helper('catalog/image')->init($product_data, 'thumbnail', $_image->getFile())->resize(300,330)->keepAspectRatio(true)->constrainOnly(true)->__toString();
103
- }
 
104
  }
105
- if($pro_status == 1){$pro_status = 'Enabled';}else{$pro_status = 'Disabled';}
106
-
107
- if($product_data->getTypeId() == 'grouped'){
108
- $associated_products = $product_data->getTypeInstance(true)->getAssociatedProducts($product_data);
109
- }elseif($product_data->getTypeId() == 'configurable'){
110
- $associated_products = $product_data->getTypeInstance()->getUsedProducts();
111
- } elseif($product_data->getTypeId() == 'bundle'){
112
- $associated_products = $product_data->getTypeInstance(true)->getSelectionsCollection($product_data->getTypeInstance(true)->getOptionsIds($product_data), $product_data);
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  }
114
- foreach($associated_products as $associated_product)
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
- $productResultArr = array('productdata' => $product_details , 'associated_products_list' =>$associated_products_list);
155
- $productDetailResult = Mage::helper('core')->jsonEncode($productResultArr);
156
- return Mage::app()->getResponse()->setBody($productDetailResult);
157
- }catch (Exception $e){
158
- $product_details = array (
159
- 'status' => 'error',
160
- 'message' => $e->getMessage()
161
- );
162
- return Mage::app()->getResponse()->setBody(Mage::helper('core')->jsonEncode($product_details));
163
- }
164
- }else{
165
- $isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
166
- return Mage::app()->getResponse()->setBody($isEnable);
 
 
 
 
 
 
 
 
 
 
 
167
  }
 
 
 
168
  }
169
-
170
- public function filterProductAction()
171
- {
172
- if(Mage::helper('mobileassistant')->isEnable()){
173
- $post_data = Mage::app()->getRequest()->getParams();
 
 
 
 
 
 
 
 
174
  $sessionId = $post_data['session'];
175
-
176
- if (!$sessionId || $sessionId == NULL) {
177
- echo $this->__("The Login has expired. Please try log in again.");
178
- return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
- if($filter_by_type != null){
202
- $products->addFieldToFilter('type_id',Array('eq'=>$filter_by_type));
203
- }
204
 
205
- if($filter_by_qty != null){
206
- $products->joinField('qty','cataloginventory/stock_item','qty','product_id=entity_id','{{table}}.stock_id=1','left');
207
- if($filter_by_qty == 'gteq'){
208
- $qty = $post_data['qty'];
209
- $products->addFieldToFilter('qty',Array('gteq'=>$qty));
210
- }elseif($filter_by_qty == 'lteq'){
211
- $qty = $post_data['qty'];
212
- $products->addFieldToFilter('qty',Array('lteq'=>$qty));
213
- }elseif($filter_by_qty == 'btwn'){
214
- $from_qty = $post_data['from_qty'];
215
- $to_qty = $post_data['to_qty'];
216
- $products->addFieldToFilter('qty',array('from'=>$from_qty, 'to'=>$to_qty));
217
- }
218
  }
 
219
 
220
- foreach($products as $product)
221
- {
222
- $product_data = Mage::getModel('catalog/product')->load($product->getId());
223
- $status = $product_data->getStatus();
224
- $qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product_data)->getQty();
225
- if($status == 1){$status = 'Enabled';}else{$status = 'Disabled';}
226
- if($qty < 0 || $product_data->getIsInStock() == 0){$qty = 'Out of Stock';}
227
- $product_list[] = array(
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
- $productListResultArr = array('productlistdata' => $product_list);
240
- $productListResult = Mage::helper('core')->jsonEncode($productListResultArr);
241
- return Mage::app()->getResponse()->setBody($productListResult);
242
- }catch (Exception $e){
243
- $product_list = array (
244
- 'status' => 'error',
245
- 'message' => $e->getMessage()
 
 
 
 
246
  );
247
- return Mage::app()->getResponse()->setBody(Mage::helper('core')->jsonEncode($product_list));
248
  }
249
- }else{
250
- $isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
251
- return Mage::app()->getResponse()->setBody($isEnable);
 
 
 
 
 
 
 
252
  }
 
 
 
253
  }
 
254
 
255
- public function ChangeProductStatusAction()
256
- {
257
- if(Mage::helper('mobileassistant')->isEnable()){
258
- $post_data = Mage::app()->getRequest()->getParams();
259
- $sessionId = $post_data['session'];
260
-
261
- if (!$sessionId || $sessionId == NULL) {
262
- echo $this->__("The Login has expired. Please try log in again.");
263
- return false;
264
- }
265
- try{
266
- $storeId = $post_data['storeid'];
267
- $productId = $post_data['productid'];
268
- $current_status = $post_data['current_status'];
269
- $new_status = $post_data['new_status'];
270
-
271
-
272
- if($current_status != $new_status && $new_status == 1)
273
- {
274
- Mage::getModel('catalog/product_status')->updateProductStatus($productId, $storeId, Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
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
- }else{
289
- $isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
290
- return Mage::app()->getResponse()->setBody($isEnable);
 
 
 
 
 
 
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.0</version>
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.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
@@ -25,12 +25,12 @@ To ensure smooth working of this extension you need to download this extension i
25
  Application Download Link:&#xD;
26
  https://itunes.apple.com/us/app/magentomobilemanager/id695074519?mt=8&amp;ign-mpt=uo%3D4&#xD;
27
  </description>
28
- <notes>-Bug Fixing&#xD;
29
- -Notification Issue</notes>
30
  <authors><author><name>Biztech</name><user>biztechcon</user><email>sales@biztechconsultancy.com</email></author></authors>
31
- <date>2015-10-17</date>
32
- <time>05:43:05</time>
33
- <contents><target name="mageetc"><dir name="modules"><file name="Biztech_Mobileassistant.xml" hash="18d9cf7b8e516db899336adfd8210621"/><file name="Biztech_All.xml" hash="f4c3b9c029e56da8f09d7d71336c00f7"/></dir></target><target name="magelocal"><dir name="Biztech"><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="57e11df64364ddd5a949adc02d50766c"/><file name="DashboardController.php" hash="b340abbf5c343884894a4a240cbd45a2"/><file name="IndexController.php" hash="67599a94a41762b9624069f63d8dace0"/><file name="OrderController.php" hash="2dd03a85169cefdb9fec3f119207c0fc"/><file name="ProductController.php" hash="29c118568b393023f9c1e72fe8f60490"/></dir><dir name="etc"><file name="api.xml" hash="7860c9fe0f121148eb2a3a498d1879b1"/><file name="config.xml" hash="d63cdebbf7bd97e2c30f20f120f12be2"/><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 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="8c4c167baf8775736e6861bfceb8e09f"/></dir><dir name="etc"><file name="config.xml" hash="27e403cedb861da03753d28527d9c664"/><file name="system.xml" hash="17262087dc933d934e09ac04cafb4c51"/></dir></dir></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>
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:&#xD;
26
  https://itunes.apple.com/us/app/magentomobilemanager/id695074519?mt=8&amp;ign-mpt=uo%3D4&#xD;
27
  </description>
28
+ <notes>-Provided theme change from Dashboard&#xD;
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>