-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDashboardCtrl.js
More file actions
45 lines (42 loc) · 1.56 KB
/
DashboardCtrl.js
File metadata and controls
45 lines (42 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* Created by sanjay on 23-Sep-16.
*/
app.controller('DashboardCtrl', function($scope,$rootScope, $state, $ionicPopup,StoreService,Common,Order) {
var _init = function(){
if(!StoreService.getSelectedStoreId() || StoreService.getSelectedStoreId()==''){
$state.go('app.stores');
}
Common.showLoader();
$scope.noOfProducts=0;
$scope.noOfOrders =0;
$scope.noOfDonations =0;
$scope.multipleStoresAvailable=StoreService.hasMultipleStores();
StoreService.checkStoreList().then(function(authenticated) {
$scope.multipleStoresAvailable=StoreService.hasMultipleStores();
Common.hideLoader();
}).finally(function() {
Common.hideLoader();
});
$scope.getCounts('product');
$scope.getCounts('order');
$scope.getCounts('donation');
};
$scope.$on('$ionicView.loaded', function() {
})
$scope.$on('$ionicView.enter', function(){
_init();
});
$scope.getCounts = function(countType){
var data = {store_id:StoreService.getSelectedStoreId(),action:countType};
Order.countOfProductNOrders(data).then(function(_result){
if(_result.data.success){
if(countType=="product")
$scope.noOfProducts=_result.data.count;
else if(countType=="order")
$scope.noOfOrders=_result.data.count;
else if(countType == "donation")
$scope.noOfDonations=_result.data.count;
}
})
}
});