Commit 938f3037d648d523e0ac3df06609705baab67ba3

Authored by Kuldeep Arora
1 parent 239310627b
Exists in master

decimal fixed analytics

app/partials/accountSetting/accountSetting.Controller.js
1 (function() { 1 (function() {
2 'use strict' 2 'use strict'
3 3
4 angular.module('acufuel') 4 angular.module('acufuel')
5 .controller('AccountSettingController', [ '$scope', '$filter', '$rootScope', '$state', 'AccountSettingService', AccountSettingController]); 5 .controller('AccountSettingController', [ '$scope', '$filter', '$rootScope', '$state', 'AccountSettingService', AccountSettingController]);
6 6
7 function AccountSettingController($scope, $filter, $rootScope, $state, AccountSettingService) { 7 function AccountSettingController($scope, $filter, $rootScope, $state, AccountSettingService) {
8 $scope.addArray = []; 8 $scope.addArray = [];
9 $scope.userData = {}; 9 $scope.userData = {};
10 getAdditionalAccounts(); 10 getAdditionalAccounts();
11 11
12 function getAdditionalAccounts() { 12 function getAdditionalAccounts() {
13 AccountSettingService.getAdditionalAccounts().then(function(result) { 13 AccountSettingService.getAdditionalAccounts().then(function(result) {
14 $scope.additionalAccounts = result; 14 $scope.additionalAccounts = result;
15 }) 15 })
16 } 16 }
17 17
18 $scope.userid = JSON.parse(localStorage.getItem('userProfileId')); 18 $scope.userid = JSON.parse(localStorage.getItem('userProfileId'));
19 19
20 //call this function after upload data 20 //call this function after upload data
21 function getLoginUserData(){ 21 function getLoginUserData(){
22 console.log("===call---")
23 if($scope.userid && $scope.userid != null && $scope.userid != undefined){ 22 if($scope.userid && $scope.userid != null && $scope.userid != undefined){
24 var id = $scope.userid; 23 var id = $scope.userid;
25 AccountSettingService.loginUserData(id).then(function(result) { 24 AccountSettingService.loginUserData(id).then(function(result) {
26 if(result.userTimeZone != null){ 25 if(result.userTimeZone != null){
27 26
28 if(result.userTimeZone.slice(0,1)==="P"){ 27 if(result.userTimeZone.slice(0,1)==="P"){
29 28
30 result.userTimeZone = result.userTimeZone.replace("P","+"); 29 result.userTimeZone = result.userTimeZone.replace("P","+");
31 30
32 }else if(result.userTimeZone.slice(0,1)==="M"){ 31 }else if(result.userTimeZone.slice(0,1)==="M"){
33 32
34 result.userTimeZone = result.userTimeZone.replace("M","-"); 33 result.userTimeZone = result.userTimeZone.replace("M","-");
35 } 34 }
36 35
37 } 36 }
38 $scope.userData = result; 37 $scope.userData = result;
39 console.log("===userData===",$scope.userData) 38 //console.log("===userData===",$scope.userData)
40 $scope.userData.status = $scope.userData.account.user.status.toLowerCase(); 39 $scope.userData.status = $scope.userData.account.user.status.toLowerCase();
41 $scope.userData.userType = $scope.userData.userType.type.toLowerCase(); 40 $scope.userData.userType = $scope.userData.userType.type.toLowerCase();
42 }) 41 })
43 } 42 }
44 } 43 }
45 44
46 getLoginUserData(); 45 getLoginUserData();
47 46
48 47
49 AccountSettingService.getProducts().then(function(result) { 48 AccountSettingService.getProducts().then(function(result) {
50 $scope.productList = result; 49 $scope.productList = result;
51 for(var i=0;i<$scope.productList.length;i++){ 50 for(var i=0;i<$scope.productList.length;i++){
52 var obj = { 51 var obj = {
53 id : $scope.productList[i].id, 52 id : $scope.productList[i].id,
54 name : $scope.productList[i].name, 53 name : $scope.productList[i].name,
55 status : $scope.productList[i].status 54 status : $scope.productList[i].status
56 } 55 }
57 $scope.addArray.push(obj); 56 $scope.addArray.push(obj);
58 } 57 }
59 }) 58 })
60 59
61 $scope.productData = {}; 60 $scope.productData = {};
62 $scope.productData.productList = []; 61 $scope.productData.productList = [];
63 62
64 $scope.checkProduct = function(productlist, product, index){ 63 $scope.checkProduct = function(productlist, product, index){
65 $scope.addArray[index].id = productlist[index].id; 64 $scope.addArray[index].id = productlist[index].id;
66 $scope.addArray[index].name = productlist[index].name; 65 $scope.addArray[index].name = productlist[index].name;
67 $scope.addArray[index].status = productlist[index].status; 66 $scope.addArray[index].status = productlist[index].status;
68 $scope.productData.productList = $scope.addArray; 67 $scope.productData.productList = $scope.addArray;
69 // console.log($scope.productData) 68 // console.log($scope.productData)
70 } 69 }
71 70
72 $scope.updateUser = function(){ 71 $scope.updateUser = function(){
73 72
74 window.localStorage.setItem('userTimeZone',JSON.stringify($scope.userData.userTimeZone)); 73 window.localStorage.setItem('userTimeZone',JSON.stringify($scope.userData.userTimeZone));
75 //Database not save the = and - sign of timezone offset 74 //Database not save the = and - sign of timezone offset
76 if($scope.userData.userTimeZone.slice(0,1)==="+"){ 75 if($scope.userData.userTimeZone.slice(0,1)==="+"){
77 76
78 $scope.userData.userTimeZone = $scope.userData.userTimeZone.replace("+","P"); 77 $scope.userData.userTimeZone = $scope.userData.userTimeZone.replace("+","P");
79 78
80 }else if($scope.userData.userTimeZone.slice(0,1)==="-"){ 79 }else if($scope.userData.userTimeZone.slice(0,1)==="-"){
81 80
82 $scope.userData.userTimeZone = $scope.userData.userTimeZone.replace("-","M"); 81 $scope.userData.userTimeZone = $scope.userData.userTimeZone.replace("-","M");
83 } 82 }
84 83
85 var updateData = "companyName=" + $scope.userData.companyName + "&username=" + $scope.userData.username + "&firstName=" + $scope.userData.firstName 84 var updateData = "companyName=" + $scope.userData.companyName + "&username=" + $scope.userData.username + "&firstName=" + $scope.userData.firstName
86 + "&lastName=" + $scope.userData.lastName + "&phone=" + $scope.userData.phone + "&mobile=" + $scope.userData.mobile 85 + "&lastName=" + $scope.userData.lastName + "&phone=" + $scope.userData.phone + "&mobile=" + $scope.userData.mobile
87 + "&status=" + $scope.userData.status + "&userType=" + $scope.userData.userType + "&userTypeId=" + $scope.userData.userType.id + "&userProfileId=" + $scope.userid + "&userTimeZone=" + $scope.userData.userTimeZone; 86 + "&status=" + $scope.userData.status + "&userType=" + $scope.userData.userType + "&userTypeId=" + $scope.userData.userType.id + "&userProfileId=" + $scope.userid + "&userTimeZone=" + $scope.userData.userTimeZone;
88 87
89 console.log("======updateData===",updateData) 88 // console.log("======updateData===",updateData)
90 AccountSettingService.updateUserProfile(updateData).then(function(result) { 89 AccountSettingService.updateUserProfile(updateData).then(function(result) {
91 90
92 AccountSettingService.updateProducts($scope.productData).then(function(result) { 91 AccountSettingService.updateProducts($scope.productData).then(function(result) {
93 toastr.success(''+result.success+'', { 92 toastr.success(''+result.success+'', {
94 closeButton: true 93 closeButton: true
95 }); 94 });
96 window.localStorage.setItem('currentUserName', JSON.stringify($scope.userData.firstName +' '+ $scope.userData.lastName)); 95 window.localStorage.setItem('currentUserName', JSON.stringify($scope.userData.firstName +' '+ $scope.userData.lastName));
97 window.localStorage.setItem('companyName', JSON.stringify($scope.userData.companyName)); 96 window.localStorage.setItem('companyName', JSON.stringify($scope.userData.companyName));
98 $scope.currentUserName = JSON.parse(localStorage.getItem('currentUserName')); 97 $scope.currentUserName = JSON.parse(localStorage.getItem('currentUserName'));
99 $scope.companyName= JSON.parse(localStorage.getItem('companyName')); 98 $scope.companyName= JSON.parse(localStorage.getItem('companyName'));
100 $scope.userTimeZone = JSON.parse(localStorage.getItem('userTimeZone')); 99 $scope.userTimeZone = JSON.parse(localStorage.getItem('userTimeZone'));
101 //console.log("====value after update===",$scope.userTimeZone ) 100 //console.log("====value after update===",$scope.userTimeZone )
102 window.localStorage.removeItem('userTime'); 101 window.localStorage.removeItem('userTime');
103 $scope.testFunction(); 102 $scope.testFunction();
104 getLoginUserData(); 103 getLoginUserData();
105 }) 104 })
106 105
107 }) 106 })
108 } 107 }
109 $scope.accountdata = {}; 108 $scope.accountdata = {};
110 $scope.accountdata.userName = ''; 109 $scope.accountdata.userName = '';
111 $scope.accountdata.status = true; 110 $scope.accountdata.status = true;
112 111
113 $scope.addAccount = function(){ 112 $scope.addAccount = function(){
114 $('#demo-modal').css('display', 'block'); 113 $('#demo-modal').css('display', 'block');
115 $scope.accountdata.status = true; 114 $scope.accountdata.status = true;
116 } 115 }
117 116
118 $scope.cancelAddAccount = function(){ 117 $scope.cancelAddAccount = function(){
119 $scope.accountdata = {}; 118 $scope.accountdata = {};
120 $('#demo-modal').css('display', ''); 119 $('#demo-modal').css('display', '');
121 } 120 }
122 121
123 $scope.checkEmail = function(email, type) { 122 $scope.checkEmail = function(email, type) {
124 //console.log(type) 123 //console.log(type)
125 AccountSettingService.checkEmail(email).then(function(result) { 124 AccountSettingService.checkEmail(email).then(function(result) {
126 if(result.status == 'ACTIVE'){ 125 if(result.status == 'ACTIVE'){
127 toastr.error('Email already exists.', { 126 toastr.error('Email already exists.', {
128 closeButton: true 127 closeButton: true
129 }) 128 })
130 if(type == 'additional'){ 129 if(type == 'additional'){
131 $scope.accountdata.userName = ''; 130 $scope.accountdata.userName = '';
132 } 131 }
133 } 132 }
134 }) 133 })
135 } 134 }
136 135
137 $scope.additionalAccnObj = {}; 136 $scope.additionalAccnObj = {};
138 $scope.createAddAccount = function(){ 137 $scope.createAddAccount = function(){
139 $scope.accountdata.status = true; 138 $scope.accountdata.status = true;
140 if ($scope.accountdata.userName === '') { 139 if ($scope.accountdata.userName === '') {
141 toastr.error('Please enter all the fields.', { 140 toastr.error('Please enter all the fields.', {
142 closeButton: true 141 closeButton: true
143 }) 142 })
144 }else{ 143 }else{
145 if (validateEmail($scope.accountdata.userName)) { 144 if (validateEmail($scope.accountdata.userName)) {
146 //console.log("checkbox",$scope.accountdata.allowEpd ,$scope.accountdata.allowFma) 145 //console.log("checkbox",$scope.accountdata.allowEpd ,$scope.accountdata.allowFma)
147 AccountSettingService.addAdditionalAccount($scope.accountdata).then(function(result) { 146 AccountSettingService.addAdditionalAccount($scope.accountdata).then(function(result) {
148 getAdditionalAccounts(); 147 getAdditionalAccounts();
149 $scope.accountdata = {}; 148 $scope.accountdata = {};
150 $('#demo-modal').css('display', ''); 149 $('#demo-modal').css('display', '');
151 toastr.success(''+result.success+'', { 150 toastr.success(''+result.success+'', {
152 closeButton: true 151 closeButton: true
153 }) 152 })
154 }) 153 })
155 }else{ 154 }else{
156 toastr.error('Please enter valid email.', { 155 toastr.error('Please enter valid email.', {
157 closeButton: true 156 closeButton: true
158 }) 157 })
159 } 158 }
160 } 159 }
161 160
162 } 161 }
163 162
164 /*Validate Email */ 163 /*Validate Email */
165 function validateEmail(email) { 164 function validateEmail(email) {
166 var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 165 var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
167 return re.test(email); 166 return re.test(email);
168 } 167 }
169 168
170 $scope.changeStatus = function(id, index){ 169 $scope.changeStatus = function(id, index){
171 event.stopPropagation(); 170 event.stopPropagation();
172 var id = id; 171 var id = id;
173 var statusData = "status=" + $scope.additionalAccounts[index].status + "&id=" + $scope.additionalAccounts[index].id + "&firstName=" + $scope.additionalAccounts[index].firstName 172 var statusData = "status=" + $scope.additionalAccounts[index].status + "&id=" + $scope.additionalAccounts[index].id + "&firstName=" + $scope.additionalAccounts[index].firstName
174 + "&lastName=" + $scope.additionalAccounts[index].lastName + "&username=" + $scope.additionalAccounts[index].userName + "&password=" + $scope.additionalAccounts[index].password 173 + "&lastName=" + $scope.additionalAccounts[index].lastName + "&username=" + $scope.additionalAccounts[index].userName + "&password=" + $scope.additionalAccounts[index].password
175 + "&allowEpd=" + $scope.additionalAccounts[index].allowEpd + "&allowFma=" + $scope.additionalAccounts[index].allowFma; 174 + "&allowEpd=" + $scope.additionalAccounts[index].allowEpd + "&allowFma=" + $scope.additionalAccounts[index].allowFma;
176 AccountSettingService.updateStatus(statusData).then(function(result) { 175 AccountSettingService.updateStatus(statusData).then(function(result) {
177 if(result.success){ 176 if(result.success){
178 toastr.success('Updated Successfully', { 177 toastr.success('Updated Successfully', {
179 closeButton: true 178 closeButton: true
180 }) 179 })
181 } 180 }
182 }) 181 })
183 } 182 }
184 var deleteAccnId = ""; 183 var deleteAccnId = "";
185 $scope.deleteAdditionalAccount = function(id) { 184 $scope.deleteAdditionalAccount = function(id) {
186 $('#delete1').css('display', 'block'); 185 $('#delete1').css('display', 'block');
187 deleteAccnId = id; 186 deleteAccnId = id;
188 187
189 } 188 }
190 189
191 $scope.accnDelete = function(){ 190 $scope.accnDelete = function(){
192 AccountSettingService.deleteAccount(deleteAccnId).then(function(result) { 191 AccountSettingService.deleteAccount(deleteAccnId).then(function(result) {
193 getAdditionalAccounts(); 192 getAdditionalAccounts();
194 $('#delete1').css('display', 'none'); 193 $('#delete1').css('display', 'none');
195 if(result.success){ 194 if(result.success){
196 toastr.success('Deleted Successfully', { 195 toastr.success('Deleted Successfully', {
197 closeButton: true 196 closeButton: true
198 }) 197 })
199 } 198 }
200 }) 199 })
201 } 200 }
202 201
203 202
204 $scope.cancelDelete = function(){ 203 $scope.cancelDelete = function(){
205 $('#delete1').css('display', 'none'); 204 $('#delete1').css('display', 'none');
206 } 205 }
207 206
208 $scope.resetPassword = function(email) { 207 $scope.resetPassword = function(email) {
209 //console.log("emailid",email) 208 //console.log("emailid",email)
210 AccountSettingService.resetPassword(email).then(function(result){ 209 AccountSettingService.resetPassword(email).then(function(result){
211 if(typeof result == 'object') { 210 if(typeof result == 'object') {
212 toastr.info("Password generated successfully. Please check your email for new password"); 211 toastr.info("Password generated successfully. Please check your email for new password");
213 //localStorage.setItem('requiredChangePwd', "Y"); 212 //localStorage.setItem('requiredChangePwd', "Y");
214 //$state.go('login'); 213 //$state.go('login');
215 } else { 214 } else {
216 toastr.info("Error in generating password"); 215 toastr.info("Error in generating password");
217 } 216 }
218 }) 217 })
219 } 218 }
220 219
221 220
222 $scope.timeZoneList = [{name:'(GMT-12:00) International Date Line West',value:'-12.00'}, 221 $scope.timeZoneList = [{name:'(GMT-12:00) International Date Line West',value:'-12.00'},
223 {name:'(GMT-11:00) Midway Island, Samoa',value:'-11.00'}, 222 {name:'(GMT-11:00) Midway Island, Samoa',value:'-11.00'},
224 {name:'(GMT-10:00) Hawaii',value :'-10.00'}, 223 {name:'(GMT-10:00) Hawaii',value :'-10.00'},
225 {name:'(GMT-09:30) Pacific/Marquesas (French Polynesia)',value :'-09.30'}, 224 {name:'(GMT-09:30) Pacific/Marquesas (French Polynesia)',value :'-09.30'},
226 {name:'(GMT-09:00) Pacific/Gambier(French Polynesia)(US)',value :'-09.00'}, 225 {name:'(GMT-09:00) Pacific/Gambier(French Polynesia)(US)',value :'-09.00'},
227 {name:'(GMT-08:00) Alaska',value :'-08.00'}, 226 {name:'(GMT-08:00) Alaska',value :'-08.00'},
228 {name:'(GMT-07:00) Arizona,(US and Canada)',value :'-07.00'}, 227 {name:'(GMT-07:00) Arizona,(US and Canada)',value :'-07.00'},
229 {name:'(GMT-06:00) (Central America),Chihuahua,Saskatchewan,Ecuador',value :'-06.00'}, 228 {name:'(GMT-06:00) (Central America),Chihuahua,Saskatchewan,Ecuador',value :'-06.00'},
230 {name:'(GMT-05:00) Central Time (US and Canada) Bogota, Mexico City,Lima,Brazil, Quito',value :'-05.00'}, 229 {name:'(GMT-05:00) Central Time (US and Canada) Bogota, Mexico City,Lima,Brazil, Quito',value :'-05.00'},
231 {name:'(GMT-04:00) Eastern Time (US and Canada),Caracas, La Paz,Indiana (East)',value :'-04.00'}, 230 {name:'(GMT-04:00) Eastern Time (US and Canada),Caracas, La Paz,Indiana (East)',value :'-04.00'},
232 {name:'(GMT-03:00) Atlantic Time (Canada),Santiago,Brasilia,Buenos Aires',value :'-03.00'}, 231 {name:'(GMT-03:00) Atlantic Time (Canada),Santiago,Brasilia,Buenos Aires',value :'-03.00'},
233 {name:'(GMT-02:30) Newfoundland and Labrador,(Canada)',value :'-02.30'}, 232 {name:'(GMT-02:30) Newfoundland and Labrador,(Canada)',value :'-02.30'},
234 {name:'(GMT-02:00) Mid-Atlantic,Greenland',value :'-02.00'}, 233 {name:'(GMT-02:00) Mid-Atlantic,Greenland',value :'-02.00'},
235 {name:'(GMT-01:00) Cape Verde Islands',value :'-01.00'}, 234 {name:'(GMT-01:00) Cape Verde Islands',value :'-01.00'},
236 {name:'(GMT) Azores,Dublin, Edinburgh, Lisbon, London',value :'00.00'}, 235 {name:'(GMT) Azores,Dublin, Edinburgh, Lisbon, London',value :'00.00'},
237 {name:'(GMT+01:00) West Central Africa,Canary Islands,Casablanca, Monrovia',value :'+01.00'}, 236 {name:'(GMT+01:00) West Central Africa,Canary Islands,Casablanca, Monrovia',value :'+01.00'},
238 {name:'(GMT+02:00) Brussels,Amsterdam,Harare,Madrid,Paris,Cairo,Belgrade',value :'+02.00'}, 237 {name:'(GMT+02:00) Brussels,Amsterdam,Harare,Madrid,Paris,Cairo,Belgrade',value :'+02.00'},
239 {name:'(GMT+03:00) Moscow,Jerusalem,St.Petersburg, Athens,Baghdad,Kuwait,Helsinki,Nairobi',value :'+03.00'}, 238 {name:'(GMT+03:00) Moscow,Jerusalem,St.Petersburg, Athens,Baghdad,Kuwait,Helsinki,Nairobi',value :'+03.00'},
240 {name:'(GMT+04:00) Armenia,Azerbaijan,UAE,(Russia)',value :'+04.00'}, 239 {name:'(GMT+04:00) Armenia,Azerbaijan,UAE,(Russia)',value :'+04.00'},
241 {name:'(GMT+04:30) Kabul,(Afghanistan)',value :'+04.30'}, 240 {name:'(GMT+04:30) Kabul,(Afghanistan)',value :'+04.30'},
242 {name:'(GMT+05:00) Islamabad, Karachi, Tashkent (Pakistan)',value :'+05.00'}, 241 {name:'(GMT+05:00) Islamabad, Karachi, Tashkent (Pakistan)',value :'+05.00'},
243 {name:'(GMT+05:30) Chennai,New Delhi(India),(Sri Lanka)',value :'+05.30'}, 242 {name:'(GMT+05:30) Chennai,New Delhi(India),(Sri Lanka)',value :'+05.30'},
244 {name:'(GMT+05:45) Kathmandu (Nepal)',value :'+05.45'}, 243 {name:'(GMT+05:45) Kathmandu (Nepal)',value :'+05.45'},
245 {name:'(GMT+06:00) Astana,Kazakhstan,Dhaka(Bangladesh),(Bhutan),(Russia)',value :'+06.00'}, 244 {name:'(GMT+06:00) Astana,Kazakhstan,Dhaka(Bangladesh),(Bhutan),(Russia)',value :'+06.00'},
246 {name:'(GMT+06:30) Yangon Rangoon (Myanmar)',value :'+06.30'}, 245 {name:'(GMT+06:30) Yangon Rangoon (Myanmar)',value :'+06.30'},
247 {name:'(GMT+07:00) Laos,Krasnoyarsk,Hanoi,Bangkok(Thailand),Jakarta(Indonesia)',value :'+07.00'}, 246 {name:'(GMT+07:00) Laos,Krasnoyarsk,Hanoi,Bangkok(Thailand),Jakarta(Indonesia)',value :'+07.00'},
248 {name:'(GMT+08:00) Perth(Western Australia),Beijing(China),Kuala Lumpur(Singapore),(Malaysia)',value :'+08.00'}, 247 {name:'(GMT+08:00) Perth(Western Australia),Beijing(China),Kuala Lumpur(Singapore),(Malaysia)',value :'+08.00'},
249 {name:'(GMT+08:45) Australia/Eucla',value :'+08.45'}, 248 {name:'(GMT+08:45) Australia/Eucla',value :'+08.45'},
250 {name:'(GMT+09:00) Japan/North Korea/South Korea/East Timor',value :'+09.00'}, 249 {name:'(GMT+09:00) Japan/North Korea/South Korea/East Timor',value :'+09.00'},
251 {name:'(GMT+09:30) Adelaide/Darwin(Australia)',value :'+09.30' }, 250 {name:'(GMT+09:30) Adelaide/Darwin(Australia)',value :'+09.30' },
252 {name:'(GMT+10:00) Guam, Port Moresby,Hobart,Vladivostok,Brisbane,Melbourne(Australia),Papua New Guinea',value :'+10.00'}, 251 {name:'(GMT+10:00) Guam, Port Moresby,Hobart,Vladivostok,Brisbane,Melbourne(Australia),Papua New Guinea',value :'+10.00'},
253 {name:'(GMT+10:30) Australia/Lord_Howe',value :'+10.30'}, 252 {name:'(GMT+10:30) Australia/Lord_Howe',value :'+10.30'},
254 {name:'(GMT+11:00) Magadan, Solomon Islands, New Caledonia',value :'+11.00'}, 253 {name:'(GMT+11:00) Magadan, Solomon Islands, New Caledonia',value :'+11.00'},
255 {name:'(GMT+12:00) Auckland, Wellington,Fiji Islands, Kamchatka, Marshall Islands',value :'+12.00'}, 254 {name:'(GMT+12:00) Auckland, Wellington,Fiji Islands, Kamchatka, Marshall Islands',value :'+12.00'},
256 {name:'(GMT+12:45) Pacific/Chatham, New Zealand',value :'+12.45'}, 255 {name:'(GMT+12:45) Pacific/Chatham, New Zealand',value :'+12.45'},
257 {name:'(GMT+13:00) Nuku alofa,Samoa,Tonga',value :'+13.00'}, 256 {name:'(GMT+13:00) Nuku alofa,Samoa,Tonga',value :'+13.00'},
258 {name:'(GMT+14:00) Pacific/Kiritimati',value :'+14.00'}] 257 {name:'(GMT+14:00) Pacific/Kiritimati',value :'+14.00'}]
259 258
260 259
261 } 260 }
262 })(); 261 })();
263 262
264 263
app/partials/analytics/analytics.controller.js
1 'use strict'; 1 'use strict';
2 angular.module('acufuel') 2 angular.module('acufuel')
3 .controller('analyticsController', ['$scope', 'analyticsService', function($scope, analyticsService) { 3 .controller('analyticsController', ['$scope', 'analyticsService', function($scope, analyticsService) {
4 4
5 5
6 6
7 $scope.getAllRegionalPap = function() { 7 $scope.getAllRegionalPap = function() {
8 $scope.flag=true; 8 $scope.flag=true;
9 $scope.stateList = [{region:'Alabama',code:'AL'},{region:'Alaska',code:'AK'},{region:'Arizona',code:'AZ'},{region:'Arkansas',code:'AR'}, 9 $scope.stateList = [{region:'Alabama',code:'AL'},{region:'Alaska',code:'AK'},{region:'Arizona',code:'AZ'},{region:'Arkansas',code:'AR'},
10 {region:'California',code:'CA' },{region:'Colorado',code:'CO'},{region:'Connecticut',code:'CT'},{region:'Delaware',code:'DE'}, 10 {region:'California',code:'CA' },{region:'Colorado',code:'CO'},{region:'Connecticut',code:'CT'},{region:'Delaware',code:'DE'},
11 {region:'Florida' ,code:'FL'},{region:'Georgia' ,code:'GA'},{region:'Hawaii' ,code:'HI'},{region:'Idaho' ,code:'ID'}, 11 {region:'Florida' ,code:'FL'},{region:'Georgia' ,code:'GA'},{region:'Hawaii' ,code:'HI'},{region:'Idaho' ,code:'ID'},
12 {region:'Illinois',code:'IL'},{region:'Indiana' ,code:'IN'},{region:'Iowa' ,code:'IA'},{region:'Kansas' ,code:'KS'}, 12 {region:'Illinois',code:'IL'},{region:'Indiana' ,code:'IN'},{region:'Iowa' ,code:'IA'},{region:'Kansas' ,code:'KS'},
13 {region:'Kentucky' ,code:'KY'},{region:'Louisiana' ,code:'LA'},{region:'Maine' ,code:'ME'},{region:'Maryland' ,code:'MD'}, 13 {region:'Kentucky' ,code:'KY'},{region:'Louisiana' ,code:'LA'},{region:'Maine' ,code:'ME'},{region:'Maryland' ,code:'MD'},
14 {region:'Massachusetts' ,code:'MA'},{region:'Michigan' ,code:'MI'},{region:'Minnesota' ,code:'MN'}, 14 {region:'Massachusetts' ,code:'MA'},{region:'Michigan' ,code:'MI'},{region:'Minnesota' ,code:'MN'},
15 {region:'Mississippi' ,code:'MS'},{region:'Missouri' ,code:'MO'},{region:'Montana',code:'MT'},{region:'Nebraska' ,code:'NE'}, 15 {region:'Mississippi' ,code:'MS'},{region:'Missouri' ,code:'MO'},{region:'Montana',code:'MT'},{region:'Nebraska' ,code:'NE'},
16 {region:'Nevada' ,code:'NV'},{region:'New Hampshire' ,code:'NH'},{region:'New Jersey' ,code:'NJ'},{region:'New Mexico' ,code:'NM'}, 16 {region:'Nevada' ,code:'NV'},{region:'New Hampshire' ,code:'NH'},{region:'New Jersey' ,code:'NJ'},{region:'New Mexico' ,code:'NM'},
17 {region:'New York' ,code:'NY'},{region:'North Carolina' ,code:'NC'},{region:'North Dakota' ,code:'ND'},{region:'Ohio' ,code:'OH'}, 17 {region:'New York' ,code:'NY'},{region:'North Carolina' ,code:'NC'},{region:'North Dakota' ,code:'ND'},{region:'Ohio' ,code:'OH'},
18 {region:'Oklahoma' ,code:'OK'},{region:'Oregon' ,code:'OR'},{region:'Pennsylvania',code:'PA'},{region:'Rhode Island' ,code:'RI'}, 18 {region:'Oklahoma' ,code:'OK'},{region:'Oregon' ,code:'OR'},{region:'Pennsylvania',code:'PA'},{region:'Rhode Island' ,code:'RI'},
19 {region:'South Carolina' ,code:'SC'},{region:'South Dakota' ,code:'SD'},{region:'Tennessee' ,code:'TN'},{region:'Texas' ,code:'TX'}, 19 {region:'South Carolina' ,code:'SC'},{region:'South Dakota' ,code:'SD'},{region:'Tennessee' ,code:'TN'},{region:'Texas' ,code:'TX'},
20 {region:'Utah' ,code:'UT'},{region:'Vermont' ,code:'VT'},{region:'Virginia' ,code:'VA'},{region:'Washington' ,code:'WA'}, 20 {region:'Utah' ,code:'UT'},{region:'Vermont' ,code:'VT'},{region:'Virginia' ,code:'VA'},{region:'Washington' ,code:'WA'},
21 {region:'West Virginia' ,code:'WV'},{region:'Wisconsin' ,code:'WI'},{region:'Wyoming',code:'WY'}] 21 {region:'West Virginia' ,code:'WV'},{region:'Wisconsin' ,code:'WI'},{region:'Wyoming',code:'WY'}]
22 22
23 analyticsService.getAllRPP().then(function(result) { 23 analyticsService.getAllRPP().then(function(result) {
24 for (var i = 0; i < $scope.stateList.length; i++) { 24 for (var i = 0; i < $scope.stateList.length; i++) {
25 for (var j = 0; j<result.length; j++){ 25 for (var j = 0; j<result.length; j++){
26 if ($scope.stateList[i].region === result[j].region) { 26 if ($scope.stateList[i].region === result[j].region) {
27 result[j].code = $scope.stateList[i].code; 27 result[j].code = $scope.stateList[i].code;
28 result[j].averagePAP = result[j].averagePAP.toFixed(2);
28 } 29 }
29 } 30 }
30 } 31 }
31 $scope.flag=false; 32 $scope.flag=false;
32 // Instantiate the map 33 // Instantiate the map
33 Highcharts.mapChart('regional-pap', { 34 Highcharts.mapChart('regional-pap', {
34 35
35 chart: { 36 chart: {
36 map: 'countries/us/us-all', 37 map: 'countries/us/us-all',
37 borderWidth: 1, 38 borderWidth: 1,
38 }, 39 },
39 40
40 title: { 41 title: {
41 text: 'Regional PAP' 42 text: 'Regional PAP'
42 }, 43 },
43 44
44 exporting: { 45 exporting: {
45 sourceWidth: 600, 46 sourceWidth: 600,
46 sourceHeight: 500 47 sourceHeight: 500
47 }, 48 },
48 49
49 legend: { 50 legend: {
50 layout: 'vertical', 51 layout: 'vertical',
51 borderWidth: 0, 52 borderWidth: 0,
52 backgroundColor: 'rgba(255,255,255,0.85)', 53 backgroundColor: 'rgba(255,255,255,0.85)',
53 floating: true, 54 floating: true,
54 width:'12px', 55 width:'12px',
55 height:'200px', 56 height:'200px',
56 verticalAlign: 'bottom', 57 verticalAlign: 'bottom',
57 y: 0, 58 y: 0,
58 x: -230, 59 x: -230,
59 }, 60 },
60 61
61 mapNavigation: { 62 mapNavigation: {
62 enabled: true 63 enabled: true
63 }, 64 },
64 65
65 /* colorAxis: { 66 /* colorAxis: {
66 min: 1, 67 min: 1,
67 type: 'logarithmic', 68 type: 'logarithmic',
68 minColor: '#2b908f', 69 minColor: '#2b908f',
69 maxColor: '#000022', 70 maxColor: '#000022',
70 stops: [ 71 stops: [
71 [0, '#EFEFFF'], 72 [0, '#EFEFFF'],
72 [5, '#f45b5b'], 73 [5, '#f45b5b'],
73 [10, 'rgb(117,0,0)'] 74 [10, 'rgb(117,0,0)']
74 ] 75 ]
75 },*/ 76 },*/
76 77
77 series: [{ 78 series: [{
78 animation: { 79 animation: {
79 duration: 1000 80 duration: 1000
80 }, 81 },
81 data: result, 82 data: result,
82 joinBy: ['postal-code', 'code'], 83 joinBy: ['postal-code', 'code'],
83 dataLabels: { 84 dataLabels: {
84 enabled: true, 85 enabled: true,
85 color: '#FFFFFF', 86 color: '#FFFFFF',
86 format: '{point.code}' 87 format: '{point.code}'
87 }, 88 },
88 name: 'Data' , 89 name: 'Data' ,
89 tooltip: { 90 tooltip: {
90 pointFormat: '{point.region} : {point.averagePAP}' 91 pointFormat: '{point.region} : {point.averagePAP}'
91 }, 92 },
92 }] 93 }]
93 }); 94 });
94 }) 95 })
95 } 96 }
96 97
97 $scope.getAllRegionalPap(); 98 $scope.getAllRegionalPap();
98 99
99 /*$(document).ready(function() { 100 /*$(document).ready(function() {
100 $(function() { 101 $(function() {
101 jQuery('#map').vectorMap({ 102 jQuery('#map').vectorMap({
102 map: 'us_lcc', 103 map: 'us_lcc',
103 backgroundColor: '#ffce99', 104 backgroundColor: '#ffce99',
104 color: '#dfdfdd', 105 color: '#dfdfdd',
105 hoverOpacity: 0, 106 hoverOpacity: 0,
106 selectedColor: '#5f8b98', 107 selectedColor: '#5f8b98',
107 hoverColor: '#5f8b98', 108 hoverColor: '#5f8b98',
108 enableZoom: true, 109 enableZoom: true,
109 showTooltip: true, 110 showTooltip: true,
110 scaleColors: ['#dfdfdd'], 111 scaleColors: ['#dfdfdd'],
111 //values: sample_data 112 //values: sample_data
112 onRegionClick: function(event, code) { 113 onRegionClick: function(event, code) {
113 var map = $('#map').vectorMap('get', 'mapObject'); 114 var map = $('#map').vectorMap('get', 'mapObject');
114 var name = map.getRegionName(code); 115 var name = map.getRegionName(code);
115 getRegionPap(name); 116 getRegionPap(name);
116 }, 117 },
117 normalizeFunction: 'polynomial' 118 normalizeFunction: 'polynomial'
118 }); 119 });
119 }); 120 });
120 })*/ 121 })*/
121 122
122 123
123 function getRegionPap(code) { 124 function getRegionPap(code) {
124 $scope.showLoader = true; 125 $scope.showLoader = true;
125 analyticsService.getRPP(code).then(function(result) { 126 analyticsService.getRPP(code).then(function(result) {
126 $scope.rppData = result; 127 $scope.rppData = result;
127 $scope.showLoader = false; 128 $scope.showLoader = false;
128 $('#popup1').css('display', 'block'); 129 $('#popup1').css('display', 'block');
129 }) 130 })
130 } 131 }
131 132
132 $scope.cancelStatus = function() { 133 $scope.cancelStatus = function() {
133 $('#popup1').css('display', 'none'); 134 $('#popup1').css('display', 'none');
134 } 135 }
135 $scope.ordersCost = 0; 136 $scope.ordersCost = 0;
136 $scope.ordersCount = 0; 137 $scope.ordersCount = 0;
137 138
138 $scope.orderCostAndCount = function() { 139 $scope.orderCostAndCount = function() {
139 analyticsService.orderCostAndCount().then(function(result) { 140 analyticsService.orderCostAndCount().then(function(result) {
140 $scope.ordersCost = result.cost; 141 $scope.ordersCost = result.cost;
141 $scope.ordersCount = result.count; 142 $scope.ordersCount = result.count;
142 }) 143 })
143 } 144 }
144 145
145 $scope.drf = {}; 146 $scope.drf = {};
146 $scope.hfp = {}; 147 $scope.hfp = {};
147 $scope.cs = {}; 148 $scope.cs = {};
148 $scope.mfsValues = []; 149 $scope.mfsValues = [];
149 $scope.msfarray = []; 150 $scope.msfarray = [];
150 $scope.getMFS = function() { 151 $scope.getMFS = function() {
151 //var makeId = makeId; 152 //var makeId = makeId;
152 analyticsService.getMFS().then(function(result) { 153 analyticsService.getMFS().then(function(result) {
153 $scope.mfsValues = result; 154 $scope.mfsValues = result;
154 $scope.optionsmfs = { 155 $scope.optionsmfs = {
155 chart: { 156 chart: {
156 type: 'multiBarChart', 157 type: 'multiBarChart',
157 height: 450, 158 height: 450,
158 margin: { 159 margin: {
159 top: 45, 160 top: 45,
160 right: 20, 161 right: 20,
161 bottom: 45, 162 bottom: 45,
162 left: 45 163 left: 45
163 }, 164 },
164 clipEdge: true, 165 clipEdge: true,
165 //staggerLabels: true, 166 //staggerLabels: true,
166 duration: 500, 167 duration: 500,
167 stacked: false, 168 stacked: false,
168 color: ["#FEDFC3", "#990000", "#000099", "#009900"], 169 color: ["#FEDFC3", "#990000", "#000099", "#009900"],
169 xAxis: { 170 xAxis: {
170 axisLabel: 'Months', 171 axisLabel: 'Months',
171 showMaxMin: false, 172 showMaxMin: false,
172 }, 173 },
173 yAxis: { 174 yAxis: {
174 axisLabel: 'Orders', 175 axisLabel: 'Orders',
175 axisLabelDistance: -20, 176 axisLabelDistance: -20,
176 tickFormat: function(d) { 177 tickFormat: function(d) {
177 return d3.format(',.1f')(d); 178 return d3.format(',.1f')(d);
178 } 179 }
179 } 180 }
180 } 181 }
181 }; 182 };
182 $scope.datamfs = $scope.mfsValues; 183 $scope.datamfs = $scope.mfsValues;
183 }) 184 })
184 } 185 }
185 186
186 $scope.orderCostAndCount(); 187 $scope.orderCostAndCount();
187 $scope.getMFS(); 188 $scope.getMFS();
188 $scope.csValues = []; 189 $scope.csValues = [];
189 $scope.getCS = function() { 190 $scope.getCS = function() {
190 //var makeId = makeId; 191 //var makeId = makeId;
191 analyticsService.getCS().then(function(result) { 192 analyticsService.getCS().then(function(result) {
192 $scope.csValues = result; 193 $scope.csValues = result;
193 $scope.optionscs = { 194 $scope.optionscs = {
194 chart: { 195 chart: {
195 type: 'pieChart', 196 type: 'pieChart',
196 height: 500, 197 height: 500,
197 // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"], 198 // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"],
198 x: function(d) { 199 x: function(d) {
199 return d.key; 200 return d.key;
200 }, 201 },
201 y: function(d) { 202 y: function(d) {
202 return d.y; 203 return d.y;
203 }, 204 },
204 showLabels: false, 205 showLabels: false,
205 segmentShowStroke: false, 206 segmentShowStroke: false,
206 animationSteps: 20, 207 animationSteps: 20,
207 animationEasing: "linear", 208 animationEasing: "linear",
208 animateScale: true, 209 animateScale: true,
209 duration: 500, 210 duration: 500,
210 labelThreshold: 0.01, 211 labelThreshold: 0.01,
211 labelSunbeamLayout: true, 212 labelSunbeamLayout: true,
212 legend: { 213 legend: {
213 margin: { 214 margin: {
214 top: 5, 215 top: 5,
215 right: 35, 216 right: 35,
216 bottom: 5, 217 bottom: 5,
217 left: 0 218 left: 0
218 } 219 }
219 } 220 }
220 } 221 }
221 }; 222 };
222 $scope.datacs = $scope.csValues; 223 $scope.datacs = $scope.csValues;
223 }) 224 })
224 } 225 }
225 226
226 $scope.getCS(); 227 $scope.getCS();
227 228
228 229
229 $scope.hfpValues = []; 230 $scope.hfpValues = [];
230 $scope.getHfpChartData = function() { 231 $scope.getHfpChartData = function() {
231 //var makeId = makeId; 232 //var makeId = makeId;
232 analyticsService.gethfpChart().then(function(result) { 233 analyticsService.gethfpChart().then(function(result) {
233 $scope.hfpValues = result; 234 $scope.hfpValues = result;
234 //console.log('---kd result--',$scope.hfpValues); 235 //console.log('---kd result--',$scope.hfpValues);
235 236
236 /*Historic Fuel Price */ 237 /*Historic Fuel Price */
237 238
238 $scope.optionshfp = { 239 $scope.optionshfp = {
239 chart: { 240 chart: {
240 type: 'cumulativeLineChart', 241 type: 'cumulativeLineChart',
241 height: 450, 242 height: 450,
242 margin: { 243 margin: {
243 top: 40, 244 top: 40,
244 right: 20, 245 right: 20,
245 bottom: 50, 246 bottom: 50,
246 left: 65 247 left: 65
247 }, 248 },
248 x: function(d) { 249 x: function(d) {
249 return d[0]; 250 return d[0];
250 }, 251 },
251 y: function(d) { 252 y: function(d) {
252 return d[1] / 100 ; 253 return d[1] / 100 ;
253 }, 254 },
254 average: function(d) { 255 average: function(d) {
255 return d.mean / 100; 256 return d.mean / 100;
256 }, 257 },
257 258
258 color: ["#FEDFC3"], 259 color: ["#FEDFC3"],
259 duration: 300, 260 duration: 300,
260 useInteractiveGuideline: true, 261 useInteractiveGuideline: true,
261 clipVoronoi: false, 262 clipVoronoi: false,
262 263
263 xAxis: { 264 xAxis: {
264 axisLabel: '', 265 axisLabel: '',
265 266
266 tickFormat: function(d) { 267 tickFormat: function(d) {
267 return d3.time.format('%m/%d/%y')(new Date(d)) 268 return d3.time.format('%m/%d/%y')(new Date(d))
268 //return d3.time.format('%b \-%y')(new Date(d)) 269 //return d3.time.format('%b \-%y')(new Date(d))
269 }, 270 },
270 showMaxMin: false, 271 showMaxMin: false,
271 staggerLabels: true 272 staggerLabels: true
272 }, 273 },
273 274
274 yAxis: { 275 yAxis: {
275 axisLabel: 'PaP/Retail Price', 276 axisLabel: 'PaP/Retail Price',
276 277
277 tickFormat: function(d) { 278 tickFormat: function(d) {
278 //return d3.format('')(d).toFixed(2); 279 //return d3.format('')(d).toFixed(2);
279 return '$ '+d.toFixed(2) 280 return '$ '+d.toFixed(2)
280 }, 281 },
281 axisLabelDistance: 5 282 axisLabelDistance: 5
282 } 283 }
283 } 284 }
284 }; 285 };
285 $scope.datahfp = [{ 286 $scope.datahfp = [{
286 key: "Long", 287 key: "Long",
287 values: $scope.hfpValues, 288 values: $scope.hfpValues,
288 mean: 0 289 mean: 0
289 }]; 290 }];
290 291
291 }) 292 })
292 } 293 }
293 294
294 $scope.getHfpChartData(); 295 $scope.getHfpChartData();
295 296
296 297
297 /*Date Range Filter for Monthly fuel Sales*/ 298 /*Date Range Filter for Monthly fuel Sales*/
298 $scope.submitDate = function() { 299 $scope.submitDate = function() {
299 if ($scope.drf.fromDate === undefined) { 300 if ($scope.drf.fromDate === undefined) {
300 $scope.fillForm = true; 301 $scope.fillForm = true;
301 } else if ($scope.drf.fromDate != undefined && $scope.drf.toDate === undefined || $scope.drf.toDate === '') { 302 } else if ($scope.drf.fromDate != undefined && $scope.drf.toDate === undefined || $scope.drf.toDate === '') {
302 $scope.fillForm = false; 303 $scope.fillForm = false;
303 var today = new Date(); 304 var today = new Date();
304 var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2); 305 var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2);
305 //from date format 306 //from date format
306 $scope.dat1 = $scope.drf.fromDate; 307 $scope.dat1 = $scope.drf.fromDate;
307 $scope.fd1 = $scope.dat1.split("/").reverse(); 308 $scope.fd1 = $scope.dat1.split("/").reverse();
308 $scope.tmp = $scope.fd1[2]; 309 $scope.tmp = $scope.fd1[2];
309 $scope.fd1[2] = $scope.fd1[1]; 310 $scope.fd1[2] = $scope.fd1[1];
310 $scope.fd1[1] = $scope.tmp; 311 $scope.fd1[1] = $scope.tmp;
311 $scope.fd = $scope.fd1.join("-"); 312 $scope.fd = $scope.fd1.join("-");
312 analyticsService.getDRFChart($scope.fd, DefaultToDate).then(function(result) { 313 analyticsService.getDRFChart($scope.fd, DefaultToDate).then(function(result) {
313 $scope.datamfs = []; 314 $scope.datamfs = [];
314 $scope.datamfs = result; 315 $scope.datamfs = result;
315 }) 316 })
316 317
317 analyticsService.orderCostAndCountByDate($scope.fd, DefaultToDate).then(function(result) { 318 analyticsService.orderCostAndCountByDate($scope.fd, DefaultToDate).then(function(result) {
318 $scope.ordersCost = result.cost; 319 $scope.ordersCost = result.cost;
319 $scope.ordersCount = result.count; 320 $scope.ordersCount = result.count;
320 }) 321 })
321 } else if ($scope.drf.fromDate != undefined && $scope.drf.toDate != undefined) { 322 } else if ($scope.drf.fromDate != undefined && $scope.drf.toDate != undefined) {
322 $scope.fillForm = false; 323 $scope.fillForm = false;
323 //from date format 324 //from date format
324 $scope.dat1 = $scope.drf.fromDate; 325 $scope.dat1 = $scope.drf.fromDate;
325 $scope.fd1 = $scope.dat1.split("/").reverse(); 326 $scope.fd1 = $scope.dat1.split("/").reverse();
326 $scope.tmp = $scope.fd1[2]; 327 $scope.tmp = $scope.fd1[2];
327 $scope.fd1[2] = $scope.fd1[1]; 328 $scope.fd1[2] = $scope.fd1[1];
328 $scope.fd1[1] = $scope.tmp; 329 $scope.fd1[1] = $scope.tmp;
329 $scope.fd = $scope.fd1.join("-"); 330 $scope.fd = $scope.fd1.join("-");
330 $scope.dat2 = $scope.drf.toDate; 331 $scope.dat2 = $scope.drf.toDate;
331 $scope.td1 = $scope.dat2.split("/").reverse(); 332 $scope.td1 = $scope.dat2.split("/").reverse();
332 $scope.tmp1 = $scope.td1[2]; 333 $scope.tmp1 = $scope.td1[2];
333 $scope.td1[2] = $scope.td1[1]; 334 $scope.td1[2] = $scope.td1[1];
334 $scope.td1[1] = $scope.tmp1; 335 $scope.td1[1] = $scope.tmp1;
335 $scope.td = $scope.td1.join("-"); 336 $scope.td = $scope.td1.join("-");
336 337
337 analyticsService.getDRFChart($scope.fd, $scope.td).then(function(result) { 338 analyticsService.getDRFChart($scope.fd, $scope.td).then(function(result) {
338 $scope.datamfs = []; 339 $scope.datamfs = [];
339 $scope.datamfs = result; 340 $scope.datamfs = result;
340 }) 341 })
341 342
342 analyticsService.orderCostAndCountByDate($scope.fd, $scope.td).then(function(result) { 343 analyticsService.orderCostAndCountByDate($scope.fd, $scope.td).then(function(result) {
343 $scope.ordersCost = result.cost; 344 $scope.ordersCost = result.cost;
344 $scope.ordersCount = result.count; 345 $scope.ordersCount = result.count;
345 }) 346 })
346 347
347 } else { 348 } else {
348 $scope.fillForm = true; 349 $scope.fillForm = true;
349 } 350 }
350 351
351 352
352 } 353 }
353 354
354 /*Date Range Filter for Historic fuel Price*/ 355 /*Date Range Filter for Historic fuel Price*/
355 $scope.submitDateHfp = function() { 356 $scope.submitDateHfp = function() {
356 357
357 if ($scope.hfp.fromDate === undefined) { 358 if ($scope.hfp.fromDate === undefined) {
358 359
359 $scope.fillForm = true; 360 $scope.fillForm = true;
360 } else if ($scope.hfp.fromDate != undefined && $scope.hfp.toDate === undefined || $scope.hfp.toDate === '') { 361 } else if ($scope.hfp.fromDate != undefined && $scope.hfp.toDate === undefined || $scope.hfp.toDate === '') {
361 $scope.fillForm = false; 362 $scope.fillForm = false;
362 var today = new Date(); 363 var today = new Date();
363 var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2); 364 var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2);
364 //from date format 365 //from date format
365 $scope.dat1 = $scope.hfp.fromDate; 366 $scope.dat1 = $scope.hfp.fromDate;
366 $scope.fd1 = $scope.dat1.split("/").reverse(); 367 $scope.fd1 = $scope.dat1.split("/").reverse();
367 $scope.tmp = $scope.fd1[2]; 368 $scope.tmp = $scope.fd1[2];
368 $scope.fd1[2] = $scope.fd1[1]; 369 $scope.fd1[2] = $scope.fd1[1];
369 $scope.fd1[1] = $scope.tmp; 370 $scope.fd1[1] = $scope.tmp;
370 $scope.fd = $scope.fd1.join("-"); 371 $scope.fd = $scope.fd1.join("-");
371 analyticsService.getDRFHfpChart($scope.fd, DefaultToDate).then(function(result) { 372 analyticsService.getDRFHfpChart($scope.fd, DefaultToDate).then(function(result) {
372 $scope.hfpValues = result; 373 $scope.hfpValues = result;
373 $scope.optionshfp = { 374 $scope.optionshfp = {
374 chart: { 375 chart: {
375 type: 'cumulativeLineChart', 376 type: 'cumulativeLineChart',
376 height: 450, 377 height: 450,
377 margin: { 378 margin: {
378 top: 40, 379 top: 40,
379 right: 20, 380 right: 20,
380 bottom: 50, 381 bottom: 50,
381 left: 65 382 left: 65
382 }, 383 },
383 x: function(d) { 384 x: function(d) {
384 return d[0]; 385 return d[0];
385 }, 386 },
386 y: function(d) { 387 y: function(d) {
387 return d[1] / 100; 388 return d[1] / 100;
388 }, 389 },
389 average: function(d) { 390 average: function(d) {
390 return d.mean / 100; 391 return d.mean / 100;
391 }, 392 },
392 393
393 color: ["#FEDFC3"], 394 color: ["#FEDFC3"],
394 duration: 300, 395 duration: 300,
395 useInteractiveGuideline: true, 396 useInteractiveGuideline: true,
396 clipVoronoi: false, 397 clipVoronoi: false,
397 398
398 xAxis: { 399 xAxis: {
399 axisLabel: '', 400 axisLabel: '',
400 401
401 tickFormat: function(d) { 402 tickFormat: function(d) {
402 return d3.time.format('%d / %m / %y')(new Date(d)) 403 return d3.time.format('%d / %m / %y')(new Date(d))
403 // return d3.time.format('%b \-%y')(new Date(d)) 404 // return d3.time.format('%b \-%y')(new Date(d))
404 }, 405 },
405 showMaxMin: false, 406 showMaxMin: false,
406 staggerLabels: true 407 staggerLabels: true
407 }, 408 },
408 409
409 yAxis: { 410 yAxis: {
410 axisLabel: 'PaP/Retail Price', 411 axisLabel: 'PaP/Retail Price',
411 412
412 tickFormat: function(d) { 413 tickFormat: function(d) {
413 //return d3.format('')(d).toFixed(2); 414 //return d3.format('')(d).toFixed(2);
414 return '$ '+d.toFixed(2) 415 return '$ '+d.toFixed(2)
415 }, 416 },
416 axisLabelDistance: 5 417 axisLabelDistance: 5
417 } 418 }
418 } 419 }
419 }; 420 };
420 $scope.datahfp = [{ 421 $scope.datahfp = [{
421 key: "Long", 422 key: "Long",
422 values: $scope.hfpValues, 423 values: $scope.hfpValues,
423 mean: 0 424 mean: 0
424 }]; 425 }];
425 }) 426 })
426 427
427 428
428 } else if ($scope.hfp.fromDate != undefined && $scope.hfp.toDate != undefined) { 429 } else if ($scope.hfp.fromDate != undefined && $scope.hfp.toDate != undefined) {
429 $scope.fillForm = false; 430 $scope.fillForm = false;
430 //from date format 431 //from date format
431 $scope.dat1 = $scope.hfp.fromDate; 432 $scope.dat1 = $scope.hfp.fromDate;
432 $scope.fd1 = $scope.dat1.split("/").reverse(); 433 $scope.fd1 = $scope.dat1.split("/").reverse();
433 $scope.tmp = $scope.fd1[2]; 434 $scope.tmp = $scope.fd1[2];
434 $scope.fd1[2] = $scope.fd1[1]; 435 $scope.fd1[2] = $scope.fd1[1];
435 $scope.fd1[1] = $scope.tmp; 436 $scope.fd1[1] = $scope.tmp;
436 $scope.fd = $scope.fd1.join("-"); 437 $scope.fd = $scope.fd1.join("-");
437 //to date format 438 //to date format
438 $scope.dat2 = $scope.hfp.toDate; 439 $scope.dat2 = $scope.hfp.toDate;
439 $scope.td1 = $scope.dat2.split("/").reverse(); 440 $scope.td1 = $scope.dat2.split("/").reverse();
440 $scope.tmp1 = $scope.td1[2]; 441 $scope.tmp1 = $scope.td1[2];
441 $scope.td1[2] = $scope.td1[1]; 442 $scope.td1[2] = $scope.td1[1];
442 $scope.td1[1] = $scope.tmp1; 443 $scope.td1[1] = $scope.tmp1;
443 $scope.td = $scope.td1.join("-"); 444 $scope.td = $scope.td1.join("-");
444 445
445 analyticsService.getDRFHfpChart($scope.fd, $scope.td).then(function(result) { 446 analyticsService.getDRFHfpChart($scope.fd, $scope.td).then(function(result) {
446 $scope.hfpValues = result; 447 $scope.hfpValues = result;
447 $scope.optionshfp = { 448 $scope.optionshfp = {
448 chart: { 449 chart: {
449 type: 'cumulativeLineChart', 450 type: 'cumulativeLineChart',
450 height: 450, 451 height: 450,
451 margin: { 452 margin: {
452 top: 40, 453 top: 40,
453 right: 20, 454 right: 20,
454 bottom: 50, 455 bottom: 50,
455 left: 65 456 left: 65
456 }, 457 },
457 x: function(d) { 458 x: function(d) {
458 return d[0]; 459 return d[0];
459 }, 460 },
460 y: function(d) { 461 y: function(d) {
461 return d[1] / 100 ; 462 return d[1] / 100 ;
462 }, 463 },
463 average: function(d) { 464 average: function(d) {
464 return d.mean / 100; 465 return d.mean / 100;
465 }, 466 },
466 467
467 color: ["#FEDFC3"], 468 color: ["#FEDFC3"],
468 duration: 300, 469 duration: 300,
469 useInteractiveGuideline: true, 470 useInteractiveGuideline: true,
470 clipVoronoi: false, 471 clipVoronoi: false,
471 472
472 xAxis: { 473 xAxis: {
473 axisLabel: '', 474 axisLabel: '',
474 475
475 tickFormat: function(d) { 476 tickFormat: function(d) {
476 return d3.time.format('%d / %m / %y')(new Date(d)) 477 return d3.time.format('%d / %m / %y')(new Date(d))
477 //return d3.time.format('%b \-%y')(new Date(d)) 478 //return d3.time.format('%b \-%y')(new Date(d))
478 }, 479 },
479 showMaxMin: false, 480 showMaxMin: false,
480 staggerLabels: true 481 staggerLabels: true
481 }, 482 },
482 483
483 yAxis: { 484 yAxis: {
484 axisLabel: 'PaP/Retail Price', 485 axisLabel: 'PaP/Retail Price',
485 486
486 tickFormat: function(d) { 487 tickFormat: function(d) {
487 //return d3.format('')(d).toFixed(2); 488 //return d3.format('')(d).toFixed(2);
488 return '$ '+d.toFixed(2) 489 return '$ '+d.toFixed(2)
489 }, 490 },
490 axisLabelDistance: 5 491 axisLabelDistance: 5
491 } 492 }
492 } 493 }
493 }; 494 };
494 $scope.datahfp = [{ 495 $scope.datahfp = [{
495 key: "Long", 496 key: "Long",
496 values:$scope.hfpValues, 497 values:$scope.hfpValues,
497 mean: 0 498 mean: 0
498 }]; 499 }];
499 }) 500 })
500 501
501 } else { 502 } else {
502 $scope.fillForm = true; 503 $scope.fillForm = true;
503 } 504 }
504 505
505 506
506 } 507 }
507 508
508 /*Date Range Filter for Customer Sources*/ 509 /*Date Range Filter for Customer Sources*/
509 $scope.submitDateCs = function() { 510 $scope.submitDateCs = function() {
510 if ($scope.cs.fromDate === undefined) { 511 if ($scope.cs.fromDate === undefined) {
511 512
512 $scope.fillForm = true; 513 $scope.fillForm = true;
513 } else if ($scope.cs.fromDate != undefined && $scope.cs.toDate === undefined || $scope.cs.toDate === '') { 514 } else if ($scope.cs.fromDate != undefined && $scope.cs.toDate === undefined || $scope.cs.toDate === '') {
514 $scope.fillForm = false; 515 $scope.fillForm = false;
515 var today = new Date(); 516 var today = new Date();
516 var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2); 517 var DefaultToDate = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2);
517 //from date format 518 //from date format
518 $scope.dat1 = $scope.cs.fromDate; 519 $scope.dat1 = $scope.cs.fromDate;
519 $scope.fd1 = $scope.dat1.split("/").reverse(); 520 $scope.fd1 = $scope.dat1.split("/").reverse();
520 $scope.tmp = $scope.fd1[2]; 521 $scope.tmp = $scope.fd1[2];
521 $scope.fd1[2] = $scope.fd1[1]; 522 $scope.fd1[2] = $scope.fd1[1];
522 $scope.fd1[1] = $scope.tmp; 523 $scope.fd1[1] = $scope.tmp;
523 $scope.fd = $scope.fd1.join("-"); 524 $scope.fd = $scope.fd1.join("-");
524 analyticsService.getDRFCSChart($scope.fd, DefaultToDate).then(function(result) { 525 analyticsService.getDRFCSChart($scope.fd, DefaultToDate).then(function(result) {
525 $scope.csValues = result; 526 $scope.csValues = result;
526 $scope.optionscs = { 527 $scope.optionscs = {
527 chart: { 528 chart: {
528 type: 'pieChart', 529 type: 'pieChart',
529 height: 500, 530 height: 500,
530 // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"], 531 // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"],
531 x: function(d) { 532 x: function(d) {
532 return d.key; 533 return d.key;
533 }, 534 },
534 y: function(d) { 535 y: function(d) {
535 return d.y; 536 return d.y;
536 }, 537 },
537 showLabels: false, 538 showLabels: false,
538 segmentShowStroke: false, 539 segmentShowStroke: false,
539 animationSteps: 20, 540 animationSteps: 20,
540 animationEasing: "linear", 541 animationEasing: "linear",
541 animateScale: true, 542 animateScale: true,
542 duration: 500, 543 duration: 500,
543 labelThreshold: 0.01, 544 labelThreshold: 0.01,
544 labelSunbeamLayout: true, 545 labelSunbeamLayout: true,
545 legend: { 546 legend: {
546 margin: { 547 margin: {
547 top: 5, 548 top: 5,
548 right: 35, 549 right: 35,
549 bottom: 5, 550 bottom: 5,
550 left: 0 551 left: 0
551 } 552 }
552 } 553 }
553 } 554 }
554 }; 555 };
555 $scope.datacs = $scope.csValues; 556 $scope.datacs = $scope.csValues;
556 }) 557 })
557 558
558 559
559 } else if ($scope.cs.fromDate != undefined && $scope.cs.toDate != undefined) { 560 } else if ($scope.cs.fromDate != undefined && $scope.cs.toDate != undefined) {
560 $scope.fillForm = false; 561 $scope.fillForm = false;
561 //from date format 562 //from date format
562 $scope.dat1 = $scope.cs.fromDate; 563 $scope.dat1 = $scope.cs.fromDate;
563 $scope.fd1 = $scope.dat1.split("/").reverse(); 564 $scope.fd1 = $scope.dat1.split("/").reverse();
564 $scope.tmp = $scope.fd1[2]; 565 $scope.tmp = $scope.fd1[2];
565 $scope.fd1[2] = $scope.fd1[1]; 566 $scope.fd1[2] = $scope.fd1[1];
566 $scope.fd1[1] = $scope.tmp; 567 $scope.fd1[1] = $scope.tmp;
567 $scope.fd = $scope.fd1.join("-"); 568 $scope.fd = $scope.fd1.join("-");
568 //to date format 569 //to date format
569 $scope.dat2 = $scope.cs.toDate; 570 $scope.dat2 = $scope.cs.toDate;
570 $scope.td1 = $scope.dat2.split("/").reverse(); 571 $scope.td1 = $scope.dat2.split("/").reverse();
571 $scope.tmp1 = $scope.td1[2]; 572 $scope.tmp1 = $scope.td1[2];
572 $scope.td1[2] = $scope.td1[1]; 573 $scope.td1[2] = $scope.td1[1];
573 $scope.td1[1] = $scope.tmp1; 574 $scope.td1[1] = $scope.tmp1;
574 $scope.td = $scope.td1.join("-"); 575 $scope.td = $scope.td1.join("-");
575 576
576 analyticsService.getDRFCSChart($scope.fd, $scope.td).then(function(result) { 577 analyticsService.getDRFCSChart($scope.fd, $scope.td).then(function(result) {
577 $scope.csValues = result; 578 $scope.csValues = result;
578 $scope.optionscs = { 579 $scope.optionscs = {
579 chart: { 580 chart: {
580 type: 'pieChart', 581 type: 'pieChart',
581 height: 500, 582 height: 500,
582 // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"], 583 // color: ["#FEDFC3","#D89700","#FFE8B3","FFD980","#FF7F0E","#fff2e6","#ffcc99","#ffa64d","#ff8c1a","#B37D00","#f5f5f0","#e0e0d1","#ccccb3","#adad85","#999966","#7a7a52"],
583 x: function(d) { 584 x: function(d) {
584 return d.key; 585 return d.key;
585 }, 586 },
586 y: function(d) { 587 y: function(d) {
587 return d.y; 588 return d.y;
588 }, 589 },
589 showLabels: false, 590 showLabels: false,
590 segmentShowStroke: false, 591 segmentShowStroke: false,
591 animationSteps: 20, 592 animationSteps: 20,
592 animationEasing: "linear", 593 animationEasing: "linear",
593 animateScale: true, 594 animateScale: true,
594 duration: 500, 595 duration: 500,
595 labelThreshold: 0.01, 596 labelThreshold: 0.01,
596 labelSunbeamLayout: true, 597 labelSunbeamLayout: true,
597 legend: { 598 legend: {
598 margin: { 599 margin: {
599 top: 5, 600 top: 5,
600 right: 35, 601 right: 35,
601 bottom: 5, 602 bottom: 5,
602 left: 0 603 left: 0
603 } 604 }
604 } 605 }
605 } 606 }
606 }; 607 };
607 $scope.datacs = $scope.csValues; 608 $scope.datacs = $scope.csValues;
608 }) 609 })
609 610
610 } else { 611 } else {
611 $scope.fillForm = true; 612 $scope.fillForm = true;
612 } 613 }
613 614
614 615
615 } 616 }
616 617
617 618
618 }]); 619 }]);
app/partials/login/login.controller.js
1 (function() { 1 (function() {
2 'use strict' 2 'use strict'
3 3
4 angular.module('acufuel') 4 angular.module('acufuel')
5 .controller('LoginController', [ '$scope', '$filter', '$rootScope', '$state','$location', 'LoginService', LoginController]); 5 .controller('LoginController', [ '$scope', '$filter', '$rootScope', '$state','$location', 'LoginService', LoginController]);
6 6
7 7
8 function LoginController($scope, $filter, $rootScope, $state,$location, LoginService) { 8 function LoginController($scope, $filter, $rootScope, $state,$location, LoginService) {
9 9
10 $scope.data = {}; 10 $scope.data = {};
11 $scope.data.username = ''; 11 $scope.data.username = '';
12 $scope.data.password = ''; 12 $scope.data.password = '';
13 $scope.count = 0; 13 $scope.count = 0;
14 var loginData; 14 var loginData;
15 localStorage.removeItem('requiredChangePwd'); 15 localStorage.removeItem('requiredChangePwd');
16 16
17 17
18 if($location.$$search && $location.$$search.tmppwd){ 18 if($location.$$search && $location.$$search.tmppwd){
19 19
20 $scope.data.username = $location.$$search.email; 20 $scope.data.username = $location.$$search.email;
21 $scope.data.password = $location.$$search.tmppwd; 21 $scope.data.password = $location.$$search.tmppwd;
22 localStorage.setItem('requiredChangePwd', "Y"); 22 localStorage.setItem('requiredChangePwd', "Y");
23 } 23 }
24 24
25 $scope.submitLogin = function() { 25 $scope.submitLogin = function() {
26 loginData = "username=" + $scope.data.username + "&password=" + $scope.data.password; 26 loginData = "username=" + $scope.data.username + "&password=" + $scope.data.password;
27 if ($scope.data.username !== '' && $scope.data.password !== '' && $scope.data.username !== undefined && $scope.data.password !== undefined) { 27 if ($scope.data.username !== '' && $scope.data.password !== '' && $scope.data.username !== undefined && $scope.data.password !== undefined) {
28 if ($scope.count === 0) { 28 if ($scope.count === 0) {
29 $scope.count++ 29 $scope.count++
30 LoginService.loginUser(loginData).then(function(result) { 30 LoginService.loginUser(loginData).then(function(result) {
31 var reqPwdChng = localStorage.getItem("requiredChangePwd"); 31 var reqPwdChng = localStorage.getItem("requiredChangePwd");
32 if(result.status == 200){ 32 if(result.status == 200){
33 if (reqPwdChng && reqPwdChng == "Y") { 33 if (reqPwdChng && reqPwdChng == "Y") {
34 $state.go('resetPassword'); 34 $state.go('resetPassword');
35 } else { 35 } else {
36 LoginService.authenticate().then(function(result){ 36 LoginService.authenticate().then(function(result){
37 console.log("==usertime from api===",result) 37 // console.log("==usertime from api===",result)
38 window.localStorage.setItem("userTime", JSON.stringify(result.userProfile.userTimeZone)); 38 window.localStorage.setItem("userTime", JSON.stringify(result.userProfile.userTimeZone));
39 39
40 var currentUserDetail = JSON.parse(window.localStorage.getItem("currentUser")); 40 var currentUserDetail = JSON.parse(window.localStorage.getItem("currentUser"));
41 if(currentUserDetail.type === 'ADDITIONAL'){ 41 if(currentUserDetail.type === 'ADDITIONAL'){
42 var email = $scope.data.username; 42 var email = $scope.data.username;
43 //console.log("hi",email) 43 //console.log("hi",email)
44 LoginService.getAdditionalAccess(email).then(function(result){ 44 LoginService.getAdditionalAccess(email).then(function(result){
45 // console.log("getaccess",result) 45 // console.log("getaccess",result)
46 window.localStorage.setItem("EPDAccess", JSON.stringify(result.allowEpd)); 46 window.localStorage.setItem("EPDAccess", JSON.stringify(result.allowEpd));
47 window.localStorage.setItem("FMAAccess", JSON.stringify(result.allowFma)); 47 window.localStorage.setItem("FMAAccess", JSON.stringify(result.allowFma));
48 }) 48 })
49 } 49 }
50 }) 50 })
51 51
52 } 52 }
53 53
54 }else{ 54 }else{
55 toastr.error('Username or password incorrect.', { 55 toastr.error('Username or password incorrect.', {
56 closeButton: true 56 closeButton: true
57 }); 57 });
58 $scope.count = 0; 58 $scope.count = 0;
59 } 59 }
60 60
61 }) 61 })
62 } 62 }
63 }else{ 63 }else{
64 toastr.error('Please enter username & password.', { 64 toastr.error('Please enter username & password.', {
65 closeButton: true 65 closeButton: true
66 }) 66 })
67 } 67 }
68 } 68 }
69 } 69 }
70 })(); 70 })();
71 71
72 72
app/partials/main/main.controller.js
1 (function() { 1 (function() {
2 'use strict' 2 'use strict'
3 3
4 angular.module('acufuel') 4 angular.module('acufuel')
5 .controller('MainController', [ '$scope', '$filter','$rootScope','$state', '$window', '$interval', MainController]); 5 .controller('MainController', [ '$scope', '$filter','$rootScope','$state', '$window', '$interval', MainController]);
6 6
7 function MainController($scope, $filter, $rootScope,$state, $window, $interval) { 7 function MainController($scope, $filter, $rootScope,$state, $window, $interval) {
8 8
9 $scope.currentUserName = JSON.parse(localStorage.getItem('currentUserName')); 9 $scope.currentUserName = JSON.parse(localStorage.getItem('currentUserName'));
10 $scope.companyName = JSON.parse(localStorage.getItem('companyName')); 10 $scope.companyName = JSON.parse(localStorage.getItem('companyName'));
11 var User = JSON.parse(localStorage.getItem('currentUser')); 11 var User = JSON.parse(localStorage.getItem('currentUser'));
12 12
13 //for login userTime from GetAPI timezone 13 //for login userTime from GetAPI timezone
14 var tempuserTime = JSON.parse(localStorage.getItem('userTime')); 14 var tempuserTime = JSON.parse(localStorage.getItem('userTime'));
15 15
16 if (tempuserTime != null) { 16 if (tempuserTime != null) {
17 if (tempuserTime.slice(0, 1) === "P") { 17 if (tempuserTime.slice(0, 1) === "P") {
18 $scope.userTimeZone = tempuserTime.replace("P", "+"); 18 $scope.userTimeZone = tempuserTime.replace("P", "+");
19 console.log("==p===",$scope.userTimeZone) 19 // console.log("==p===",$scope.userTimeZone)
20 console.log("======kd=======")
21 } else if (tempuserTime.slice(0, 1) === "M") { 20 } else if (tempuserTime.slice(0, 1) === "M") {
22 $scope.userTimeZone = tempuserTime.replace("M", "-"); 21 $scope.userTimeZone = tempuserTime.replace("M", "-");
23 console.log("==M===",$scope.userTimeZone) 22 //console.log("==M===",$scope.userTimeZone)
24 } 23 }
25 24
26 } else { 25 } else {
27 26
28 $scope.userTimeZone = JSON.parse(localStorage.getItem('userTimeZone')); 27 $scope.userTimeZone = JSON.parse(localStorage.getItem('userTimeZone'));
29 console.log("===$scope.userTimeZone==",$scope.userTimeZone) 28 //console.log("===$scope.userTimeZone==",$scope.userTimeZone)
30 } 29 }
31 30
32 31
33 if(User.type === 'ADDITIONAL'){ 32 if(User.type === 'ADDITIONAL'){
34 $scope.companyName = $scope.currentUserName; 33 $scope.companyName = $scope.currentUserName;
35 } 34 }
36 35
37 36
38 $scope.testFunction = function(){ 37 $scope.testFunction = function(){
39 $scope.currentUserName = JSON.parse(localStorage.getItem('currentUserName')); 38 $scope.currentUserName = JSON.parse(localStorage.getItem('currentUserName'));
40 $scope.companyName = JSON.parse(localStorage.getItem('companyName')); 39 $scope.companyName = JSON.parse(localStorage.getItem('companyName'));
41 $scope.userTimeZone = JSON.parse(localStorage.getItem('userTimeZone')); 40 $scope.userTimeZone = JSON.parse(localStorage.getItem('userTimeZone'));
42 console.log("===$scope.userTimeZone test==",$scope.userTimeZone) 41 //console.log("===$scope.userTimeZone test==",$scope.userTimeZone)
43 42
44 } 43 }
45 44
46 $scope.logout = function(){ 45 $scope.logout = function(){
47 $state.go('login'); 46 $state.go('login');
48 localStorage.clear(); 47 localStorage.clear();
49 $rootScope.isAuthenticated = false; 48 $rootScope.isAuthenticated = false;
50 49
51 } 50 }
52 51
53 /** 52 /**
54 Automatic logout session after 2 hours 53 Automatic logout session after 2 hours
55 **/ 54 **/
56 55
57 var resetTime; 56 var resetTime;
58 /*function warning(){ 57 /*function warning(){
59 //setTimeout(function(){ 58 //setTimeout(function(){
60 $('.warning-message').delay(5000).css('display', 'block'); 59 $('.warning-message').delay(5000).css('display', 'block');
61 //}, 5000); 60 //}, 5000);
62 }*/ 61 }*/
63 62
64 resetTime = setInterval(function(){ 63 resetTime = setInterval(function(){
65 // $('.warning-message').delay(5000).css('display', 'block'); 64 // $('.warning-message').delay(5000).css('display', 'block');
66 //console.log('out'); 65 //console.log('out');
67 localStorage.clear(); 66 localStorage.clear();
68 $state.go('login'); 67 $state.go('login');
69 }, 7200000); 68 }, 7200000);
70 69
71 70
72 $(document).mousemove(function(event){ 71 $(document).mousemove(function(event){
73 clearInterval(resetTime); 72 clearInterval(resetTime);
74 //$('.warning-message').delay(5000).css('display', 'none'); 73 //$('.warning-message').delay(5000).css('display', 'none');
75 // warning(); 74 // warning();
76 //console.log('restart'); 75 //console.log('restart');
77 resetTime = setInterval(function(){ 76 resetTime = setInterval(function(){
78 //console.log('out'); 77 //console.log('out');
79 //warning(); 78 //warning();
80 localStorage.clear(); 79 localStorage.clear();
81 $state.go('login'); 80 $state.go('login');
82 }, 7200000); 81 }, 7200000);
83 }) 82 })
84 83
85 84
86 85
87 // Flight Tracking page code 86 // Flight Tracking page code
88 87
89 /*$scope.reloadPage = function(){ 88 /*$scope.reloadPage = function(){
90 console.log("if",$state) 89 console.log("if",$state)
91 console.log("=========state name",$state.current.name); 90 console.log("=========state name",$state.current.name);
92 // $state.go('app.flightTracking', {}, {reload: 'app.flightTracking'}) 91 // $state.go('app.flightTracking', {}, {reload: 'app.flightTracking'})
93 //$state.go($state.current, {}, {reload: true}); 92 //$state.go($state.current, {}, {reload: true});
94 93
95 if($state.current.name != "app.flightTracking"){ 94 if($state.current.name != "app.flightTracking"){
96 $window.location.href = '/#!/flightTracking'; 95 $window.location.href = '/#!/flightTracking';
97 setInterval(function(){ 96 setInterval(function(){
98 console.log("come") 97 console.log("come")
99 $window.location.reload() 98 $window.location.reload()
100 },10); 99 },10);
101 }else{ 100 }else{
102 console.log("flight tracking state found====="); 101 console.log("flight tracking state found=====");
103 $window.location.reload(); 102 $window.location.reload();
104 } 103 }
105 }*/ 104 }*/
106 105
107 // Set timeout variables. 106 // Set timeout variables.
108 107
109 } 108 }
110 //var timoutWarning = 840000; // Display warning in 14 Mins. 109 //var timoutWarning = 840000; // Display warning in 14 Mins.
111 //var timoutNow = 900000; // Timeout in 15 mins. 110 //var timoutNow = 900000; // Timeout in 15 mins.
112 111
113 112
114 113
115 114
116 })(); 115 })();
117 116
118 117
app/partials/scheduler/scheduler.controller.js
1 'use strict'; 1 'use strict';
2 2
3 angular.module('acufuel') 3 angular.module('acufuel')
4 4
5 .controller('schedulerController', ['$scope','$compile', 'uiCalendarConfig', 'schedulerService', function($scope, $compile, uiCalendarConfig, schedulerService) { 5 .controller('schedulerController', ['$scope','$compile', 'uiCalendarConfig', 'schedulerService', function($scope, $compile, uiCalendarConfig, schedulerService) {
6 6
7 7
8 $scope.showLoader = true; 8 $scope.showLoader = true;
9 getEventsList(); 9 getEventsList();
10 10
11 /*---get events on calendar---*/ 11 /*---get events on calendar---*/
12 $scope.events = []; 12 $scope.events = [];
13 function getEventsList(){ 13 function getEventsList(){
14 schedulerService.getEvents().then(function(result) { 14 schedulerService.getEvents().then(function(result) {
15 //console.log('----kd events-------',result); 15 //console.log('----kd events-------',result);
16 //console.log("==length===",result.length); 16 //console.log("==length===",result.length);
17 17
18 for (var i = 0; i < result.length; i++) { 18 for (var i = 0; i < result.length; i++) {
19 var newTime = new Date(result[i].deployDate); 19 var newTime = new Date(result[i].deployDate);
20 console.log("deployDate",result[i].deployDate) 20 // console.log("deployDate",result[i].deployDate)
21 var dmonth = newTime.getUTCMonth() + 1; //months from 1-12 21 var dmonth = newTime.getUTCMonth() + 1; //months from 1-12
22 var dday = newTime.getUTCDate(); 22 var dday = newTime.getUTCDate();
23 var dyear = newTime.getUTCFullYear(); 23 var dyear = newTime.getUTCFullYear();
24 var hours = newTime.getHours(); 24 var hours = newTime.getHours();
25 var min = newTime.getMinutes(); 25 var min = newTime.getMinutes();
26 var sec = newTime.getSeconds(); 26 var sec = newTime.getSeconds();
27 /* 27 /*
28 $scope.events.push({ 28 $scope.events.push({
29 'id': result[i].id, 29 'id': result[i].id,
30 'title': result[i].aircraft +',\n' + result[i].make +'/' + result[i].model +',\n' + result[i].requestedVolume +',' +result[i].priceQuote, 30 'title': result[i].aircraft +',\n' + result[i].make +'/' + result[i].model +',\n' + result[i].requestedVolume +',' +result[i].priceQuote,
31 'start': dyear+'-'+dmonth+'-'+dday 31 'start': dyear+'-'+dmonth+'-'+dday
32 32
33 })*/ 33 })*/
34 $scope.events.push({ 34 $scope.events.push({
35 'id': result[i].id, 35 'id': result[i].id,
36 'title': result[i].aircraft +'\n' + '(' + result[i].make +'/' + result[i].model + ')' + '\n' + 'for' + ' ' + result[i].requestedVolume + ' ' + 'gal.' + ' ' +'@' + ' ' +'$'+result[i].priceQuote, 36 'title': result[i].aircraft +'\n' + '(' + result[i].make +'/' + result[i].model + ')' + '\n' + 'for' + ' ' + result[i].requestedVolume + ' ' + 'gal.' + ' ' +'@' + ' ' +'$'+result[i].priceQuote,
37 'start': dyear+'-'+dmonth+'-'+dday + ' ' + hours + ':' + min + ':' + sec 37 'start': dyear+'-'+dmonth+'-'+dday + ' ' + hours + ':' + min + ':' + sec
38 38
39 }) 39 })
40 // $scope.showEventsList(); 40 // $scope.showEventsList();
41 $scope.showLoader = false; 41 $scope.showLoader = false;
42 42
43 } 43 }
44 44
45 $('#my-calendar').fullCalendar('removeEvents'); 45 $('#my-calendar').fullCalendar('removeEvents');
46 $('#my-calendar').fullCalendar('addEventSource',$scope.events); 46 $('#my-calendar').fullCalendar('addEventSource',$scope.events);
47 // $scope.eventSources = [$scope.events, $scope.eventSource, $scope.eventsF]; 47 // $scope.eventSources = [$scope.events, $scope.eventSource, $scope.eventsF];
48 48
49 // console.log('==eventSource are====',$scope.eventSources); 49 // console.log('==eventSource are====',$scope.eventSources);
50 // $scope.newFuelPricing[i].futureFuelPricing.deployDate = dmonth+'/'+dday+'/'+dyear; 50 // $scope.newFuelPricing[i].futureFuelPricing.deployDate = dmonth+'/'+dday+'/'+dyear;
51 }) 51 })
52 } 52 }
53 53
54 54
55 55
56 $scope.newEvent = {}; 56 $scope.newEvent = {};
57 $scope.addNewEvent = function(){ 57 $scope.addNewEvent = function(){
58 //console.log('newEvent', $scope.newEvent); 58 //console.log('newEvent', $scope.newEvent);
59 $scope.showLoader = true; 59 $scope.showLoader = true;
60 if ($scope.newEvent.deployDate != undefined) { 60 if ($scope.newEvent.deployDate != undefined) {
61 $scope.newEvent.deployDate = new Date($scope.newEvent.deployDate); 61 $scope.newEvent.deployDate = new Date($scope.newEvent.deployDate);
62 $scope.newEvent.deployDate = $scope.newEvent.deployDate.getTime(); 62 $scope.newEvent.deployDate = $scope.newEvent.deployDate.getTime();
63 } 63 }
64 //var data = 'aircraft='+$scope.newEvent.aircraft+'&deployDate='+$scope.newEvent.deployDate; 64 //var data = 'aircraft='+$scope.newEvent.aircraft+'&deployDate='+$scope.newEvent.deployDate;
65 schedulerService.addNewEventService($scope.newEvent).then(function(response){ 65 schedulerService.addNewEventService($scope.newEvent).then(function(response){
66 $scope.newEvent = {}; 66 $scope.newEvent = {};
67 $('#addEvent').modal('hide'); 67 $('#addEvent').modal('hide');
68 $scope.events = []; 68 $scope.events = [];
69 getEventsList(); 69 getEventsList();
70 }) 70 })
71 } 71 }
72 72
73 $scope.cancelAdd = function(){ 73 $scope.cancelAdd = function(){
74 $scope.newEvent = {}; 74 $scope.newEvent = {};
75 } 75 }
76 76
77 $scope.editData = {}; 77 $scope.editData = {};
78 $scope.editEvent = function(data){ 78 $scope.editEvent = function(data){
79 $scope.editData = data; 79 $scope.editData = data;
80 $('#editEvent').modal('show'); 80 $('#editEvent').modal('show');
81 } 81 }
82 $scope.updateEvent = function(){ 82 $scope.updateEvent = function(){
83 $scope.showLoader = true; 83 $scope.showLoader = true;
84 $scope.updatedData = {}; 84 $scope.updatedData = {};
85 $scope.updatedData.id = $scope.editData.id; 85 $scope.updatedData.id = $scope.editData.id;
86 $scope.updatedData.deployDate = $scope.editData.start; 86 $scope.updatedData.deployDate = $scope.editData.start;
87 if ($scope.updatedData.deployDate != undefined) { 87 if ($scope.updatedData.deployDate != undefined) {
88 $scope.updatedData.deployDate = new Date($scope.updatedData.deployDate); 88 $scope.updatedData.deployDate = new Date($scope.updatedData.deployDate);
89 $scope.updatedData.deployDate = $scope.updatedData.deployDate.getTime(); 89 $scope.updatedData.deployDate = $scope.updatedData.deployDate.getTime();
90 } 90 }
91 schedulerService.updateScheduledEvent($scope.updatedData).then(function(response){ 91 schedulerService.updateScheduledEvent($scope.updatedData).then(function(response){
92 //console.log('response', response); 92 //console.log('response', response);
93 $scope.updatedData = {}; 93 $scope.updatedData = {};
94 $('#editEvent').modal('hide'); 94 $('#editEvent').modal('hide');
95 toastr.success('Updated Successfully', { 95 toastr.success('Updated Successfully', {
96 closeButton: true 96 closeButton: true
97 }) 97 })
98 $scope.events = []; 98 $scope.events = [];
99 getEventsList(); 99 getEventsList();
100 }) 100 })
101 } 101 }
102 102
103 103
104 /* code for calendar */ 104 /* code for calendar */
105 105
106 var date = new Date(); 106 var date = new Date();
107 var d = date.getDate(); 107 var d = date.getDate();
108 var m = date.getMonth(); 108 var m = date.getMonth();
109 var y = date.getFullYear(); 109 var y = date.getFullYear();
110 110
111 $scope.changeTo = 'Hungarian'; 111 $scope.changeTo = 'Hungarian';
112 112
113 $scope.eventSource = {}; 113 $scope.eventSource = {};
114 114
115 $scope.eventsF = function (start, end, timezone, callback) { 115 $scope.eventsF = function (start, end, timezone, callback) {
116 var s = new Date(start).getTime() / 1000; 116 var s = new Date(start).getTime() / 1000;
117 var e = new Date(end).getTime() / 1000; 117 var e = new Date(end).getTime() / 1000;
118 var m = new Date(start).getMonth(); 118 var m = new Date(start).getMonth();
119 var events = [{title: 'Feed Me ' + m,start: s + (50000),end: s + (100000),allDay: false, className: ['customFeed']}]; 119 var events = [{title: 'Feed Me ' + m,start: s + (50000),end: s + (100000),allDay: false, className: ['customFeed']}];
120 callback(events); 120 callback(events);
121 }; 121 };
122 122
123 $scope.calEventsExt = { 123 $scope.calEventsExt = {
124 color: '#f00', 124 color: '#f00',
125 textColor: 'yellow', 125 textColor: 'yellow',
126 events: [] 126 events: []
127 }; 127 };
128 128
129 $scope.alertOnEventClick = function( date, jsEvent, view){ 129 $scope.alertOnEventClick = function( date, jsEvent, view){
130 $scope.alertMessage = (date.title + ' was clicked '); 130 $scope.alertMessage = (date.title + ' was clicked ');
131 }; 131 };
132 132
133 $scope.alertOnDrop = function(event, delta, revertFunc, jsEvent, ui, view){ 133 $scope.alertOnDrop = function(event, delta, revertFunc, jsEvent, ui, view){
134 console.log('-----aa-'); 134 console.log('-----aa-');
135 var dmonth = event.start._d.getUTCMonth() + 1; //months from 1-12 135 var dmonth = event.start._d.getUTCMonth() + 1; //months from 1-12
136 var dday = event.start._d.getUTCDate(); 136 var dday = event.start._d.getUTCDate();
137 var dyear = event.start._d.getUTCFullYear(); 137 var dyear = event.start._d.getUTCFullYear();
138 var setDeploy = new Date(); 138 var setDeploy = new Date();
139 var hours = setDeploy.getHours(); 139 var hours = setDeploy.getHours();
140 var min = setDeploy.getMinutes(); 140 var min = setDeploy.getMinutes();
141 var sec = setDeploy.getSeconds(); 141 var sec = setDeploy.getSeconds();
142 142
143 for (var i = 0; i < $scope.events.length; i++) { 143 for (var i = 0; i < $scope.events.length; i++) {
144 if ($scope.events[i].id == event.id) { 144 if ($scope.events[i].id == event.id) {
145 145
146 //console.log('events', $scope.events[i]); 146 //console.log('events', $scope.events[i]);
147 //$scope.events[i].start = dyear+'-'+dmonth+'-'+dday; 147 //$scope.events[i].start = dyear+'-'+dmonth+'-'+dday;
148 $scope.showLoader = true; 148 $scope.showLoader = true;
149 $scope.updatedDataDrop = {}; 149 $scope.updatedDataDrop = {};
150 $scope.updatedDataDrop.id = $scope.events[i].id; 150 $scope.updatedDataDrop.id = $scope.events[i].id;
151 $scope.updatedDataDrop.aircraft = $scope.events[i].title; 151 $scope.updatedDataDrop.aircraft = $scope.events[i].title;
152 $scope.updatedDataDrop.deployDate = dyear+'-'+dmonth+'-'+dday + ' ' + hours + ':' + min + ':' + sec; 152 $scope.updatedDataDrop.deployDate = dyear+'-'+dmonth+'-'+dday + ' ' + hours + ':' + min + ':' + sec;
153 console.log('date-----', $scope.updatedDataDrop.deployDate); 153 console.log('date-----', $scope.updatedDataDrop.deployDate);
154 if ($scope.updatedDataDrop.deployDate != undefined) { 154 if ($scope.updatedDataDrop.deployDate != undefined) {
155 $scope.updatedDataDrop.deployDate = new Date($scope.updatedDataDrop.deployDate); 155 $scope.updatedDataDrop.deployDate = new Date($scope.updatedDataDrop.deployDate);
156 $scope.updatedDataDrop.deployDate = $scope.updatedDataDrop.deployDate.getTime(); 156 $scope.updatedDataDrop.deployDate = $scope.updatedDataDrop.deployDate.getTime();
157 console.log('date----222-', $scope.updatedDataDrop.deployDate); 157 console.log('date----222-', $scope.updatedDataDrop.deployDate);
158 } 158 }
159 schedulerService.updateScheduledEvent($scope.updatedDataDrop).then(function(response){ 159 schedulerService.updateScheduledEvent($scope.updatedDataDrop).then(function(response){
160 // console.log('response', response); 160 // console.log('response', response);
161 $scope.updatedDataDrop = {}; 161 $scope.updatedDataDrop = {};
162 $('#editEvent').modal('hide'); 162 $('#editEvent').modal('hide');
163 toastr.success('Updated Successfully', { 163 toastr.success('Updated Successfully', {
164 closeButton: true 164 closeButton: true
165 }) 165 })
166 $scope.events = []; 166 $scope.events = [];
167 getEventsList(); 167 getEventsList();
168 }) 168 })
169 169
170 } 170 }
171 } 171 }
172 //console.log('$scope.events new', $scope.events); 172 //console.log('$scope.events new', $scope.events);
173 $scope.alertMessage = ('Event Droped to make dayDelta ' + delta); 173 $scope.alertMessage = ('Event Droped to make dayDelta ' + delta);
174 }; 174 };
175 175
176 $scope.alertOnResize = function(event, delta, revertFunc, jsEvent, ui, view ){ 176 $scope.alertOnResize = function(event, delta, revertFunc, jsEvent, ui, view ){
177 $scope.alertMessage = ('Event Resized to make dayDelta ' + delta); 177 $scope.alertMessage = ('Event Resized to make dayDelta ' + delta);
178 }; 178 };
179 179
180 $scope.addRemoveEventSource = function(sources,source) { 180 $scope.addRemoveEventSource = function(sources,source) {
181 var canAdd = 0; 181 var canAdd = 0;
182 angular.forEach(sources,function(value, key){ 182 angular.forEach(sources,function(value, key){
183 if(sources[key] === source){ 183 if(sources[key] === source){
184 sources.splice(key,1); 184 sources.splice(key,1);
185 canAdd = 1; 185 canAdd = 1;
186 } 186 }
187 }); 187 });
188 if(canAdd === 0){ 188 if(canAdd === 0){
189 sources.push(source); 189 sources.push(source);
190 } 190 }
191 }; 191 };
192 192
193 $scope.addEvent = function() { 193 $scope.addEvent = function() {
194 $scope.events.push({ 194 $scope.events.push({
195 title: 'Open Sesame', 195 title: 'Open Sesame',
196 start: new Date(y, m, 28), 196 start: new Date(y, m, 28),
197 end: new Date(y, m, 29), 197 end: new Date(y, m, 29),
198 className: ['openSesame'] 198 className: ['openSesame']
199 }); 199 });
200 }; 200 };
201 201
202 $scope.remove = function(index) { 202 $scope.remove = function(index) {
203 $scope.events.splice(index,1); 203 $scope.events.splice(index,1);
204 }; 204 };
205 205
206 $scope.changeView = function(view,calendar) { 206 $scope.changeView = function(view,calendar) {
207 uiCalendarConfig.calendars[calendar].fullCalendar('changeView',view); 207 uiCalendarConfig.calendars[calendar].fullCalendar('changeView',view);
208 }; 208 };
209 209
210 $scope.renderCalender = function(calendar) { 210 $scope.renderCalender = function(calendar) {
211 if(uiCalendarConfig.calendars[calendar]){ 211 if(uiCalendarConfig.calendars[calendar]){
212 uiCalendarConfig.calendars[calendar].fullCalendar('render'); 212 uiCalendarConfig.calendars[calendar].fullCalendar('render');
213 } 213 }
214 }; 214 };
215 215
216 $scope.eventRender = function( event, element, view ) { 216 $scope.eventRender = function( event, element, view ) {
217 element.attr({'tooltip': event.title, 217 element.attr({'tooltip': event.title,
218 'tooltip-append-to-body': true}); 218 'tooltip-append-to-body': true});
219 $compile(element)($scope); 219 $compile(element)($scope);
220 }; 220 };
221 221
222 $scope.uiConfig = { 222 $scope.uiConfig = {
223 calendar:{ 223 calendar:{
224 height: 450, 224 height: 450,
225 editable: true, 225 editable: true,
226 droppable: true, 226 droppable: true,
227 drop: function (event, delta, revertFunc, jsEvent, ui, view) { 227 drop: function (event, delta, revertFunc, jsEvent, ui, view) {
228 }, 228 },
229 header:{ 229 header:{
230 right: 'month basicWeek basicDay', 230 right: 'month basicWeek basicDay',
231 center: 'title', 231 center: 'title',
232 left: 'prev,next, today' 232 left: 'prev,next, today'
233 }, 233 },
234 eventClick: $scope.alertOnEventClick, 234 eventClick: $scope.alertOnEventClick,
235 eventDrop: $scope.alertOnDrop, 235 eventDrop: $scope.alertOnDrop,
236 eventResize: $scope.alertOnResize, 236 eventResize: $scope.alertOnResize,
237 eventRender: $scope.eventRender 237 eventRender: $scope.eventRender
238 } 238 }
239 }; 239 };
240 240
241 $scope.addEvent = function(index) { 241 $scope.addEvent = function(index) {
242 //console.log('INDEX', index); 242 //console.log('INDEX', index);
243 //console.log('EVENTS', $scope.eventSources); 243 //console.log('EVENTS', $scope.eventSources);
244 // $scope.events.push($scope.eventList[index]); 244 // $scope.events.push($scope.eventList[index]);
245 } 245 }
246 246
247 /*$scope.showEventsList = function(){ 247 /*$scope.showEventsList = function(){
248 console.log('testing', $scope.eventsF); 248 console.log('testing', $scope.eventsF);
249 249
250 };*/ 250 };*/
251 251
252 // $scope.eventSources = [$scope.events, $scope.eventSource, $scope.eventsF]; 252 // $scope.eventSources = [$scope.events, $scope.eventSource, $scope.eventsF];
253 253
254 //$scope.eventSources2 = [$scope.calEventsExt, $scope.eventsF, $scope.events]; 254 //$scope.eventSources2 = [$scope.calEventsExt, $scope.eventsF, $scope.events];
255 }]); 255 }]);
256 256
257 257