Version Notes
-Bug Fixes and Enhacements
-Added Provision Enable/Disable feature from Device
-Stock Alert On device
- Added order details in notification on device
Download this release
Release Info
Developer | Biztech |
Extension | magento_mobile_assistant_manager |
Version | 0.1.9 |
Comparing to | |
See all releases |
Code changes from version 0.1.8 to 0.1.9
- app/code/local/Biztech/Mobileassistant/Helper/Data.php +137 -121
- app/code/local/Biztech/Mobileassistant/Model/Mobileassistant.php +9 -9
- app/code/local/Biztech/Mobileassistant/Model/Mobileassistant/Api.php +57 -56
- app/code/local/Biztech/Mobileassistant/Model/Mysql4/Mobileassistant.php +9 -9
- app/code/local/Biztech/Mobileassistant/Model/Mysql4/Mobileassistant/Collection.php +9 -9
- app/code/local/Biztech/Mobileassistant/Model/Observer.php +63 -1
- app/code/local/Biztech/Mobileassistant/controllers/CustomerController.php +1 -1
- app/code/local/Biztech/Mobileassistant/controllers/DashboardController.php +251 -209
- app/code/local/Biztech/Mobileassistant/controllers/IndexController.php +189 -177
- app/code/local/Biztech/Mobileassistant/controllers/OrderController.php +304 -292
- app/code/local/Biztech/Mobileassistant/controllers/ProductController.php +284 -221
- app/code/local/Biztech/Mobileassistant/etc/api.xml +16 -16
- app/code/local/Biztech/Mobileassistant/etc/config.xml +31 -1
- app/code/local/Biztech/Mobileassistant/etc/system.xml +80 -60
- app/code/local/Biztech/Mobileassistant/sql/mobileassistant_setup/mysql4-install-0.1.0.php +20 -20
- app/code/local/Biztech/Mobileassistant/sql/mobileassistant_setup/mysql4-upgrade-0.1.0-0.1.4.php +7 -7
- app/code/local/Biztech/Mobileassistant/sql/mobileassistant_setup/mysql4-upgrade-0.1.4-0.1.5.php +15 -15
- app/code/local/Biztech/Mobileassistant/sql/mobileassistant_setup/mysql4-upgrade-0.1.5-0.1.6.php +7 -7
- package.xml +8 -6
app/code/local/Biztech/Mobileassistant/Helper/Data.php
CHANGED
@@ -1,122 +1,138 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Biztech_Mobileassistant_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
-
{
|
5 |
-
public function getPrice($price)
|
6 |
-
{
|
7 |
-
$
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
$
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
$
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
'
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Biztech_Mobileassistant_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
public function getPrice($price,$storeId,$order_currency)
|
6 |
+
{
|
7 |
+
$currencyCode = $order_currency;
|
8 |
+
if($order_currency == null)
|
9 |
+
{
|
10 |
+
$store= Mage::getModel('core/store')->load($storeId);
|
11 |
+
$price = $store->roundPrice($store->convertPrice($price));
|
12 |
+
$currencyCode = Mage::app()->getStore($storeId)->getCurrentCurrencyCode();
|
13 |
+
}
|
14 |
+
$price = strip_tags(Mage::app()->getLocale()->currency($currencyCode)->toCurrency($this->getPriceFormat($price)));
|
15 |
+
return $price;
|
16 |
+
}
|
17 |
+
|
18 |
+
public function getPriceFormat($price)
|
19 |
+
{
|
20 |
+
$price = sprintf("%01.2f", $price);
|
21 |
+
return $price;
|
22 |
+
}
|
23 |
+
|
24 |
+
public function getActualDate($updated_date)
|
25 |
+
{
|
26 |
+
$date = Mage::app()->getLocale()->date(strtotime($updated_date));
|
27 |
+
$timestamp = $date->get(Zend_Date::TIMESTAMP) - $date->get(Zend_Date::TIMEZONE_SECS);
|
28 |
+
$updated_date = date("Y-m-d H:i:s", $timestamp);
|
29 |
+
return $updated_date;
|
30 |
+
|
31 |
+
}
|
32 |
+
|
33 |
+
public function getActualOrderDate($updated_date)
|
34 |
+
{
|
35 |
+
$date = Mage::app()->getLocale()->date(strtotime($updated_date));
|
36 |
+
$timestamp = $date->get(Zend_Date::TIMESTAMP) + $date->get(Zend_Date::TIMEZONE_SECS);
|
37 |
+
$updated_date = date("Y-m-d H:i:s", $timestamp);
|
38 |
+
return $updated_date;
|
39 |
+
|
40 |
+
}
|
41 |
+
|
42 |
+
public function isEnable()
|
43 |
+
{
|
44 |
+
return Mage::getStoreConfig('mobileassistant/mobileassistant_general/enabled');
|
45 |
+
}
|
46 |
+
|
47 |
+
public function pushNotification($notification_type,$entity_id,$params=NULL){
|
48 |
+
|
49 |
+
$google_api_key = 'AIzaSyAZPkT165oPcjfhUmgJnt5Lcs2OInBFJmE';
|
50 |
+
$passphrase = 'push2magento';
|
51 |
+
$collections = Mage::getModel("mobileassistant/mobileassistant")->getCollection()->addFieldToFilter('notification_flag',Array('eq'=>1))->addFieldToFilter('is_logout',Array('eq'=>0));
|
52 |
+
|
53 |
+
if ($notification_type=='customer'){
|
54 |
+
$notification_data = array();
|
55 |
+
$message = Mage::getStoreConfig('mobileassistant/mobileassistant_general/customer_register_notification_msg');
|
56 |
+
if($message == null){
|
57 |
+
$message = Mage::helper('mobileassistant')->__('A New customer has been registered on the Store.');
|
58 |
+
}
|
59 |
+
}else if($notification_type == 'order'){
|
60 |
+
|
61 |
+
$order = Mage::getModel('sales/order')->load($entity_id);
|
62 |
+
$msgString = Mage::getStoreConfig('mobileassistant/mobileassistant_general/notification_msg');
|
63 |
+
if($msgString == null){
|
64 |
+
$msgString = Mage::helper('mobileassistant')->__('A New order has been received on the Store.');
|
65 |
+
}
|
66 |
+
$message =$msgString."\nOrder Id: ".$order->getIncrementId()."\nGrand Total: ".$this->getPrice($order->getGrandTotal(),$order->getStoreId(),$order->getOrderCurrencyCode());
|
67 |
+
|
68 |
+
}else if($notification_type == 'product'){
|
69 |
+
$msgString = Mage::getStoreConfig('mobileassistant/mobileassistant_general/product_inventory_notification_msg');
|
70 |
+
if($msgString == null){
|
71 |
+
$msgString = Mage::helper('mobileassistant')->__('Product Stock Alert');
|
72 |
+
}
|
73 |
+
$message = $msgString."\nName: ".$params['name']."\nCurrent Qty: ".$params['qty'];
|
74 |
+
}
|
75 |
+
|
76 |
+
$apnsCert = Mage::getBaseDir('lib'). DS. "mobileassistant".DS."pushcert.pem";
|
77 |
+
$ctx = stream_context_create();
|
78 |
+
stream_context_set_option($ctx, 'ssl', 'local_cert', $apnsCert);
|
79 |
+
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
|
80 |
+
$flags = STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT;
|
81 |
+
$fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err,$errstr, 60, $flags, $ctx);
|
82 |
+
|
83 |
+
foreach($collections as $collection){
|
84 |
+
$deviceType = $collection->getDeviceType();
|
85 |
+
|
86 |
+
if($deviceType == 'ios'){
|
87 |
+
if ($fp){
|
88 |
+
|
89 |
+
$deviceToken = $collection->getDeviceToken();
|
90 |
+
$body['aps'] = array(
|
91 |
+
'alert' => $message,
|
92 |
+
'sound' => 'default',
|
93 |
+
'entity_id' => $entity_id,
|
94 |
+
'type' => $notification_type
|
95 |
+
);
|
96 |
+
|
97 |
+
$payload = json_encode($body);
|
98 |
+
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
|
99 |
+
$result = fwrite($fp, $msg, strlen($msg));
|
100 |
+
|
101 |
+
}
|
102 |
+
|
103 |
+
}elseif($deviceType == 'android')
|
104 |
+
{
|
105 |
+
|
106 |
+
$deviceToken = $collection->getDeviceToken();
|
107 |
+
$registrationIds = array($deviceToken);
|
108 |
+
$msg_a = array(
|
109 |
+
'message' => $message,
|
110 |
+
'entity_id' => $entity_id,
|
111 |
+
'type' => $notification_type
|
112 |
+
);
|
113 |
+
|
114 |
+
$fields = array(
|
115 |
+
'registration_ids' => $registrationIds,
|
116 |
+
'data' => $msg_a
|
117 |
+
);
|
118 |
+
|
119 |
+
$headers = array(
|
120 |
+
'Authorization: key=' . $google_api_key,
|
121 |
+
'Content-Type: application/json'
|
122 |
+
);
|
123 |
+
|
124 |
+
$ch = curl_init();
|
125 |
+
curl_setopt( $ch,CURLOPT_URL, 'https://android.googleapis.com/gcm/send' );
|
126 |
+
curl_setopt( $ch,CURLOPT_POST, true );
|
127 |
+
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
|
128 |
+
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
|
129 |
+
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
|
130 |
+
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
|
131 |
+
$result = curl_exec($ch );
|
132 |
+
curl_close( $ch );
|
133 |
+
}
|
134 |
+
}
|
135 |
+
fclose($fp);
|
136 |
+
return true;
|
137 |
+
}
|
138 |
}
|
app/code/local/Biztech/Mobileassistant/Model/Mobileassistant.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Biztech_Mobileassistant_Model_Mobileassistant extends Mage_Core_Model_Abstract
|
4 |
-
{
|
5 |
-
public function _construct()
|
6 |
-
{
|
7 |
-
parent::_construct();
|
8 |
-
$this->_init('mobileassistant/mobileassistant');
|
9 |
-
}
|
10 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Biztech_Mobileassistant_Model_Mobileassistant extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('mobileassistant/mobileassistant');
|
9 |
+
}
|
10 |
}
|
app/code/local/Biztech/Mobileassistant/Model/Mobileassistant/Api.php
CHANGED
@@ -1,56 +1,57 @@
|
|
1 |
-
<?php
|
2 |
-
class Biztech_Mobileassistant_Model_Mobileassistant_Api extends Mage_Api_Model_Resource_Abstract
|
3 |
-
{
|
4 |
-
public function create($data)
|
5 |
-
{
|
6 |
-
$collections = Mage::getModel("mobileassistant/mobileassistant")->getCollection()->addFieldToFilter('username',Array('eq'=>$data['user']))->addFieldToFilter('apikey',Array('eq'=>$data['key']))->addFieldToFilter('device_token',Array('eq'=>$data['devicetoken']));
|
7 |
-
$count = count($collections);
|
8 |
-
if($count == 0){
|
9 |
-
Mage::getModel("mobileassistant/mobileassistant")
|
10 |
-
->setUsername($data['user'])
|
11 |
-
->setApikey($data['key'])
|
12 |
-
->setDeviceToken($data['devicetoken'])
|
13 |
-
->setDeviceType($data['device_type'])
|
14 |
-
->setNotificationFlag($data['notification_flag'])
|
15 |
-
->save();
|
16 |
-
}
|
17 |
-
if($count == 1){
|
18 |
-
foreach($collections as $user)
|
19 |
-
{
|
20 |
-
$user_id = $user->getUserId();
|
21 |
-
$flag = $user->getNotificationFlag();
|
22 |
-
}
|
23 |
-
if($flag != $data['notification_flag'] || $data['is_logout'] != 1){
|
24 |
-
try {
|
25 |
-
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
26 |
-
$connection->beginTransaction();
|
27 |
-
$fields = array();
|
28 |
-
$fields['notification_flag'] = $data['notification_flag'];
|
29 |
-
$fields['is_logout'] = $data['is_logout'];
|
30 |
-
$where = $connection->quoteInto('user_id =?', $user_id);
|
31 |
-
$
|
32 |
-
$connection->
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
$
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
|
1 |
+
<?php
|
2 |
+
class Biztech_Mobileassistant_Model_Mobileassistant_Api extends Mage_Api_Model_Resource_Abstract
|
3 |
+
{
|
4 |
+
public function create($data)
|
5 |
+
{
|
6 |
+
$collections = Mage::getModel("mobileassistant/mobileassistant")->getCollection()->addFieldToFilter('username',Array('eq'=>$data['user']))->addFieldToFilter('apikey',Array('eq'=>$data['key']))->addFieldToFilter('device_token',Array('eq'=>$data['devicetoken']));
|
7 |
+
$count = count($collections);
|
8 |
+
if($count == 0){
|
9 |
+
Mage::getModel("mobileassistant/mobileassistant")
|
10 |
+
->setUsername($data['user'])
|
11 |
+
->setApikey($data['key'])
|
12 |
+
->setDeviceToken($data['devicetoken'])
|
13 |
+
->setDeviceType($data['device_type'])
|
14 |
+
->setNotificationFlag($data['notification_flag'])
|
15 |
+
->save();
|
16 |
+
}
|
17 |
+
if($count == 1){
|
18 |
+
foreach($collections as $user)
|
19 |
+
{
|
20 |
+
$user_id = $user->getUserId();
|
21 |
+
$flag = $user->getNotificationFlag();
|
22 |
+
}
|
23 |
+
if($flag != $data['notification_flag'] || $data['is_logout'] != 1){
|
24 |
+
try {
|
25 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
26 |
+
$connection->beginTransaction();
|
27 |
+
$fields = array();
|
28 |
+
$fields['notification_flag'] = $data['notification_flag'];
|
29 |
+
$fields['is_logout'] = $data['is_logout'];
|
30 |
+
$where = $connection->quoteInto('user_id =?', $user_id);
|
31 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
32 |
+
$connection->update($prefix.'mobileassistant', $fields, $where);
|
33 |
+
$connection->commit();
|
34 |
+
} catch (Exception $e){
|
35 |
+
return $e->getMessage();
|
36 |
+
}
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
$successArr[] = array('success_msg' => 'Login sucessfully','session_id' => $data['session_id']) ;
|
41 |
+
|
42 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
43 |
+
foreach ($website->getGroups() as $group) {
|
44 |
+
$stores = $group->getStores();
|
45 |
+
foreach ($stores as $store) {
|
46 |
+
$storeArr[] = array('id' =>$store->getId(),
|
47 |
+
'name' => $store->getName()
|
48 |
+
);
|
49 |
+
}
|
50 |
+
}
|
51 |
+
}
|
52 |
+
$isPos = 0;
|
53 |
+
$result = array('success' => $successArr,'stores' => $storeArr,'is_pos' => $isPos);
|
54 |
+
return $result;
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
app/code/local/Biztech/Mobileassistant/Model/Mysql4/Mobileassistant.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Biztech_Mobileassistant_Model_Mysql4_Mobileassistant extends Mage_Core_Model_Mysql4_Abstract
|
4 |
-
{
|
5 |
-
public function _construct()
|
6 |
-
{
|
7 |
-
// Note that the mobileassistant_id refers to the key field in your database table.
|
8 |
-
$this->_init('mobileassistant/mobileassistant', 'mobileassistant_id');
|
9 |
-
}
|
10 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Biztech_Mobileassistant_Model_Mysql4_Mobileassistant extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
// Note that the mobileassistant_id refers to the key field in your database table.
|
8 |
+
$this->_init('mobileassistant/mobileassistant', 'mobileassistant_id');
|
9 |
+
}
|
10 |
}
|
app/code/local/Biztech/Mobileassistant/Model/Mysql4/Mobileassistant/Collection.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Biztech_Mobileassistant_Model_Mysql4_Mobileassistant_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
-
{
|
5 |
-
public function _construct()
|
6 |
-
{
|
7 |
-
parent::_construct();
|
8 |
-
$this->_init('mobileassistant/mobileassistant');
|
9 |
-
}
|
10 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Biztech_Mobileassistant_Model_Mysql4_Mobileassistant_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('mobileassistant/mobileassistant');
|
9 |
+
}
|
10 |
}
|
app/code/local/Biztech/Mobileassistant/Model/Observer.php
CHANGED
@@ -3,10 +3,72 @@
|
|
3 |
{
|
4 |
private static $_handleCustomerFirstOrderCounter = 1;
|
5 |
private static $_handleCustomerFirstRegisterNotificationCounter = 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
public function sales_order_save_after(Varien_Event_Observer $observer)
|
7 |
{
|
8 |
if(Mage::getStoreConfig('mobileassistant/mobileassistant_general/enabled')){
|
9 |
-
|
10 |
$action = Mage::app()->getFrontController()->getAction();
|
11 |
if ($action->getFullActionName() == 'checkout_onepage_saveOrder')
|
12 |
{
|
3 |
{
|
4 |
private static $_handleCustomerFirstOrderCounter = 1;
|
5 |
private static $_handleCustomerFirstRegisterNotificationCounter = 1;
|
6 |
+
|
7 |
+
|
8 |
+
/*inventory status-starts*/
|
9 |
+
public function catalogInventorySave(Varien_Event_Observer $observer)
|
10 |
+
{
|
11 |
+
if (Mage::getStoreConfig('mobileassistant/mobileassistant_general/enabled')) {
|
12 |
+
$event = $observer->getEvent();
|
13 |
+
$_item = $event->getItem();
|
14 |
+
$params = array();
|
15 |
+
$params['product_id'] = $_item->getProductId();
|
16 |
+
$params['name'] = $_item->getProductName();
|
17 |
+
$params['qty'] = $_item->getProduct()->getStockItem()->getQty();
|
18 |
+
//$params['qty_change'] = ($_item->getTotalQty());
|
19 |
+
$minQty = Mage::getStoreConfig('mobileassistant/mobileassistant_general/minimum_qty');
|
20 |
+
if($params['qty'] <= $minQty){
|
21 |
+
Mage::helper('mobileassistant')->pushNotification('product',$params['product_id'],$params);
|
22 |
+
}
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
|
27 |
+
public function subtractQuoteInventory(Varien_Event_Observer $observer)
|
28 |
+
{
|
29 |
+
if (Mage::getStoreConfig('mobileassistant/mobileassistant_general/enabled')) {
|
30 |
+
|
31 |
+
$quote = $observer->getEvent()->getQuote();
|
32 |
+
foreach ($quote->getAllItems() as $item) {
|
33 |
+
$params = array();
|
34 |
+
$params['product_id'] = $item->getProductId();
|
35 |
+
$params['name'] = $item->getName();
|
36 |
+
$params['qty'] = $item->getProduct()->getStockItem()->getQty();
|
37 |
+
//$params['qty_change'] = ($_item->getTotalQty());
|
38 |
+
$minQty = Mage::getStoreConfig('mobileassistant/mobileassistant_general/minimum_qty');
|
39 |
+
if(($params['qty']-$params['qty_change']) <= $minQty){
|
40 |
+
Mage::helper('mobileassistant')->pushNotification('product',$params['product_id'],$params);
|
41 |
+
}
|
42 |
+
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
public function revertQuoteInventory(Varien_Event_Observer $observer)
|
48 |
+
{
|
49 |
+
if (Mage::getStoreConfig('mobileassistant/mobileassistant_general/enabled')) {
|
50 |
+
|
51 |
+
$quote = $observer->getEvent()->getQuote();
|
52 |
+
foreach ($quote->getAllItems() as $item) {
|
53 |
+
$params = array();
|
54 |
+
$params['product_id'] = $item->getProductId();
|
55 |
+
$params['name'] = $item->getName();
|
56 |
+
$params['qty'] = $item->getProduct()->getStockItem()->getQty();
|
57 |
+
//$params['qty_change'] = ($_item->getTotalQty());
|
58 |
+
$minQty = Mage::getStoreConfig('mobileassistant/mobileassistant_general/minimum_qty');
|
59 |
+
if(($params['qty']+$params['qty_change']) <= $minQty){
|
60 |
+
Mage::helper('mobileassistant')->pushNotification('product',$params['product_id'],$params);
|
61 |
+
}
|
62 |
+
}
|
63 |
+
}
|
64 |
+
}
|
65 |
+
/*inventory status- ends*/
|
66 |
+
|
67 |
+
|
68 |
public function sales_order_save_after(Varien_Event_Observer $observer)
|
69 |
{
|
70 |
if(Mage::getStoreConfig('mobileassistant/mobileassistant_general/enabled')){
|
71 |
+
|
72 |
$action = Mage::app()->getFrontController()->getAction();
|
73 |
if ($action->getFullActionName() == 'checkout_onepage_saveOrder')
|
74 |
{
|
app/code/local/Biztech/Mobileassistant/controllers/CustomerController.php
CHANGED
@@ -134,7 +134,7 @@
|
|
134 |
'customer_name' => $order->getBillingName(),
|
135 |
'status' => $order->getStatus(),
|
136 |
'order_date' => date('Y-m-d H:i:s', strtotime($order->getCreatedAt())),
|
137 |
-
'grand_total' => Mage::helper('mobileassistant')->getPrice($order->getGrandTotal()),
|
138 |
'toal_qty' => Mage::getModel('sales/order')->load($order->getEntityId())->getTotalQtyOrdered()
|
139 |
);
|
140 |
}
|
134 |
'customer_name' => $order->getBillingName(),
|
135 |
'status' => $order->getStatus(),
|
136 |
'order_date' => date('Y-m-d H:i:s', strtotime($order->getCreatedAt())),
|
137 |
+
'grand_total' => Mage::helper('mobileassistant')->getPrice($order->getGrandTotal(),$order->getStoreId(),$order->getOrderCurrencyCode()),
|
138 |
'toal_qty' => Mage::getModel('sales/order')->load($order->getEntityId())->getTotalQtyOrdered()
|
139 |
);
|
140 |
}
|
app/code/local/Biztech/Mobileassistant/controllers/DashboardController.php
CHANGED
@@ -1,210 +1,252 @@
|
|
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 |
-
if (!Mage::getSingleton('api/session')->isLoggedIn($sessionId)) {
|
10 |
-
echo $this->__("The Login has expired. Please try log in again.");
|
11 |
-
return false;
|
12 |
-
}
|
13 |
-
|
14 |
-
$storeId = $post_data['storeid'];
|
15 |
-
$type_id = $post_data['days_for_dashboard'];
|
16 |
-
|
17 |
-
$now = Mage::getModel('core/date')->timestamp(time());
|
18 |
-
$end_date = date('Y-m-d 23:59:59', $now);
|
19 |
-
$start_date = '';
|
20 |
-
$orderCollection = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id',Array('eq'=>$storeId))->addFieldToFilter('status',Array('eq'=>'complete'))->setOrder('entity_id', 'desc');
|
21 |
-
if($type_id == 7){
|
22 |
-
$start_date = date('Y-m-d 00:00:00', strtotime('-6 days'));
|
23 |
-
}elseif($type_id == 30){
|
24 |
-
$start_date = date('Y-m-d 00:00:00', strtotime('-29 days'));
|
25 |
-
}elseif($type_id == 90){
|
26 |
-
$start_date = date('Y-m-d 00:00:00', strtotime('-89 days'));
|
27 |
-
} else if ($type_id == 24){
|
28 |
-
$end_date = date("Y-m-d H:m:s");
|
29 |
-
$start_date = date("Y-m-d H:m:s", strtotime('-24 hours', time()));
|
30 |
-
$timezoneLocal = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
|
31 |
-
|
32 |
-
list ($dateStart, $dateEnd) = Mage::getResourceModel('reports/order_collection')
|
33 |
-
->getDateRange('24h', '', '', true);
|
34 |
-
|
35 |
-
$dateStart->setTimezone($timezoneLocal);
|
36 |
-
$dateEnd->setTimezone($timezoneLocal);
|
37 |
-
|
38 |
-
$dates = array();
|
39 |
-
|
40 |
-
while($dateStart->compare($dateEnd) < 0){
|
41 |
-
$d = $dateStart->toString('yyyy-MM-dd HH:mm:ss');
|
42 |
-
$dateStart->addHour(1);
|
43 |
-
$dates[] = $d;
|
44 |
-
}
|
45 |
-
|
46 |
-
$start_date = $dates[0];
|
47 |
-
$end_date = $dates[count($dates)-1];
|
48 |
-
|
49 |
-
$orderCollection->addAttributeToFilter('created_at', array('from'=>$start_date, 'to'=>$end_date));
|
50 |
-
$total_count = count($orderCollection);
|
51 |
-
}
|
52 |
-
|
53 |
-
if ($type_id!='year'){
|
54 |
-
if ($type_id=='month'){
|
55 |
-
$end_date = date("Y-m-d H:m:s");
|
56 |
-
$start_date = date('Y-m-01 H:m:s');
|
57 |
-
}
|
58 |
-
|
59 |
-
if ($type_id!=24){
|
60 |
-
$orderCollection->addAttributeToFilter('created_at', array('from'=>$start_date, 'to'=>$end_date));
|
61 |
-
$total_count = count($orderCollection);
|
62 |
-
$dates = $this->getDatesFromRange($start_date, $end_date);
|
63 |
-
}
|
64 |
-
$count = 0;
|
65 |
-
foreach($dates as $date)
|
66 |
-
{
|
67 |
-
$orderCollectionByDate = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id',Array('eq'=>$storeId))->addFieldToFilter('status',Array('eq'=>'complete'))->setOrder('entity_id', 'desc');
|
68 |
-
|
69 |
-
if ($type_id==24){
|
70 |
-
$dateStart = $dates[$count];
|
71 |
-
$dateEnd = $dates[$count+1];
|
72 |
-
}else{
|
73 |
-
|
74 |
-
$dateStart = date('Y-m-d 00:00:00',strtotime($date));
|
75 |
-
$dateEnd = date('Y-m-d 23:59:59',strtotime($date));
|
76 |
-
}
|
77 |
-
$orderByDate = $orderCollectionByDate->addAttributeToFilter('created_at', array('from'=>$dateStart, 'to'=>$dateEnd));
|
78 |
-
$orderByDate->getSelect()->columns('SUM(grand_total) AS grand_total_sum');
|
79 |
-
$orderByDate->getSelect()->group(array('store_id'));
|
80 |
-
$orderdata= $orderByDate->getData();
|
81 |
-
if(count($orderByDate) == 0)
|
82 |
-
{
|
83 |
-
if ($type_id==24){
|
84 |
-
$orderTotalByDate[date("Y-m-d H:i",strtotime($date))] = 0;
|
85 |
-
}else if ($type_id=='month'){
|
86 |
-
$orderTotalByDate[date('d',strtotime($date))] = 0;
|
87 |
-
}else{
|
88 |
-
$orderTotalByDate[$date] = 0;
|
89 |
-
}
|
90 |
-
}
|
91 |
-
else{
|
92 |
-
if ($type_id==24){
|
93 |
-
$ordersByDate[date("Y-m-d H:i",strtotime($date))][] = $orderdata[0]['grand_total_sum'];
|
94 |
-
$orderTotalByDate[date("Y-m-d H:i",strtotime($date))] = array_sum($ordersByDate[date("Y-m-d H:i",strtotime($date))]);
|
95 |
-
}else if ($type_id=='month'){
|
96 |
-
$ordersByDate[date('d',strtotime($date))][] = $orderdata[0]['grand_total_sum'];
|
97 |
-
$orderTotalByDate[date('d',strtotime($date))] = array_sum($ordersByDate[date('d',strtotime($date))]);
|
98 |
-
}else{
|
99 |
-
$ordersByDate[$date][] = $orderdata[0]['grand_total_sum'];
|
100 |
-
$orderTotalByDate[$date] = array_sum($ordersByDate[$date]);
|
101 |
-
}
|
102 |
-
|
103 |
-
|
104 |
-
}
|
105 |
-
|
106 |
-
$count++;
|
107 |
-
}
|
108 |
-
}else{
|
109 |
-
$end_date = date ('Y-m-d');
|
110 |
-
$start_date = date ('Y-01-01');
|
111 |
-
$orderCollection->addAttributeToFilter('created_at', array('from'=>$start_date, 'to'=>$end_date));
|
112 |
-
$total_count = count($orderCollection);
|
113 |
-
$months = $this->get_months($start_date, $end_date);
|
114 |
-
$current_year = date("Y");
|
115 |
-
foreach ($months as $month){
|
116 |
-
$first_day = $this->firstDay($month,$current_year);
|
117 |
-
$ordersByDate = array();
|
118 |
-
if ($month==date('F'))
|
119 |
-
$last_day = date ('Y-m-d');
|
120 |
-
else
|
121 |
-
$last_day = $this->lastday($month,$current_year);
|
122 |
-
|
123 |
-
$dates = $this->getDatesFromRange($first_day, $last_day);
|
124 |
-
|
125 |
-
foreach($dates as $date)
|
126 |
-
{
|
127 |
-
$orderCollectionByDate = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id',Array('eq'=>$storeId))->addFieldToFilter('status',Array('eq'=>'complete'))->setOrder('entity_id', 'desc');
|
128 |
-
$dateStart = date('Y-m-d 00:00:00',strtotime($date));
|
129 |
-
$dateEnd = date('Y-m-d 23:59:59',strtotime($date));
|
130 |
-
$orderByDate = $orderCollectionByDate->addAttributeToFilter('created_at', array('from'=>$dateStart, 'to'=>$dateEnd));
|
131 |
-
$orderByDate->getSelect()->columns('SUM(grand_total) AS grand_total_sum');
|
132 |
-
$orderByDate->getSelect()->group(array('store_id'));
|
133 |
-
$orderdata= $orderByDate->getData();
|
134 |
-
$ordersByDate[] = $orderdata[0]['grand_total_sum'];
|
135 |
-
}
|
136 |
-
|
137 |
-
$orderTotalByDate[$month] = array_sum($ordersByDate);
|
138 |
-
}
|
139 |
-
}
|
140 |
-
|
141 |
-
$
|
142 |
-
|
143 |
-
$
|
144 |
-
$
|
145 |
-
$
|
146 |
-
|
147 |
-
|
148 |
-
$
|
149 |
-
return Mage::app()->getResponse()->setBody($
|
150 |
-
}
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
$
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
}
|
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 |
+
if (!Mage::getSingleton('api/session')->isLoggedIn($sessionId)) {
|
10 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
11 |
+
return false;
|
12 |
+
}
|
13 |
+
|
14 |
+
$storeId = $post_data['storeid'];
|
15 |
+
$type_id = $post_data['days_for_dashboard'];
|
16 |
+
|
17 |
+
$now = Mage::getModel('core/date')->timestamp(time());
|
18 |
+
$end_date = date('Y-m-d 23:59:59', $now);
|
19 |
+
$start_date = '';
|
20 |
+
$orderCollection = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id',Array('eq'=>$storeId))->addFieldToFilter('status',Array('eq'=>'complete'))->setOrder('entity_id', 'desc');
|
21 |
+
if($type_id == 7){
|
22 |
+
$start_date = date('Y-m-d 00:00:00', strtotime('-6 days'));
|
23 |
+
}elseif($type_id == 30){
|
24 |
+
$start_date = date('Y-m-d 00:00:00', strtotime('-29 days'));
|
25 |
+
}elseif($type_id == 90){
|
26 |
+
$start_date = date('Y-m-d 00:00:00', strtotime('-89 days'));
|
27 |
+
} else if ($type_id == 24){
|
28 |
+
$end_date = date("Y-m-d H:m:s");
|
29 |
+
$start_date = date("Y-m-d H:m:s", strtotime('-24 hours', time()));
|
30 |
+
$timezoneLocal = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
|
31 |
+
|
32 |
+
list ($dateStart, $dateEnd) = Mage::getResourceModel('reports/order_collection')
|
33 |
+
->getDateRange('24h', '', '', true);
|
34 |
+
|
35 |
+
$dateStart->setTimezone($timezoneLocal);
|
36 |
+
$dateEnd->setTimezone($timezoneLocal);
|
37 |
+
|
38 |
+
$dates = array();
|
39 |
+
|
40 |
+
while($dateStart->compare($dateEnd) < 0){
|
41 |
+
$d = $dateStart->toString('yyyy-MM-dd HH:mm:ss');
|
42 |
+
$dateStart->addHour(1);
|
43 |
+
$dates[] = $d;
|
44 |
+
}
|
45 |
+
|
46 |
+
$start_date = $dates[0];
|
47 |
+
$end_date = $dates[count($dates)-1];
|
48 |
+
|
49 |
+
$orderCollection->addAttributeToFilter('created_at', array('from'=>$start_date, 'to'=>$end_date));
|
50 |
+
$total_count = count($orderCollection);
|
51 |
+
}
|
52 |
+
|
53 |
+
if ($type_id!='year'){
|
54 |
+
if ($type_id=='month'){
|
55 |
+
$end_date = date("Y-m-d H:m:s");
|
56 |
+
$start_date = date('Y-m-01 H:m:s');
|
57 |
+
}
|
58 |
+
|
59 |
+
if ($type_id!=24){
|
60 |
+
$orderCollection->addAttributeToFilter('created_at', array('from'=>$start_date, 'to'=>$end_date));
|
61 |
+
$total_count = count($orderCollection);
|
62 |
+
$dates = $this->getDatesFromRange($start_date, $end_date);
|
63 |
+
}
|
64 |
+
$count = 0;
|
65 |
+
foreach($dates as $date)
|
66 |
+
{
|
67 |
+
$orderCollectionByDate = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id',Array('eq'=>$storeId))->addFieldToFilter('status',Array('eq'=>'complete'))->setOrder('entity_id', 'desc');
|
68 |
+
|
69 |
+
if ($type_id == 24){
|
70 |
+
$dateStart = $dates[$count];
|
71 |
+
$dateEnd = $dates[$count+1];
|
72 |
+
}else{
|
73 |
+
|
74 |
+
$dateStart = date('Y-m-d 00:00:00',strtotime($date));
|
75 |
+
$dateEnd = date('Y-m-d 23:59:59',strtotime($date));
|
76 |
+
}
|
77 |
+
$orderByDate = $orderCollectionByDate->addAttributeToFilter('created_at', array('from'=>$dateStart, 'to'=>$dateEnd));
|
78 |
+
$orderByDate->getSelect()->columns('SUM(grand_total) AS grand_total_sum');
|
79 |
+
$orderByDate->getSelect()->group(array('store_id'));
|
80 |
+
$orderdata= $orderByDate->getData();
|
81 |
+
if(count($orderByDate) == 0)
|
82 |
+
{
|
83 |
+
if ($type_id==24){
|
84 |
+
$orderTotalByDate[date("Y-m-d H:i",strtotime($date))] = 0;
|
85 |
+
}else if ($type_id=='month'){
|
86 |
+
$orderTotalByDate[date('d',strtotime($date))] = 0;
|
87 |
+
}else{
|
88 |
+
$orderTotalByDate[$date] = 0;
|
89 |
+
}
|
90 |
+
}
|
91 |
+
else{
|
92 |
+
if ($type_id==24){
|
93 |
+
$ordersByDate[date("Y-m-d H:i",strtotime($date))][] = $orderdata[0]['grand_total_sum'];
|
94 |
+
$orderTotalByDate[date("Y-m-d H:i",strtotime($date))] = array_sum($ordersByDate[date("Y-m-d H:i",strtotime($date))]);
|
95 |
+
}else if ($type_id=='month'){
|
96 |
+
$ordersByDate[date('d',strtotime($date))][] = $orderdata[0]['grand_total_sum'];
|
97 |
+
$orderTotalByDate[date('d',strtotime($date))] = array_sum($ordersByDate[date('d',strtotime($date))]);
|
98 |
+
}else{
|
99 |
+
$ordersByDate[$date][] = $orderdata[0]['grand_total_sum'];
|
100 |
+
$orderTotalByDate[$date] = array_sum($ordersByDate[$date]);
|
101 |
+
}
|
102 |
+
|
103 |
+
|
104 |
+
}
|
105 |
+
|
106 |
+
$count++;
|
107 |
+
}
|
108 |
+
}else{
|
109 |
+
$end_date = date ('Y-m-d');
|
110 |
+
$start_date = date ('Y-01-01');
|
111 |
+
$orderCollection->addAttributeToFilter('created_at', array('from'=>$start_date, 'to'=>$end_date));
|
112 |
+
$total_count = count($orderCollection);
|
113 |
+
$months = $this->get_months($start_date, $end_date);
|
114 |
+
$current_year = date("Y");
|
115 |
+
foreach ($months as $month){
|
116 |
+
$first_day = $this->firstDay($month,$current_year);
|
117 |
+
$ordersByDate = array();
|
118 |
+
if ($month==date('F'))
|
119 |
+
$last_day = date ('Y-m-d');
|
120 |
+
else
|
121 |
+
$last_day = $this->lastday($month,$current_year);
|
122 |
+
|
123 |
+
$dates = $this->getDatesFromRange($first_day, $last_day);
|
124 |
+
|
125 |
+
foreach($dates as $date)
|
126 |
+
{
|
127 |
+
$orderCollectionByDate = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('store_id',Array('eq'=>$storeId))->addFieldToFilter('status',Array('eq'=>'complete'))->setOrder('entity_id', 'desc');
|
128 |
+
$dateStart = date('Y-m-d 00:00:00',strtotime($date));
|
129 |
+
$dateEnd = date('Y-m-d 23:59:59',strtotime($date));
|
130 |
+
$orderByDate = $orderCollectionByDate->addAttributeToFilter('created_at', array('from'=>$dateStart, 'to'=>$dateEnd));
|
131 |
+
$orderByDate->getSelect()->columns('SUM(grand_total) AS grand_total_sum');
|
132 |
+
$orderByDate->getSelect()->group(array('store_id'));
|
133 |
+
$orderdata= $orderByDate->getData();
|
134 |
+
$ordersByDate[] = $orderdata[0]['grand_total_sum'];
|
135 |
+
}
|
136 |
+
|
137 |
+
$orderTotalByDate[$month] = array_sum($ordersByDate);
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
$baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
|
142 |
+
|
143 |
+
$orderGrandTotal = strip_tags(Mage::app()->getLocale()->currency($baseCurrencyCode)->toCurrency(array_sum($orderTotalByDate)));
|
144 |
+
$lifeTimeSales = strip_tags(Mage::app()->getLocale()->currency($baseCurrencyCode)->toCurrency(round(Mage::getResourceModel('reports/order_collection')->addFieldToFilter('store_id', $storeId)->calculateSales()->load()->getFirstItem()->getLifetime(),2)));
|
145 |
+
$averageOrder = strip_tags(Mage::app()->getLocale()->currency($baseCurrencyCode)->toCurrency(round(Mage::getResourceModel('reports/order_collection')->addFieldToFilter('store_id', $storeId)->calculateSales()->load()->getFirstItem()->getAverage(),2)));
|
146 |
+
|
147 |
+
$orderTotalResultArr = array('dashboard_result' =>array('ordertotalbydate' => $orderTotalByDate,'ordergrandtotal' => $orderGrandTotal,'totalordercount' => $total_count,'lifetimesales' => $lifeTimeSales,'averageorder' => $averageOrder));
|
148 |
+
$orderDashboardResult = Mage::helper('core')->jsonEncode($orderTotalResultArr);
|
149 |
+
return Mage::app()->getResponse()->setBody($orderDashboardResult);
|
150 |
+
}else{
|
151 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
152 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
public function getDatesFromRange($start_date, $end_date)
|
157 |
+
{
|
158 |
+
$date_from = strtotime(date('Y-m-d', strtotime($start_date)));
|
159 |
+
$date_to = strtotime(date('Y-m-d', strtotime($end_date)));
|
160 |
+
|
161 |
+
for ($i=$date_from; $i<=$date_to; $i+=86400) {
|
162 |
+
$dates[] = date("Y-m-d", $i);
|
163 |
+
}
|
164 |
+
return $dates;
|
165 |
+
}
|
166 |
+
|
167 |
+
public function getNewestCustomerAction()
|
168 |
+
{
|
169 |
+
if(Mage::helper('mobileassistant')->isEnable()){
|
170 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
171 |
+
$sessionId = $post_data['session'];
|
172 |
+
if (!Mage::getSingleton('api/session')->isLoggedIn($sessionId)) {
|
173 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
174 |
+
return false;
|
175 |
+
}
|
176 |
+
|
177 |
+
$storeId =$post_data['storeid'];
|
178 |
+
$baseCurrencyCode = (string) Mage::app()->getStore($storeId)->getBaseCurrencyCode();
|
179 |
+
|
180 |
+
$collection = Mage::getResourceModel('reports/customer_collection')->addCustomerName();
|
181 |
+
$storeFilter = 0;
|
182 |
+
if ($storeId) {
|
183 |
+
$collection->addAttributeToFilter('store_id', $storeId);
|
184 |
+
$storeFilter = 1;
|
185 |
+
}
|
186 |
+
$collection->addOrdersStatistics($storeFilter)->orderByCustomerRegistration();
|
187 |
+
|
188 |
+
foreach($collection as $_collection)
|
189 |
+
{
|
190 |
+
$newestCustomer[] = array(
|
191 |
+
'name' => $_collection->getName(),
|
192 |
+
'email' => $_collection->getEmail(),
|
193 |
+
'orders_count' => $_collection->getOrdersCount(),
|
194 |
+
'average_order_amount'=>Mage::app()->getLocale()->currency($baseCurrencyCode)->toCurrency(Mage::helper('mobileassistant')->getPriceFormat($_collection->getOrdersAvgAmount())),
|
195 |
+
'total_order_amount' => Mage::app()->getLocale()->currency($baseCurrencyCode)->toCurrency(Mage::helper('mobileassistant')->getPriceFormat($_collection->getOrdersSumAmount()))
|
196 |
+
);
|
197 |
+
}
|
198 |
+
|
199 |
+
$NewestCustomerResult = Mage::helper('core')->jsonEncode($newestCustomer);
|
200 |
+
return Mage::app()->getResponse()->setBody($NewestCustomerResult);
|
201 |
+
}else{
|
202 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
203 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
function get_months($date1, $date2) {
|
208 |
+
$time1 = strtotime($date1);
|
209 |
+
$time2 = strtotime($date2);
|
210 |
+
$my = date('mY', $time2);
|
211 |
+
$months = array();
|
212 |
+
$f = '';
|
213 |
+
|
214 |
+
while($time1 < $time2) {
|
215 |
+
$time1 = strtotime((date('Y-m-d', $time1).' +15days'));
|
216 |
+
|
217 |
+
if(date('m', $time1) != $f) {
|
218 |
+
$f = date('m', $time1);
|
219 |
+
|
220 |
+
if(date('mY', $time1) != $my && ($time1 < $time2))
|
221 |
+
$months[] = date('m', $time1);
|
222 |
+
}
|
223 |
+
|
224 |
+
}
|
225 |
+
|
226 |
+
$months[] = date('m', $time2);
|
227 |
+
return $months;
|
228 |
+
}
|
229 |
+
|
230 |
+
function lastday($month = '', $year = '') {
|
231 |
+
if (empty($month)) {
|
232 |
+
$month = date('m');
|
233 |
+
}
|
234 |
+
if (empty($year)) {
|
235 |
+
$year = date('Y');
|
236 |
+
}
|
237 |
+
$result = strtotime("{$year}-{$month}-01");
|
238 |
+
$result = strtotime('-1 day', strtotime('+1 month', $result));
|
239 |
+
return date('Y-m-d', $result);
|
240 |
+
}
|
241 |
+
|
242 |
+
function firstDay($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 |
+
return date('Y-m-d', $result);
|
251 |
+
}
|
252 |
}
|
app/code/local/Biztech/Mobileassistant/controllers/IndexController.php
CHANGED
@@ -1,178 +1,190 @@
|
|
1 |
-
<?php
|
2 |
-
class Biztech_Mobileassistant_IndexController extends Mage_Core_Controller_Front_Action
|
3 |
-
{
|
4 |
-
public function indexAction()
|
5 |
-
{
|
6 |
-
if(Mage::getStoreConfig('mobileassistant/mobileassistant_general/enabled')){
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
$
|
40 |
-
$
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
}
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
$
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
$
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
$
|
154 |
-
|
155 |
-
$
|
156 |
-
$
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
}
|
1 |
+
<?php
|
2 |
+
class Biztech_Mobileassistant_IndexController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
+
public function indexAction()
|
5 |
+
{
|
6 |
+
if(Mage::getStoreConfig('mobileassistant/mobileassistant_general/enabled')){
|
7 |
+
|
8 |
+
if(class_exists("SOAPClient") == false)
|
9 |
+
{
|
10 |
+
$result['error'] = $this->__('It seems you have php extension: SOAP disabled in your server. Please enable.');
|
11 |
+
$jsonData = Mage::helper('core')->jsonEncode($result);
|
12 |
+
return Mage::app()->getResponse()->setBody($jsonData);
|
13 |
+
}
|
14 |
+
|
15 |
+
|
16 |
+
$isSecure = Mage::app()->getFrontController()->getRequest()->isSecure();
|
17 |
+
$validate_url = false;
|
18 |
+
if($isSecure)
|
19 |
+
{
|
20 |
+
if(Mage::getStoreConfig('web/secure/base_url') == Mage::getStoreConfig('web/secure/base_link_url')){
|
21 |
+
$validate_url = true;
|
22 |
+
}
|
23 |
+
}else
|
24 |
+
{
|
25 |
+
if(Mage::getStoreConfig('web/unsecure/base_url') == Mage::getStoreConfig('web/unsecure/base_link_url')){
|
26 |
+
$validate_url = true;
|
27 |
+
}
|
28 |
+
}
|
29 |
+
if($validate_url){
|
30 |
+
$details = Mage::app()->getRequest()->getParams();
|
31 |
+
$user = $details['userapi'];
|
32 |
+
$api_key = $details['keyapi'];
|
33 |
+
$deviceToken = $details['token'];
|
34 |
+
$flag = $details['notification_flag'];
|
35 |
+
$device_type = $details['device_type'];
|
36 |
+
$url = $details['magento_url'].'api/soap?wsdl';
|
37 |
+
|
38 |
+
try{
|
39 |
+
$soap = new SoapClient($url);
|
40 |
+
$session_id = $soap->login($user, $api_key);
|
41 |
+
}
|
42 |
+
catch(SoapFault $fault){
|
43 |
+
$result['error'] = $fault->getMessage();
|
44 |
+
$jsonData = Mage::helper('core')->jsonEncode($result);
|
45 |
+
return Mage::app()->getResponse()->setBody($jsonData);
|
46 |
+
}
|
47 |
+
if($session_id){
|
48 |
+
$data[] = array('user' => $user,'key' => $api_key,'devicetoken'=>$deviceToken,'session_id' => $session_id,'notification_flag'=> $flag,'device_type'=> $device_type,'is_logout'=> 0);
|
49 |
+
$result = $soap->call($session_id,'mobileassistant.create',$data);
|
50 |
+
$jsonData = Mage::helper('core')->jsonEncode($result);
|
51 |
+
return Mage::app()->getResponse()->setBody($jsonData);
|
52 |
+
}
|
53 |
+
}else{
|
54 |
+
$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.');
|
55 |
+
}
|
56 |
+
}else{
|
57 |
+
$result['error'] = $this->__('Please activate the Mobile Assistant Extension on the Magento Store.');
|
58 |
+
}
|
59 |
+
$jsonData = Mage::helper('core')->jsonEncode($result);
|
60 |
+
return Mage::app()->getResponse()->setBody($jsonData);
|
61 |
+
}
|
62 |
+
|
63 |
+
public function testModuleAction()
|
64 |
+
{
|
65 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
66 |
+
$url = $post_data['magento_url'];
|
67 |
+
$url_info = parse_url($url);
|
68 |
+
|
69 |
+
if(Mage::getConfig()->getModuleConfig('Biztech_Mobileassistant')->is('active', 'true') && Mage::getStoreConfig('mobileassistant/mobileassistant_general/enabled'))
|
70 |
+
{
|
71 |
+
|
72 |
+
$isSecure = Mage::app()->getFrontController()->getRequest()->isSecure();
|
73 |
+
$validate_url = false;
|
74 |
+
if($isSecure)
|
75 |
+
{
|
76 |
+
if(Mage::getStoreConfig('web/secure/base_url') == Mage::getStoreConfig('web/secure/base_link_url')){
|
77 |
+
$validate_url = true;
|
78 |
+
}
|
79 |
+
|
80 |
+
if($url_info['scheme'] == 'http')
|
81 |
+
{
|
82 |
+
$result['error'] = $this->__('It seems you use secure url for your store. So please use "https". ');
|
83 |
+
$jsonData = Mage::helper('core')->jsonEncode($result);
|
84 |
+
return Mage::app()->getResponse()->setBody($jsonData);
|
85 |
+
}
|
86 |
+
|
87 |
+
}else{
|
88 |
+
if(Mage::getStoreConfig('web/unsecure/base_url') == Mage::getStoreConfig('web/unsecure/base_link_url')){
|
89 |
+
$validate_url = true;
|
90 |
+
}
|
91 |
+
}
|
92 |
+
if($validate_url){
|
93 |
+
|
94 |
+
$is_index = Mage::getStoreConfig('web/seo/use_rewrites');
|
95 |
+
if(!$is_index && basename($url) != 'index.php')
|
96 |
+
{
|
97 |
+
$result['error'] = $this->__('Please add "index.php" after your url.');
|
98 |
+
$jsonData = Mage::helper('core')->jsonEncode($result);
|
99 |
+
return Mage::app()->getResponse()->setBody($jsonData);
|
100 |
+
}
|
101 |
+
|
102 |
+
$result['success'] = $this->__('Hurray! The connection with the Magento Site worked out fine & you can start using the App.');
|
103 |
+
}else{
|
104 |
+
$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.');
|
105 |
+
}
|
106 |
+
}else{
|
107 |
+
$result['error'] = $this->__('Please activate the Mobile Assistant Extension on the Magento Store.');
|
108 |
+
}
|
109 |
+
$jsonData = Mage::helper('core')->jsonEncode($result);
|
110 |
+
return Mage::app()->getResponse()->setBody($jsonData);
|
111 |
+
}
|
112 |
+
|
113 |
+
public function changeSettingsAction()
|
114 |
+
{
|
115 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
116 |
+
$user = $post_data['userapi'];
|
117 |
+
$deviceToken = $post_data['token'];
|
118 |
+
$flag = $post_data['notification_flag'];
|
119 |
+
$collections = Mage::getModel("mobileassistant/mobileassistant")->getCollection()->addFieldToFilter('username',Array('eq'=>$user))->addFieldToFilter('device_token',Array('eq'=>$deviceToken));
|
120 |
+
$count = count($collections);
|
121 |
+
|
122 |
+
foreach($collections as $user)
|
123 |
+
{
|
124 |
+
$user_id = $user->getUserId();
|
125 |
+
}
|
126 |
+
if($count == 1)
|
127 |
+
{
|
128 |
+
try {
|
129 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
130 |
+
$connection->beginTransaction();
|
131 |
+
$fields = array();
|
132 |
+
$fields['notification_flag'] = $flag;
|
133 |
+
$where = $connection->quoteInto('user_id =?', $user_id);
|
134 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
135 |
+
$connection->update($prefix.'mobileassistant', $fields, $where);
|
136 |
+
$connection->commit();
|
137 |
+
} catch (Exception $e){
|
138 |
+
return $e->getMessage();
|
139 |
+
}
|
140 |
+
$successArr[] = array('success_msg' => 'Settings updated sucessfully') ;
|
141 |
+
$result = Mage::helper('core')->jsonEncode($successArr);
|
142 |
+
return Mage::app()->getResponse()->setBody($result);
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
public function getLogoAndCurrencyAction()
|
147 |
+
{
|
148 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
149 |
+
$storeId = $post_data['storeid'];
|
150 |
+
$block = new Mage_Page_Block_Html_Header();
|
151 |
+
$logo = $block->getLogoSrc();
|
152 |
+
|
153 |
+
$currency_code = Mage::getModel('core/store')->load($storeId)->getCurrentCurrencyCode();
|
154 |
+
|
155 |
+
$isPos = 0;
|
156 |
+
$resultArr = array('logo' => $logo,'currency_symbol' => Mage::app()->getLocale()->currency($currency_code)->getSymbol(),'is_pos' => $isPos);
|
157 |
+
$result = Mage::helper('core')->jsonEncode($resultArr);
|
158 |
+
return Mage::app()->getResponse()->setBody($result);
|
159 |
+
}
|
160 |
+
|
161 |
+
public function logoutAction()
|
162 |
+
{
|
163 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
164 |
+
$user = $post_data['userapi'];
|
165 |
+
$deviceToken = $post_data['token'];
|
166 |
+
$collections = Mage::getModel("mobileassistant/mobileassistant")->getCollection()->addFieldToFilter('device_token',Array('eq'=>$deviceToken));
|
167 |
+
$count = count($collections);
|
168 |
+
|
169 |
+
foreach($collections as $user)
|
170 |
+
{
|
171 |
+
$device_token = $user->getDeviceToken();
|
172 |
+
|
173 |
+
try {
|
174 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
175 |
+
$connection->beginTransaction();
|
176 |
+
$fields = array();
|
177 |
+
$fields['is_logout'] = 1;
|
178 |
+
$where = $connection->quoteInto('device_token =?', $device_token);
|
179 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
180 |
+
$connection->update($prefix.'mobileassistant', $fields, $where);
|
181 |
+
$connection->commit();
|
182 |
+
} catch (Exception $e){
|
183 |
+
return $e->getMessage();
|
184 |
+
}
|
185 |
+
$successArr[] = array('success_msg' => 'User logout successfully.') ;
|
186 |
+
$result = Mage::helper('core')->jsonEncode($successArr);
|
187 |
+
return Mage::app()->getResponse()->setBody($result);
|
188 |
+
}
|
189 |
+
}
|
190 |
}
|
app/code/local/Biztech/Mobileassistant/controllers/OrderController.php
CHANGED
@@ -1,293 +1,305 @@
|
|
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 |
-
if (!Mage::getSingleton('api/session')->isLoggedIn($sessionId)) {
|
10 |
-
echo $this->__("The Login has expired. Please try log in again.");
|
11 |
-
return false;
|
12 |
-
}
|
13 |
-
|
14 |
-
$limit = $post_data['limit'];
|
15 |
-
$storeId = $post_data['storeid'];
|
16 |
-
$offset = $post_data['offset'];
|
17 |
-
$is_refresh = $post_data['is_refresh'];
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
$
|
26 |
-
$
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
'
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
$
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
$
|
69 |
-
$
|
70 |
-
$
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
$
|
86 |
-
|
87 |
-
|
88 |
-
$
|
89 |
-
$orderCollection->addAttributeToFilter('created_at', array('from'=>$dateStart, 'to'=>$dateEnd));
|
90 |
-
}elseif($filter_by_date ==
|
91 |
-
$
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
$
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
$
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
$
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
'
|
153 |
-
'
|
154 |
-
'
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
'
|
165 |
-
'
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
)
|
178 |
-
|
179 |
-
|
180 |
-
$
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
'
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
'
|
198 |
-
'
|
199 |
-
);
|
200 |
-
|
201 |
-
$
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
$
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
$
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
}
|
291 |
-
return $
|
292 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
}
|
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 |
+
if (!Mage::getSingleton('api/session')->isLoggedIn($sessionId)) {
|
10 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
11 |
+
return false;
|
12 |
+
}
|
13 |
+
|
14 |
+
$limit = $post_data['limit'];
|
15 |
+
$storeId = $post_data['storeid'];
|
16 |
+
$offset = $post_data['offset'];
|
17 |
+
$is_refresh = $post_data['is_refresh'];
|
18 |
+
$source = $post_data['source'];
|
19 |
+
|
20 |
+
$orderCollection = Mage::getResourceModel('sales/order_grid_collection')->addFieldToFilter('store_id',Array('eq'=>$storeId))->setOrder('entity_id', 'desc');
|
21 |
+
if($offset != null){
|
22 |
+
$orderCollection->addAttributeToFilter('entity_id', array('lt' => $offset));
|
23 |
+
}
|
24 |
+
if($is_refresh == 1){
|
25 |
+
$last_fetch_order = $post_data['last_fetch_order'];
|
26 |
+
$min_fetch_order = $post_data['min_fetch_order'];
|
27 |
+
$last_updated = Mage::helper('mobileassistant')->getActualDate($post_data['last_updated']);
|
28 |
+
|
29 |
+
$orderCollection->getSelect()->where("(entity_id BETWEEN '".$min_fetch_order."'AND '".$last_fetch_order ."' AND updated_at > '".$last_updated."') OR entity_id >'".$last_fetch_order."'");
|
30 |
+
}
|
31 |
+
|
32 |
+
$orderCollection->getSelect()->limit($limit);
|
33 |
+
|
34 |
+
foreach($orderCollection as $order){
|
35 |
+
if($source == 'dashboard')
|
36 |
+
{
|
37 |
+
$grand_total = Mage::helper('mobileassistant')->getPrice($order->getBaseGrandTotal(),$order->getStoreId(),$order->getBaseCurrencyCode());
|
38 |
+
}else{
|
39 |
+
$grand_total = Mage::helper('mobileassistant')->getPrice($order->getGrandTotal(),$order->getStoreId(),$order->getOrderCurrencyCode());
|
40 |
+
}
|
41 |
+
|
42 |
+
$orderListData[] = array(
|
43 |
+
'entity_id' => $order->getEntityId(),
|
44 |
+
'increment_id' => $order->getIncrementId(),
|
45 |
+
'store_id' => $order->getStoreId(),
|
46 |
+
'customer_name' => $order->getBillingName(),
|
47 |
+
'status' => $order->getStatus(),
|
48 |
+
'order_date' => Mage::helper('mobileassistant')->getActualOrderDate($order->getCreatedAt()),
|
49 |
+
'grand_total' => $grand_total,
|
50 |
+
'toal_qty' => Mage::getModel('sales/order')->load($order->getEntityId())->getTotalQtyOrdered(),
|
51 |
+
'total_items' => count($order->getAllItems())
|
52 |
+
);
|
53 |
+
}
|
54 |
+
|
55 |
+
$updated_time = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
|
56 |
+
$orderListResultArr = array('orderlistdata' => $orderListData,'updated_time' =>$updated_time);
|
57 |
+
$orderListResult = Mage::helper('core')->jsonEncode($orderListResultArr);
|
58 |
+
return Mage::app()->getResponse()->setBody($orderListResult);
|
59 |
+
}else{
|
60 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
61 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
public function getFilterOrderListAction()
|
66 |
+
{
|
67 |
+
if(Mage::helper('mobileassistant')->isEnable()){
|
68 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
69 |
+
$storeId = $post_data['storeid'];
|
70 |
+
$sessionId = $post_data['session'];
|
71 |
+
|
72 |
+
if (!Mage::getSingleton('api/session')->isLoggedIn($sessionId)) {
|
73 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
74 |
+
return false;
|
75 |
+
}
|
76 |
+
$filter_by_date = $post_data['filter_by_date'];
|
77 |
+
$filter_by_status = $post_data['filter_by_status'];
|
78 |
+
$search_by_id = $post_data['search_by_id'];
|
79 |
+
$now = Mage::getModel('core/date')->timestamp(time());
|
80 |
+
$orderCollection = Mage::getResourceModel('sales/order_grid_collection')->addFieldToFilter('store_id',Array('eq'=>$storeId))->setOrder('entity_id', 'desc');
|
81 |
+
|
82 |
+
if($filter_by_date != null){
|
83 |
+
$dateEnd = date('Y-m-d 23:59:59', $now);
|
84 |
+
if($filter_by_date == 1){
|
85 |
+
$dateStart = date('Y-m-d 00:00:00', $now);
|
86 |
+
$orderCollection->addAttributeToFilter('created_at', array('from'=>$dateStart, 'to'=>$dateEnd));
|
87 |
+
}elseif($filter_by_date == 2){
|
88 |
+
$dateStart = date('Y-m-d 00:00:00', strtotime('-6 days'));
|
89 |
+
$orderCollection->addAttributeToFilter('created_at', array('from'=>$dateStart, 'to'=>$dateEnd));
|
90 |
+
}elseif($filter_by_date == 3){
|
91 |
+
$dateStart = date('Y-m-01 00:00:00');
|
92 |
+
$orderCollection->addAttributeToFilter('created_at', array('from'=>$dateStart, 'to'=>$dateEnd));
|
93 |
+
}elseif($filter_by_date == 4){
|
94 |
+
$orderCollection->addAttributeToFilter('created_at', array("lt"=>$post_data['before_date']." 00:00:00"));
|
95 |
+
}elseif($filter_by_date == 5){
|
96 |
+
$dateStart = $post_data['start_date']." 00:00:00";
|
97 |
+
$dateEnd = $post_data['end_date']." 23:59:59";
|
98 |
+
$orderCollection->addAttributeToFilter('created_at', array('from'=>$dateStart, 'to'=>$dateEnd));
|
99 |
+
}elseif($filter_by_date == 6){
|
100 |
+
$orderCollection->addAttributeToFilter('created_at', array("gt"=>$post_data['after_date']." 23:59:59"));
|
101 |
+
}
|
102 |
+
}
|
103 |
+
if($filter_by_status != null){
|
104 |
+
$orderCollection->addFieldToFilter('status',Array('eq'=>$filter_by_status));
|
105 |
+
}
|
106 |
+
|
107 |
+
if($search_by_id != null){
|
108 |
+
$orderCollection->addFieldToFilter('increment_id',Array('like'=>'%'.$search_by_id.'%'));
|
109 |
+
}
|
110 |
+
foreach($orderCollection as $order){
|
111 |
+
|
112 |
+
$orderListData[] = array(
|
113 |
+
'entity_id' => $order->getEntityId(),
|
114 |
+
'increment_id' => $order->getIncrementId(),
|
115 |
+
'store_id' => $order->getStoreId(),
|
116 |
+
'customer_name' => $order->getBillingName(),
|
117 |
+
'status' => $order->getStatus(),
|
118 |
+
'order_date' => Mage::helper('mobileassistant')->getActualOrderDate($order->getCreatedAt()),
|
119 |
+
'grand_total' => Mage::helper('mobileassistant')->getPrice($order->getGrandTotal(),$order->getStoreId(),$order->getOrderCurrencyCode()),
|
120 |
+
'toal_qty' => Mage::getModel('sales/order')->load($order->getEntityId())->getTotalQtyOrdered(),
|
121 |
+
'total_items' => count($order->getAllItems())
|
122 |
+
);
|
123 |
+
}
|
124 |
+
$orderListResultArr = array('orderlistdata' => $orderListData);
|
125 |
+
$orderListResult = Mage::helper('core')->jsonEncode($orderListResultArr);
|
126 |
+
return Mage::app()->getResponse()->setBody($orderListResult);
|
127 |
+
}else{
|
128 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
129 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
public function getOrderDetailAction()
|
134 |
+
{
|
135 |
+
if(Mage::helper('mobileassistant')->isEnable()){
|
136 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
137 |
+
$sessionId = $post_data['session'];
|
138 |
+
$storeId = $post_data['storeid'];
|
139 |
+
if (!Mage::getSingleton('api/session')->isLoggedIn($sessionId)) {
|
140 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
141 |
+
return false;
|
142 |
+
}
|
143 |
+
|
144 |
+
$order_id = $post_data['entity_id'];
|
145 |
+
$order = Mage::getModel('sales/order')->load($order_id);
|
146 |
+
|
147 |
+
$order_detail = array(
|
148 |
+
'entity_id' => $order->getEntityId(),
|
149 |
+
'increment_id' => $order->getIncrementId(),
|
150 |
+
'status' => $order->getStatus(),
|
151 |
+
'order_date' => Mage::helper('mobileassistant')->getActualOrderDate($order->getCreatedAt()),
|
152 |
+
'total_qty' => $order->getTotalQtyOrdered(),
|
153 |
+
'total_items' => count($order->getAllItems()),
|
154 |
+
'grand_total' => Mage::helper('mobileassistant')->getPrice($order->getGrandTotal(),$order->getStoreId(),$order->getOrderCurrencyCode()),
|
155 |
+
'sub_total' => Mage::helper('mobileassistant')->getPrice($order->getSubtotal(),$order->getStoreId(),$order->getOrderCurrencyCode()),
|
156 |
+
'discount' => Mage::helper('mobileassistant')->getPrice($order->getDiscountAmount(),$order->getStoreId(),$order->getOrderCurrencyCode()),
|
157 |
+
'tax' => Mage::helper('mobileassistant')->getPrice($order->getTax(),$order->getStoreId(),$order->getOrderCurrencyCode())
|
158 |
+
);
|
159 |
+
|
160 |
+
$customer_id = $order->getCustomerId();
|
161 |
+
$customer_name = $order->getCustomerFirstname()." ".$order->getCustomerLastname();
|
162 |
+
if($customer_id == null){$customer_name = $order->getCustomerName();}
|
163 |
+
$customer_detail = array(
|
164 |
+
'customer_id' => $customer_id,
|
165 |
+
'customer_name' => $customer_name,
|
166 |
+
'customer_email' => $order->getCustomerEmail()
|
167 |
+
);
|
168 |
+
|
169 |
+
$billing_address = $order->getBillingAddress();
|
170 |
+
$billing_address_data = array(
|
171 |
+
'name' => $billing_address->getFirstname().' '.$billing_address->getLastname(),
|
172 |
+
'street' => $billing_address->getData('street'),
|
173 |
+
'city' => $billing_address->getCity(),
|
174 |
+
'region' => $billing_address->getRegion(),
|
175 |
+
'postcode' => $billing_address->getPostcode(),
|
176 |
+
'country' => Mage::getModel('directory/country')->loadByCode($billing_address->getCountryId())->getName(),
|
177 |
+
'telephone' => $billing_address->getTelephone()
|
178 |
+
);
|
179 |
+
$shipping_address = $order->getShippingAddress();
|
180 |
+
if($shipping_address){
|
181 |
+
$shipping_address_data = array(
|
182 |
+
'name' => $shipping_address->getFirstname().' '.$shipping_address->getLastname(),
|
183 |
+
'street' => $shipping_address->getData('street'),
|
184 |
+
'city' => $shipping_address->getCity(),
|
185 |
+
'region' => $shipping_address->getRegion(),
|
186 |
+
'postcode' => $shipping_address->getPostcode(),
|
187 |
+
'country' => Mage::getModel('directory/country')->loadByCode($shipping_address->getCountryId())->getName(),
|
188 |
+
'telephone' => $shipping_address->getTelephone()
|
189 |
+
);
|
190 |
+
}
|
191 |
+
|
192 |
+
$payment_info = array(
|
193 |
+
'payment_method' => $order->getPayment()->getMethodInstance()->getTitle()
|
194 |
+
);
|
195 |
+
|
196 |
+
$shipping_info = array(
|
197 |
+
'shipping_method' => $order->getShippingDescription(),
|
198 |
+
'shipping_charge' => Mage::helper('mobileassistant')->getPrice($order->getShippingAmount(),$order->getStoreId(),$order->getOrderCurrencyCode())
|
199 |
+
);
|
200 |
+
|
201 |
+
$products_detail = $this->_orderedProductDetails($order_id);
|
202 |
+
|
203 |
+
$full_order_detail = array(
|
204 |
+
'basic_order_detail' => $order_detail,
|
205 |
+
'customer_detail' => $customer_detail,
|
206 |
+
'billing_address' => $billing_address_data,
|
207 |
+
'shipping_address' => $shipping_address_data,
|
208 |
+
'payment_info' => $payment_info,
|
209 |
+
'shipping_info' => $shipping_info,
|
210 |
+
'product_detail' => $products_detail
|
211 |
+
);
|
212 |
+
$orderDetailResultArr = array('orderlistdata' => $full_order_detail);
|
213 |
+
$orderDetailResult = Mage::helper('core')->jsonEncode($orderDetailResultArr);
|
214 |
+
return Mage::app()->getResponse()->setBody($orderDetailResult);
|
215 |
+
}else{
|
216 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
217 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
218 |
+
}
|
219 |
+
}
|
220 |
+
|
221 |
+
protected function _orderedProductDetails($order_id)
|
222 |
+
{
|
223 |
+
$order = Mage::getModel('sales/order')->load($order_id);
|
224 |
+
foreach ($order->getItemsCollection() as $item) {
|
225 |
+
$options = $item->getProductOptions();
|
226 |
+
if($item->getProductType() == "downloadable"){
|
227 |
+
$obj = new Mage_Downloadable_Block_Adminhtml_Sales_Items_Column_Downloadable_Name();
|
228 |
+
foreach($options['links'] as $links)
|
229 |
+
{
|
230 |
+
|
231 |
+
$this->_purchased = Mage::getModel('downloadable/link_purchased')
|
232 |
+
->load($order_id, 'order_id');
|
233 |
+
$purchasedItem = Mage::getModel('downloadable/link_purchased_item')->getCollection()
|
234 |
+
->addFieldToFilter('order_item_id', $item->getId());
|
235 |
+
$this->_purchased->setPurchasedItems($purchasedItem);
|
236 |
+
|
237 |
+
foreach ($this->_purchased->getPurchasedItems() as $_link){
|
238 |
+
$links_value[] = $_link->getLinkTitle().'('. $_link->getNumberOfDownloadsUsed() . ' / ' . ($_link->getNumberOfDownloadsBought() ? $_link->getNumberOfDownloadsBought() : Mage::helper('downloadable')->__('U')) .')';
|
239 |
+
}
|
240 |
+
|
241 |
+
$info = array(array(
|
242 |
+
'label' => $obj->getLinksTitle(),
|
243 |
+
'value' => implode(',',$links_value)
|
244 |
+
));
|
245 |
+
}
|
246 |
+
|
247 |
+
}else{
|
248 |
+
|
249 |
+
$result = array();
|
250 |
+
if ($options = $item->getProductOptions()) {
|
251 |
+
if (isset($options['options'])) {
|
252 |
+
$result = array_merge($result, $options['options']);
|
253 |
+
}
|
254 |
+
if (isset($options['additional_options'])) {
|
255 |
+
$result = array_merge($result, $options['additional_options']);
|
256 |
+
}
|
257 |
+
if (!empty($options['attributes_info'])) {
|
258 |
+
$result = array_merge($options['attributes_info'], $result);
|
259 |
+
}
|
260 |
+
}
|
261 |
+
|
262 |
+
$info = array();
|
263 |
+
if($result)
|
264 |
+
{
|
265 |
+
foreach ($result as $_option){
|
266 |
+
$info[] = array(
|
267 |
+
'label' => $_option['label'],
|
268 |
+
'value' => $_option['value']
|
269 |
+
);
|
270 |
+
}
|
271 |
+
}
|
272 |
+
}
|
273 |
+
$skus = '';
|
274 |
+
$product = Mage::getModel('catalog/product')->load($item->getProductId());
|
275 |
+
if ($item->getParentItem()) continue;
|
276 |
+
if ($_options = $this->_getItemOptions($item)) {
|
277 |
+
$skus = $_options;
|
278 |
+
}
|
279 |
+
$products_detail[] = array(
|
280 |
+
'product_id' => $item->getProductId(),
|
281 |
+
'name' => $item->getName(),
|
282 |
+
'sku' => $item->getSku(),
|
283 |
+
'unit_price' => Mage::helper('mobileassistant')->getPrice($item->getOriginalPrice(),$order->getStoreId(),$order->getOrderCurrencyCode()),
|
284 |
+
'ordered_qty' => round($item->getQtyOrdered(), 2),
|
285 |
+
'row_total' => Mage::helper('mobileassistant')->getPrice($item->getRowTotal(),$order->getStoreId(),$order->getOrderCurrencyCode()),
|
286 |
+
'options' => $skus ? $skus : '',
|
287 |
+
'image' => ($product->getImage())?Mage::helper('catalog/image')->init($product, 'image',$product->getImage())->resize(300,330)->keepAspectRatio(true)->constrainOnly(true)->__toString():'N/A',
|
288 |
+
'attribute_info' => $info ? $info : ''
|
289 |
+
);
|
290 |
+
}
|
291 |
+
return $products_detail;
|
292 |
+
}
|
293 |
+
|
294 |
+
private function _getItemOptions($item)
|
295 |
+
{
|
296 |
+
$id = array('id' => $item->getItemId());
|
297 |
+
$order_items = Mage::getModel('sales/order_item')->getCollection()->addFieldToFilter('parent_item_id',Array('eq'=>$id));
|
298 |
+
foreach($order_items as $order_item)
|
299 |
+
{
|
300 |
+
$product_data = Mage::getModel('catalog/product')->load($order_item->getProductId());
|
301 |
+
$skus[] = $product_data->getSku();
|
302 |
+
}
|
303 |
+
return $skus;
|
304 |
+
}
|
305 |
}
|
app/code/local/Biztech/Mobileassistant/controllers/ProductController.php
CHANGED
@@ -1,222 +1,285 @@
|
|
1 |
-
<?php
|
2 |
-
class Biztech_Mobileassistant_ProductController extends Mage_Core_Controller_Front_Action
|
3 |
-
{
|
4 |
-
public function getProductListAction()
|
5 |
-
{
|
6 |
-
if(Mage::helper('mobileassistant')->isEnable()){
|
7 |
-
|
8 |
-
$
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
$
|
15 |
-
$
|
16 |
-
$
|
17 |
-
$
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
$
|
29 |
-
$
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
$
|
39 |
-
|
40 |
-
|
41 |
-
$
|
42 |
-
|
43 |
-
|
44 |
-
'
|
45 |
-
'
|
46 |
-
'
|
47 |
-
'
|
48 |
-
'
|
49 |
-
'
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
$
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
$
|
75 |
-
$
|
76 |
-
$
|
77 |
-
|
78 |
-
if($
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
$
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
'
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
$
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
'
|
116 |
-
'
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
$
|
149 |
-
|
150 |
-
|
151 |
-
$
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
$
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
}
|
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 |
+
if (!Mage::getSingleton('api/session')->isLoggedIn($sessionId)) {
|
11 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
12 |
+
return false;
|
13 |
+
}
|
14 |
+
$storeId = $post_data['storeid'];
|
15 |
+
$limit = $post_data['limit'];
|
16 |
+
$offset = $post_data['offset'];
|
17 |
+
$new_products = $post_data['last_fetch_product'];
|
18 |
+
$is_refresh = $post_data['is_refresh'];
|
19 |
+
|
20 |
+
|
21 |
+
$products = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($storeId)->setOrder('entity_id', 'desc');
|
22 |
+
if($offset != null){
|
23 |
+
$products->addAttributeToFilter('entity_id', array('lt' => $offset));
|
24 |
+
}
|
25 |
+
|
26 |
+
|
27 |
+
if($is_refresh == 1){
|
28 |
+
$last_fetch_product = $post_data['last_fetch_product'];
|
29 |
+
$min_fetch_product = $post_data['min_fetch_product'];
|
30 |
+
$last_updated = $post_data['last_updated'];
|
31 |
+
$products->getSelect()->where("(entity_id BETWEEN '".$min_fetch_product."'AND '".$last_fetch_product ."' AND updated_at > '".$last_updated."') OR entity_id >'".$last_fetch_product."'");
|
32 |
+
}
|
33 |
+
|
34 |
+
$products->getSelect()->limit($limit);
|
35 |
+
|
36 |
+
foreach($products as $product)
|
37 |
+
{
|
38 |
+
$product_data = Mage::getModel('catalog/product')->load($product->getId());
|
39 |
+
$status = $product_data->getStatus();
|
40 |
+
$qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product_data)->getQty();
|
41 |
+
if($status == 1){$status = 'Enabled';}else{$status = 'Disabled';}
|
42 |
+
if($qty == 0 || $product_data->getIsInStock() == 0){$qty = 'Out of Stock';}
|
43 |
+
$product_list[] = array(
|
44 |
+
'id' => $product->getId(),
|
45 |
+
'sku' => $product_data->getSku(),
|
46 |
+
'name' => $product_data->getName(),
|
47 |
+
'status' => $status,
|
48 |
+
'qty' => $qty,
|
49 |
+
'price' => Mage::helper('mobileassistant')->getPrice($product_data->getPrice(),$storeId),
|
50 |
+
'image' => ($product_data->getImage())?Mage::helper('catalog/image')->init($product, 'image',$product_data->getImage())->resize(300,330)->keepAspectRatio(true)->constrainOnly(true)->__toString():'N/A',
|
51 |
+
'type' => $product->getTypeId()
|
52 |
+
);
|
53 |
+
}
|
54 |
+
$updated_time = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
|
55 |
+
$productResultArr = array('productlistdata' => $product_list,'updated_time' =>$updated_time);
|
56 |
+
$productListResult = Mage::helper('core')->jsonEncode($productResultArr);
|
57 |
+
return Mage::app()->getResponse()->setBody($productListResult);
|
58 |
+
}else{
|
59 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
60 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
public function getProductDetailAction()
|
65 |
+
{
|
66 |
+
if(Mage::helper('mobileassistant')->isEnable()){
|
67 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
68 |
+
$sessionId = $post_data['session'];
|
69 |
+
if (!Mage::getSingleton('api/session')->isLoggedIn($sessionId)) {
|
70 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
71 |
+
return false;
|
72 |
+
}
|
73 |
+
try{
|
74 |
+
$storeId = $post_data['storeid'];
|
75 |
+
$productId = $post_data['productid'];
|
76 |
+
$productSku = $post_data['sku'];
|
77 |
+
|
78 |
+
if(isset($productSku) && $productSku != null)
|
79 |
+
{
|
80 |
+
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $productSku);
|
81 |
+
if($product)
|
82 |
+
{
|
83 |
+
$product_data = Mage::getModel('catalog/product')->load($product->getId());
|
84 |
+
}else{
|
85 |
+
$result = Mage::helper('core')->jsonEncode(array('mesage' => 'No product found.'));
|
86 |
+
return Mage::app()->getResponse()->setBody($result);
|
87 |
+
}
|
88 |
+
|
89 |
+
}else{
|
90 |
+
$product_data = Mage::getModel('catalog/product')->load($productId);
|
91 |
+
}
|
92 |
+
|
93 |
+
|
94 |
+
$pro_status = $product_data->getStatus();
|
95 |
+
$qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product_data)->getQty();
|
96 |
+
|
97 |
+
$_images = $product_data->getMediaGalleryImages();
|
98 |
+
if($_images){
|
99 |
+
foreach($_images as $_image){
|
100 |
+
$images[] = Mage::helper('catalog/image')->init($product_data, 'thumbnail', $_image->getFile())->resize(300,330)->keepAspectRatio(true)->constrainOnly(true)->__toString();
|
101 |
+
}
|
102 |
+
}
|
103 |
+
if($pro_status == 1){$pro_status = 'Enabled';}else{$pro_status = 'Disabled';}
|
104 |
+
|
105 |
+
if($product_data->getTypeId() == 'grouped'){
|
106 |
+
$associated_products = $product_data->getTypeInstance(true)->getAssociatedProducts($product_data);
|
107 |
+
}elseif($product_data->getTypeId() == 'configurable'){
|
108 |
+
$associated_products = $product_data->getTypeInstance()->getUsedProducts();
|
109 |
+
} elseif($product_data->getTypeId() == 'bundle'){
|
110 |
+
$associated_products = $product_data->getTypeInstance(true)->getSelectionsCollection($product_data->getTypeInstance(true)->getOptionsIds($product_data), $product_data);
|
111 |
+
}
|
112 |
+
foreach($associated_products as $associated_product)
|
113 |
+
{
|
114 |
+
$status = $associated_product->getStatus();
|
115 |
+
$qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($associated_product)->getQty();
|
116 |
+
if($status == 1){$status = 'Enabled';}else{$status = 'Disabled';}
|
117 |
+
if($qty == 0 || $associated_product->getIsInStock() == 0){$qty = 'Out of Stock';}
|
118 |
+
$associated_products_details[] = array(
|
119 |
+
'id' => $associated_product->getId(),
|
120 |
+
'sku' => $associated_product->getSku()
|
121 |
+
);
|
122 |
+
|
123 |
+
$associated_products_list[] = array(
|
124 |
+
'id' => $associated_product->getId(),
|
125 |
+
'sku' => $associated_product->getSku(),
|
126 |
+
'name' => $associated_product->getName(),
|
127 |
+
'status' => $status,
|
128 |
+
'qty' => $qty,
|
129 |
+
'price' => Mage::helper('mobileassistant')->getPrice($associated_product->getPrice(),$storeId),
|
130 |
+
);
|
131 |
+
}
|
132 |
+
$product_details[] = array(
|
133 |
+
'id' => $product_data->getId(),
|
134 |
+
'sku' => $product_data->getSku(),
|
135 |
+
'name' => $product_data->getName(),
|
136 |
+
'status' => $pro_status,
|
137 |
+
'qty' => $qty,
|
138 |
+
'price' => Mage::helper('mobileassistant')->getPrice($product_data->getPrice(),$storeId),
|
139 |
+
'desc' => $product_data->getDescription(),
|
140 |
+
'type' => $product_data->getTypeId(),
|
141 |
+
'special_price' => Mage::helper('mobileassistant')->getPrice($product_data->getSpecialPrice(),$storeId),
|
142 |
+
'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',
|
143 |
+
'associated_skus' => $associated_products_details,
|
144 |
+
'all_images' => $images
|
145 |
+
);
|
146 |
+
|
147 |
+
$productResultArr = array('productdata' => $product_details , 'associated_products_list' =>$associated_products_list);
|
148 |
+
$productDetailResult = Mage::helper('core')->jsonEncode($productResultArr);
|
149 |
+
return Mage::app()->getResponse()->setBody($productDetailResult);
|
150 |
+
}catch (Exception $e){
|
151 |
+
$product_details = array (
|
152 |
+
'status' => 'error',
|
153 |
+
'message' => $e->getMessage()
|
154 |
+
);
|
155 |
+
return Mage::app()->getResponse()->setBody(Mage::helper('core')->jsonEncode($product_details));
|
156 |
+
}
|
157 |
+
}else{
|
158 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
159 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
public function filterProductAction()
|
164 |
+
{
|
165 |
+
if(Mage::helper('mobileassistant')->isEnable()){
|
166 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
167 |
+
$sessionId = $post_data['session'];
|
168 |
+
if (!Mage::getSingleton('api/session')->isLoggedIn($sessionId)) {
|
169 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
170 |
+
return false;
|
171 |
+
}
|
172 |
+
try{
|
173 |
+
$storeId = $post_data['storeid'];
|
174 |
+
$filter_by_name = $post_data['filter_by_name'];
|
175 |
+
$filter_by_type = $post_data['product_type'];
|
176 |
+
$filter_by_qty = $post_data['filter_by_qty'];
|
177 |
+
|
178 |
+
$products = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($storeId)->setOrder('entity_id', 'desc');
|
179 |
+
|
180 |
+
if($filter_by_name != null){
|
181 |
+
$products->addAttributeToFilter(array(
|
182 |
+
array(
|
183 |
+
'attribute' => 'name',
|
184 |
+
'like' => '%'.$filter_by_name.'%'
|
185 |
+
),
|
186 |
+
array(
|
187 |
+
'attribute' => 'sku',
|
188 |
+
'like' => '%'.$filter_by_name.'%'
|
189 |
+
)
|
190 |
+
));
|
191 |
+
}
|
192 |
+
|
193 |
+
if($filter_by_type != null){
|
194 |
+
$products->addFieldToFilter('type_id',Array('eq'=>$filter_by_type));
|
195 |
+
}
|
196 |
+
|
197 |
+
if($filter_by_qty != null){
|
198 |
+
$products->joinField('qty','cataloginventory/stock_item','qty','product_id=entity_id','{{table}}.stock_id=1','left');
|
199 |
+
if($filter_by_qty == 'gteq'){
|
200 |
+
$qty = $post_data['qty'];
|
201 |
+
$products->addFieldToFilter('qty',Array('gteq'=>$qty));
|
202 |
+
}elseif($filter_by_qty == 'lteq'){
|
203 |
+
$qty = $post_data['qty'];
|
204 |
+
$products->addFieldToFilter('qty',Array('lteq'=>$qty));
|
205 |
+
}elseif($filter_by_qty == 'btwn'){
|
206 |
+
$from_qty = $post_data['from_qty'];
|
207 |
+
$to_qty = $post_data['to_qty'];
|
208 |
+
$products->addFieldToFilter('qty',array('from'=>$from_qty, 'to'=>$to_qty));
|
209 |
+
}
|
210 |
+
}
|
211 |
+
|
212 |
+
foreach($products as $product)
|
213 |
+
{
|
214 |
+
$product_data = Mage::getModel('catalog/product')->load($product->getId());
|
215 |
+
$status = $product_data->getStatus();
|
216 |
+
$qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product_data)->getQty();
|
217 |
+
if($status == 1){$status = 'Enabled';}else{$status = 'Disabled';}
|
218 |
+
if($qty == 0 || $product_data->getIsInStock() == 0){$qty = 'Out of Stock';}
|
219 |
+
$product_list[] = array(
|
220 |
+
'id' => $product->getId(),
|
221 |
+
'sku' => $product_data->getSku(),
|
222 |
+
'name' => $product_data->getName(),
|
223 |
+
'status' => $status,
|
224 |
+
'qty' => $qty,
|
225 |
+
'price' => Mage::helper('mobileassistant')->getPrice($product_data->getPrice(),$storeId),
|
226 |
+
'type' => $product->getTypeId(),
|
227 |
+
'image' => ($product_data->getImage())?Mage::helper('catalog/image')->init($product, 'image',$product_data->getImage())->resize(300,330)->keepAspectRatio(true)->constrainOnly(true)->__toString():'N/A',
|
228 |
+
);
|
229 |
+
}
|
230 |
+
|
231 |
+
$productListResultArr = array('productlistdata' => $product_list);
|
232 |
+
$productListResult = Mage::helper('core')->jsonEncode($productListResultArr);
|
233 |
+
return Mage::app()->getResponse()->setBody($productListResult);
|
234 |
+
}catch (Exception $e){
|
235 |
+
$product_list = array (
|
236 |
+
'status' => 'error',
|
237 |
+
'message' => $e->getMessage()
|
238 |
+
);
|
239 |
+
return Mage::app()->getResponse()->setBody(Mage::helper('core')->jsonEncode($product_list));
|
240 |
+
}
|
241 |
+
}else{
|
242 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
243 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
244 |
+
}
|
245 |
+
}
|
246 |
+
|
247 |
+
public function ChangeProductStatusAction()
|
248 |
+
{
|
249 |
+
if(Mage::helper('mobileassistant')->isEnable()){
|
250 |
+
$post_data = Mage::app()->getRequest()->getParams();
|
251 |
+
$sessionId = $post_data['session'];
|
252 |
+
if (!Mage::getSingleton('api/session')->isLoggedIn($sessionId)) {
|
253 |
+
echo $this->__("The Login has expired. Please try log in again.");
|
254 |
+
return false;
|
255 |
+
}
|
256 |
+
try{
|
257 |
+
$storeId = $post_data['storeid'];
|
258 |
+
$productId = $post_data['productid'];
|
259 |
+
$current_status = $post_data['current_status'];
|
260 |
+
$new_status = $post_data['new_status'];
|
261 |
+
|
262 |
+
|
263 |
+
if($current_status != $new_status && $new_status == 1)
|
264 |
+
{
|
265 |
+
Mage::getModel('catalog/product_status')->updateProductStatus($productId, $storeId, Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
|
266 |
+
}elseif($current_status != $new_status && $new_status == 2){
|
267 |
+
Mage::getModel('catalog/product_status')->updateProductStatus($productId, $storeId, Mage_Catalog_Model_Product_Status::STATUS_DISABLED);
|
268 |
+
}
|
269 |
+
$productResultArr = array('message' => 'Product has been successfully updated.');
|
270 |
+
$productDetailResult = Mage::helper('core')->jsonEncode($productResultArr);
|
271 |
+
return Mage::app()->getResponse()->setBody($productDetailResult);
|
272 |
+
}catch (Exception $e){
|
273 |
+
$product_details = array (
|
274 |
+
'status' => 'error',
|
275 |
+
'message' => $e->getMessage()
|
276 |
+
);
|
277 |
+
return Mage::app()->getResponse()->setBody(Mage::helper('core')->jsonEncode($product_details));
|
278 |
+
}
|
279 |
+
}else{
|
280 |
+
$isEnable = Mage::helper('core')->jsonEncode(array('enable' => false));
|
281 |
+
return Mage::app()->getResponse()->setBody($isEnable);
|
282 |
+
}
|
283 |
+
}
|
284 |
+
|
285 |
}
|
app/code/local/Biztech/Mobileassistant/etc/api.xml
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<api>
|
4 |
-
<resources>
|
5 |
-
<mobileassistant translate="title" module="biztech_mobileassistant">
|
6 |
-
<title>Mobileassistant Api</title>
|
7 |
-
<model>mobileassistant/mobileassistant_api</model>
|
8 |
-
<methods>
|
9 |
-
<create translate="title" module="biztech_mobileassistant">
|
10 |
-
<title>Create</title>
|
11 |
-
</create>
|
12 |
-
</methods>
|
13 |
-
</mobileassistant>
|
14 |
-
</resources>
|
15 |
-
</api>
|
16 |
-
</config>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api>
|
4 |
+
<resources>
|
5 |
+
<mobileassistant translate="title" module="biztech_mobileassistant">
|
6 |
+
<title>Mobileassistant Api</title>
|
7 |
+
<model>mobileassistant/mobileassistant_api</model>
|
8 |
+
<methods>
|
9 |
+
<create translate="title" module="biztech_mobileassistant">
|
10 |
+
<title>Create</title>
|
11 |
+
</create>
|
12 |
+
</methods>
|
13 |
+
</mobileassistant>
|
14 |
+
</resources>
|
15 |
+
</api>
|
16 |
+
</config>
|
app/code/local/Biztech/Mobileassistant/etc/config.xml
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
<config>
|
11 |
<modules>
|
12 |
<Biztech_Mobileassistant>
|
13 |
-
<version>0.1.
|
14 |
</Biztech_Mobileassistant>
|
15 |
</modules>
|
16 |
<frontend>
|
@@ -76,6 +76,7 @@
|
|
76 |
</mobileassistant>
|
77 |
</updates>
|
78 |
</layout>
|
|
|
79 |
</adminhtml>
|
80 |
<global>
|
81 |
<models>
|
@@ -147,6 +148,35 @@
|
|
147 |
</customer_register_checkout>
|
148 |
</observers>
|
149 |
</customer_register_checkout>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
</events>
|
151 |
</global>
|
152 |
</config>
|
10 |
<config>
|
11 |
<modules>
|
12 |
<Biztech_Mobileassistant>
|
13 |
+
<version>0.1.9</version>
|
14 |
</Biztech_Mobileassistant>
|
15 |
</modules>
|
16 |
<frontend>
|
76 |
</mobileassistant>
|
77 |
</updates>
|
78 |
</layout>
|
79 |
+
|
80 |
</adminhtml>
|
81 |
<global>
|
82 |
<models>
|
148 |
</customer_register_checkout>
|
149 |
</observers>
|
150 |
</customer_register_checkout>
|
151 |
+
|
152 |
+
<!--inventory status:starts-->
|
153 |
+
<cataloginventory_stock_item_save_commit_after>
|
154 |
+
<observers>
|
155 |
+
<mobileassistant_stockupdate>
|
156 |
+
<class>mobileassistant/observer</class>
|
157 |
+
<method>catalogInventorySave</method>
|
158 |
+
</mobileassistant_stockupdate>
|
159 |
+
</observers>
|
160 |
+
</cataloginventory_stock_item_save_commit_after>
|
161 |
+
|
162 |
+
<sales_model_service_quote_submit_before>
|
163 |
+
<observers>
|
164 |
+
<mobileassistant_stockupdate>
|
165 |
+
<class>mobileassistant/observer</class>
|
166 |
+
<method>subtractQuoteInventory</method>
|
167 |
+
</mobileassistant_stockupdate>
|
168 |
+
</observers>
|
169 |
+
</sales_model_service_quote_submit_before>
|
170 |
+
|
171 |
+
<sales_model_service_quote_submit_failure>
|
172 |
+
<observers>
|
173 |
+
<mobileassistant_stockupdate>
|
174 |
+
<class>mobileassistant/observer</class>
|
175 |
+
<method>revertQuoteInventory</method>
|
176 |
+
</mobileassistant_stockupdate>
|
177 |
+
</observers>
|
178 |
+
</sales_model_service_quote_submit_failure>
|
179 |
+
<!--inventory status:ends-->
|
180 |
</events>
|
181 |
</global>
|
182 |
</config>
|
app/code/local/Biztech/Mobileassistant/etc/system.xml
CHANGED
@@ -1,60 +1,80 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8" ?>
|
2 |
-
<config>
|
3 |
-
<tabs>
|
4 |
-
<biztech translate="label" module="mobileassistant">
|
5 |
-
<label>Biztech Extensions</label>
|
6 |
-
<sort_order>400</sort_order>
|
7 |
-
</biztech>
|
8 |
-
</tabs>
|
9 |
-
<sections>
|
10 |
-
<mobileassistant translate="label" module="mobileassistant">
|
11 |
-
<label>MageMob Admin</label>
|
12 |
-
<tab>biztech</tab>
|
13 |
-
<frontend_type>text</frontend_type>
|
14 |
-
<sort_order>10</sort_order>
|
15 |
-
<show_in_default>1</show_in_default>
|
16 |
-
<show_in_website>1</show_in_website>
|
17 |
-
<show_in_store>1</show_in_store>
|
18 |
-
<groups>
|
19 |
-
<mobileassistant_general translate="label">
|
20 |
-
<label>General</label>
|
21 |
-
<frontend_type>text</frontend_type>
|
22 |
-
<sort_order>10</sort_order>
|
23 |
-
<show_in_default>1</show_in_default>
|
24 |
-
<show_in_website>1</show_in_website>
|
25 |
-
<show_in_store>1</show_in_store>
|
26 |
-
<fields>
|
27 |
-
<enabled translate="label">
|
28 |
-
<label>Enabled</label>
|
29 |
-
<frontend_type>select</frontend_type>
|
30 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
31 |
-
<sort_order>1</sort_order>
|
32 |
-
<show_in_default>1</show_in_default>
|
33 |
-
<show_in_website>1</show_in_website>
|
34 |
-
<show_in_store>1</show_in_store>
|
35 |
-
<comment>Select Yes to enable this feature.</comment>
|
36 |
-
</enabled>
|
37 |
-
<notification_msg translate="label">
|
38 |
-
<label>New Order Notification Message</label>
|
39 |
-
<frontend_type>text</frontend_type>
|
40 |
-
<sort_order>2</sort_order>
|
41 |
-
<show_in_default>1</show_in_default>
|
42 |
-
<show_in_website>1</show_in_website>
|
43 |
-
<show_in_store>1</show_in_store>
|
44 |
-
<comment>Enter your message which will be received on the Mobile app whenever a New Order is received.</comment>
|
45 |
-
</notification_msg>
|
46 |
-
<customer_register_notification_msg translate="label">
|
47 |
-
<label>New Customer Register Notification Message</label>
|
48 |
-
<frontend_type>text</frontend_type>
|
49 |
-
<sort_order>3</sort_order>
|
50 |
-
<show_in_default>1</show_in_default>
|
51 |
-
<show_in_website>1</show_in_website>
|
52 |
-
<show_in_store>1</show_in_store>
|
53 |
-
<comment>Enter your message which will be received on the Mobile app whenever a New Customer is registered.</comment>
|
54 |
-
</customer_register_notification_msg>
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
</
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<biztech translate="label" module="mobileassistant">
|
5 |
+
<label>Biztech Extensions</label>
|
6 |
+
<sort_order>400</sort_order>
|
7 |
+
</biztech>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<mobileassistant translate="label" module="mobileassistant">
|
11 |
+
<label>MageMob Admin</label>
|
12 |
+
<tab>biztech</tab>
|
13 |
+
<frontend_type>text</frontend_type>
|
14 |
+
<sort_order>10</sort_order>
|
15 |
+
<show_in_default>1</show_in_default>
|
16 |
+
<show_in_website>1</show_in_website>
|
17 |
+
<show_in_store>1</show_in_store>
|
18 |
+
<groups>
|
19 |
+
<mobileassistant_general translate="label">
|
20 |
+
<label>General</label>
|
21 |
+
<frontend_type>text</frontend_type>
|
22 |
+
<sort_order>10</sort_order>
|
23 |
+
<show_in_default>1</show_in_default>
|
24 |
+
<show_in_website>1</show_in_website>
|
25 |
+
<show_in_store>1</show_in_store>
|
26 |
+
<fields>
|
27 |
+
<enabled translate="label">
|
28 |
+
<label>Enabled</label>
|
29 |
+
<frontend_type>select</frontend_type>
|
30 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
31 |
+
<sort_order>1</sort_order>
|
32 |
+
<show_in_default>1</show_in_default>
|
33 |
+
<show_in_website>1</show_in_website>
|
34 |
+
<show_in_store>1</show_in_store>
|
35 |
+
<comment>Select Yes to enable this feature.</comment>
|
36 |
+
</enabled>
|
37 |
+
<notification_msg translate="label">
|
38 |
+
<label>New Order Notification Message</label>
|
39 |
+
<frontend_type>text</frontend_type>
|
40 |
+
<sort_order>2</sort_order>
|
41 |
+
<show_in_default>1</show_in_default>
|
42 |
+
<show_in_website>1</show_in_website>
|
43 |
+
<show_in_store>1</show_in_store>
|
44 |
+
<comment>Enter your message which will be received on the Mobile app whenever a New Order is received.</comment>
|
45 |
+
</notification_msg>
|
46 |
+
<customer_register_notification_msg translate="label">
|
47 |
+
<label>New Customer Register Notification Message</label>
|
48 |
+
<frontend_type>text</frontend_type>
|
49 |
+
<sort_order>3</sort_order>
|
50 |
+
<show_in_default>1</show_in_default>
|
51 |
+
<show_in_website>1</show_in_website>
|
52 |
+
<show_in_store>1</show_in_store>
|
53 |
+
<comment>Enter your message which will be received on the Mobile app whenever a New Customer is registered.</comment>
|
54 |
+
</customer_register_notification_msg>
|
55 |
+
|
56 |
+
<minimum_qty translate="label">
|
57 |
+
<label>Minimum Quantity Required For Product</label>
|
58 |
+
<frontend_type>text</frontend_type>
|
59 |
+
<sort_order>5</sort_order>
|
60 |
+
<show_in_default>1</show_in_default>
|
61 |
+
<show_in_website>1</show_in_website>
|
62 |
+
<show_in_store>1</show_in_store>
|
63 |
+
<validate>validate-zero-or-greater</validate>
|
64 |
+
<comment>Enter minimum quantity required for product inventory alerts</comment>
|
65 |
+
</minimum_qty>
|
66 |
+
<product_inventory_notification_msg translate="label">
|
67 |
+
<label>Product Inventory Notification Message</label>
|
68 |
+
<frontend_type>text</frontend_type>
|
69 |
+
<sort_order>6</sort_order>
|
70 |
+
<show_in_default>1</show_in_default>
|
71 |
+
<show_in_website>1</show_in_website>
|
72 |
+
<show_in_store>1</show_in_store>
|
73 |
+
<comment>Enter your message which will be received on the Mobile app whenever a product qty is lower than minimum qty.</comment>
|
74 |
+
</product_inventory_notification_msg>
|
75 |
+
</fields>
|
76 |
+
</mobileassistant_general>
|
77 |
+
</groups>
|
78 |
+
</mobileassistant>
|
79 |
+
</sections>
|
80 |
+
</config>
|
app/code/local/Biztech/Mobileassistant/sql/mobileassistant_setup/mysql4-install-0.1.0.php
CHANGED
@@ -1,21 +1,21 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$installer = $this;
|
4 |
-
|
5 |
-
$installer->startSetup();
|
6 |
-
|
7 |
-
$installer->run("
|
8 |
-
|
9 |
-
-- DROP TABLE IF EXISTS {$this->getTable('mobileassistant')};
|
10 |
-
CREATE TABLE {$this->getTable('mobileassistant')} (
|
11 |
-
`user_id` int(11) unsigned NOT NULL auto_increment,
|
12 |
-
`username` varchar(255) NOT NULL default '',
|
13 |
-
`apikey` varchar(40) NOT NULL default '',
|
14 |
-
`device_token` varchar(255) NOT NULL default '',
|
15 |
-
`notification_flag` smallint(11) NOT NULL default '1',
|
16 |
-
PRIMARY KEY (`user_id`)
|
17 |
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
18 |
-
|
19 |
-
");
|
20 |
-
|
21 |
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
|
9 |
+
-- DROP TABLE IF EXISTS {$this->getTable('mobileassistant')};
|
10 |
+
CREATE TABLE {$this->getTable('mobileassistant')} (
|
11 |
+
`user_id` int(11) unsigned NOT NULL auto_increment,
|
12 |
+
`username` varchar(255) NOT NULL default '',
|
13 |
+
`apikey` varchar(40) NOT NULL default '',
|
14 |
+
`device_token` varchar(255) NOT NULL default '',
|
15 |
+
`notification_flag` smallint(11) NOT NULL default '1',
|
16 |
+
PRIMARY KEY (`user_id`)
|
17 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
18 |
+
|
19 |
+
");
|
20 |
+
|
21 |
$installer->endSetup();
|
app/code/local/Biztech/Mobileassistant/sql/mobileassistant_setup/mysql4-upgrade-0.1.0-0.1.4.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$installer = $this;
|
4 |
-
|
5 |
-
$installer->startSetup();
|
6 |
-
|
7 |
-
|
8 |
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
|
8 |
$installer->endSetup();
|
app/code/local/Biztech/Mobileassistant/sql/mobileassistant_setup/mysql4-upgrade-0.1.4-0.1.5.php
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$installer = $this;
|
4 |
-
|
5 |
-
$installer->startSetup();
|
6 |
-
|
7 |
-
$installer->run("
|
8 |
-
|
9 |
-
|
10 |
-
ALTER TABLE `{$this->getTable('mobileassistant')}` ADD `device_type` VARCHAR( 255 ) NOT NULL DEFAULT '',
|
11 |
-
ADD `is_logout` SMALLINT( 11 ) NOT NULL DEFAULT '0';
|
12 |
-
|
13 |
-
");
|
14 |
-
|
15 |
-
|
16 |
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
|
9 |
+
|
10 |
+
ALTER TABLE `{$this->getTable('mobileassistant')}` ADD `device_type` VARCHAR( 255 ) NOT NULL DEFAULT '',
|
11 |
+
ADD `is_logout` SMALLINT( 11 ) NOT NULL DEFAULT '0';
|
12 |
+
|
13 |
+
");
|
14 |
+
|
15 |
+
|
16 |
$installer->endSetup();
|
app/code/local/Biztech/Mobileassistant/sql/mobileassistant_setup/mysql4-upgrade-0.1.5-0.1.6.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$installer = $this;
|
4 |
-
|
5 |
-
$installer->startSetup();
|
6 |
-
|
7 |
-
|
8 |
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
|
8 |
$installer->endSetup();
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>magento_mobile_assistant_manager</name>
|
4 |
-
<version>0.1.
|
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,14 @@ To ensure smooth working of this extension you need to download this extension i
|
|
25 |
Application Download Link:
|
26 |
https://itunes.apple.com/us/app/magentomobilemanager/id695074519?mt=8&ign-mpt=uo%3D4
|
27 |
</description>
|
28 |
-
<notes>-Bug
|
29 |
-
-
|
|
|
|
|
30 |
<authors><author><name>Biztech</name><user>biztechcon</user><email>sales@biztechconsultancy.com</email></author></authors>
|
31 |
-
<date>2015-03
|
32 |
-
<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="Helper"><file name="Data.php" hash="
|
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.1.9</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
25 |
Application Download Link:
|
26 |
https://itunes.apple.com/us/app/magentomobilemanager/id695074519?mt=8&ign-mpt=uo%3D4
|
27 |
</description>
|
28 |
+
<notes>-Bug Fixes and Enhacements
|
29 |
+
-Added Provision Enable/Disable feature from Device
|
30 |
+
-Stock Alert On device
|
31 |
+
- Added order details in notification on device</notes>
|
32 |
<authors><author><name>Biztech</name><user>biztechcon</user><email>sales@biztechconsultancy.com</email></author></authors>
|
33 |
+
<date>2015-06-03</date>
|
34 |
+
<time>05:45:41</time>
|
35 |
+
<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="Helper"><file name="Data.php" hash="c4c160896ad9aa366a5d3e3b58cb9417"/></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="24c60c285907e95cda85b2fed407aec8"/></dir><dir name="controllers"><file name="CustomerController.php" hash="35ba5c85e9b6042846fd919316fe09db"/><file name="DashboardController.php" hash="9b4976bf56373d7a82cf1c2d45b5563b"/><file name="IndexController.php" hash="270697d98f4aedf6012a5714536f814f"/><file name="OrderController.php" hash="cf76a6f679380eca13ce48b4ac855fee"/><file name="ProductController.php" hash="4dab0e0cb4f5dddf2cdeaab94e4f3b1e"/></dir><dir name="etc"><file name="api.xml" hash="7860c9fe0f121148eb2a3a498d1879b1"/><file name="config.xml" hash="6efc013dd918ea284ae1efc59df6d3ba"/><file name="system.xml" hash="ae22361f905daf8c8b39863afb9bab19"/></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.4-0.1.5.php" hash="bd4adba7146d89fed6c548dd46a30a81"/><file name="mysql4-upgrade-0.1.5-0.1.6.php" hash="172e9ecba3b5b385cef1c257b2af4bfa"/></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="83ceddbab4d621545b9c7c4bccdec7c0"/></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="37a517e3bdd6ee2e4c61af6699f7f21b"/></dir></dir></target></contents>
|
36 |
<compatible/>
|
37 |
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
38 |
</package>
|