Blame view

app/partials/dashboard/dashboard.controller.js 13.5 KB
feacde5ff   Rishav   setup acuefuel in...
1
2
3
4
      (function() {
      'use strict'
      
      angular.module('acufuel')
176381a3a   Anchit Jindal   minor changes
5
          .controller('dashboardController', [ '$scope', '$filter', '$rootScope', '$state', 'dashboardService','updateFuelManagerService', 'analyticsService', dashboardController]);
feacde5ff   Rishav   setup acuefuel in...
6
          
176381a3a   Anchit Jindal   minor changes
7
      function dashboardController($scope, $filter, $rootScope, $state, dashboardService,updateFuelManagerService,analyticsService) {
26f8c698a   Kuldeep Arora   fixes
8
          
dd378d69f   Mr. Hot Foods   changes in flight...
9
10
11
          $scope.getQuote = true;
          $scope.showQuote = false;
          $scope.getQuote = function () {
1b71872b2   Kuldeep Arora   email and code be...
12
          $scope.getQuote = false;
dd378d69f   Mr. Hot Foods   changes in flight...
13
              $scope.showQuote = true;
1b71872b2   Kuldeep Arora   email and code be...
14
        }
dd378d69f   Mr. Hot Foods   changes in flight...
15

1b71872b2   Kuldeep Arora   email and code be...
16
        $scope.logout = function () {
f62f8940f   Kuldeep Arora   UI changes
17
          localStorage.clear();
1b71872b2   Kuldeep Arora   email and code be...
18
19
20
21
          localStorage.removeItem("loginStatus");
          $rootScope.path = false;
          $state.reload();
        }
9732e9b36   Swarn Singh   updates in fuel m...
22

a49ef5361   Kuldeep Arora   dashboard & Sched...
23
            $scope.marginList = {};
6275a96f0   Jaideep Singh   s
24
25
               dashboardService.getMargin().then(function(result) {
                  $scope.marginList = result;
961a97a2f   Kuldeep Arora   Enhancement in de...
26
                 // console.log("--kd Margin result--", result)
6275a96f0   Jaideep Singh   s
27
              })
9732e9b36   Swarn Singh   updates in fuel m...
28
29
30
          $scope.newFuelPricing = {};
          dashboardService.getFuelPricingNew().then(function(result) {
              $scope.newFuelPricing = result;
961a97a2f   Kuldeep Arora   Enhancement in de...
31
            //  console.log("kd Fuel Pricing result", result)
9732e9b36   Swarn Singh   updates in fuel m...
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
                for (var i = 0; i<$scope.newFuelPricing.length; i++) {
                  if ($scope.newFuelPricing[i].fuelPricing != null) {
                      if ($scope.newFuelPricing[i].fuelPricing.expirationDate != null && $scope.newFuelPricing[i].fuelPricing.expirationDate != '') {
                          var newTime = new Date($scope.newFuelPricing[i].fuelPricing.expirationDate);
                          var month = newTime.getUTCMonth() + 1; //months from 1-12
                          var day = newTime.getUTCDate();
                          var year = newTime.getUTCFullYear();
                          $scope.newFuelPricing[i].fuelPricing.expirationDate = month+'/'+day+'/'+year;
                      }
                  }
                  if ($scope.newFuelPricing[i].futureFuelPricing != null) {
                      if ($scope.newFuelPricing[i].futureFuelPricing != null) {
                          if ($scope.newFuelPricing[i].futureFuelPricing.nextExpiration != null && $scope.newFuelPricing[i].futureFuelPricing.nextExpiration != '') {
                              var newTime = new Date($scope.newFuelPricing[i].futureFuelPricing.nextExpiration);
                              var nextMonth = newTime.getUTCMonth() + 1; //months from 1-12
                              var nextDay = newTime.getUTCDate();
                              var nextYear = newTime.getUTCFullYear();
                              $scope.newFuelPricing[i].futureFuelPricing.nextExpiration = nextMonth+'/'+nextDay+'/'+nextYear;
                          }
                      }
                      if ($scope.newFuelPricing[i].futureFuelPricing != null) {
                          if ($scope.newFuelPricing[i].futureFuelPricing.deployDate != null && $scope.newFuelPricing[i].futureFuelPricing.deployDate != '') {
                              var newTime = new Date($scope.newFuelPricing[i].futureFuelPricing.deployDate);
                              var dmonth = newTime.getUTCMonth() + 1; //months from 1-12
                              var dday = newTime.getUTCDate();
                              var dyear = newTime.getUTCFullYear();
                              $scope.newFuelPricing[i].futureFuelPricing.deployDate = dmonth+'/'+dday+'/'+dyear;
                          }
                      }
                  }
05bfa28a2   Mr. Hot Foods   remove save butto...
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
                  var str =""+ $scope.newFuelPricing[i].name
                 if(str.startsWith("J")){
                    $scope.newFuelPricing[i].jeta = true;
                    var str1 = str.substring(0,5)
                    var str2 = str.substring(6, str.length)
                    $scope.newFuelPricing[i].name = str1
                    $scope.newFuelPricing[i].namejetrest = str2
  
  
                }else if(str.startsWith("100")){
                    $scope.newFuelPricing[i].avgas = true;
                    var str1 = str.substring(0,5)
                    var str2 = str.substring(6, str.length)
                    $scope.newFuelPricing[i].name = str1
                    $scope.newFuelPricing[i].nameavgasrest = str2
                }
9732e9b36   Swarn Singh   updates in fuel m...
78
79
80
                }
                $scope.showLoader = false;
          })
6275a96f0   Jaideep Singh   s
81
         
9732e9b36   Swarn Singh   updates in fuel m...
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
  
          $scope.updateFuelPricing = {};
          $scope.updateFuelPricing.fuelPricingList = [];
          $scope.updateFuelPricing.userProfileId = $scope.userProfileId;
          $scope.updateFuelPricingClick = function(){
              $scope.showLoader = true;
  
              for (var i = 0; i<$scope.newFuelPricing.length; i++) {
                  if ($scope.newFuelPricing[i].fuelPricing != null) {
                      $scope.newFuelPricing[i].fuelPricing.papTotal = parseFloat($scope.newFuelPricing[i].fuelPricing.cost) + parseFloat($scope.newFuelPricing[i].fuelPricing.papMargin);
                      if ($scope.newFuelPricing[i].fuelPricing.cost == null) {
                          $scope.newFuelPricing[i].fuelPricing.cost = '';
                      }
                      if ($scope.newFuelPricing[i].fuelPricing.papMargin == null) {
                          $scope.newFuelPricing[i].fuelPricing.papMargin = '';
                      }
                      if ($scope.newFuelPricing[i].fuelPricing.papTotal == null) {
                          $scope.newFuelPricing[i].fuelPricing.papTotal = '';
                      }
                      if ($scope.newFuelPricing[i].fuelPricing.expirationDate == null) {
                          $scope.newFuelPricing[i].fuelPricing.expirationDate = '';
                      }else{
                          $scope.newFuelPricing[i].fuelPricing.expirationDate = new Date($scope.newFuelPricing[i].fuelPricing.expirationDate);
961a97a2f   Kuldeep Arora   Enhancement in de...
105
                         // console.log('$scope.newFuelPricing[i].fuelPricing.expirationDate', $scope.newFuelPricing[i].fuelPricing.expirationDate);
9732e9b36   Swarn Singh   updates in fuel m...
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
                          $scope.newFuelPricing[i].fuelPricing.expirationDate = $scope.newFuelPricing[i].fuelPricing.expirationDate.getTime();
                      }
  
                      $scope.newFuelPricing[i].fuelPricing.papTotal = parseFloat($scope.newFuelPricing[i].fuelPricing.cost) + parseFloat($scope.newFuelPricing[i].fuelPricing.papMargin);
                      $scope.updateFuelPricing.fuelPricingList.push({
                          'cost': $scope.newFuelPricing[i].fuelPricing.cost,
                          'papMargin': $scope.newFuelPricing[i].fuelPricing.papMargin,
                          'papTotal': $scope.newFuelPricing[i].fuelPricing.papTotal,
                          'expirationDate': $scope.newFuelPricing[i].fuelPricing.expirationDate,
                          'productId': $scope.newFuelPricing[i].id,
                          'id': $scope.newFuelPricing[i].fuelPricing.id,
                      })
                      
                  }else{
                      /*$scope.newFuelPricing[i].fuelPricing.cost = '';
                      $scope.newFuelPricing[i].fuelPricing.papMargin = '';
                      $scope.newFuelPricing[i].fuelPricing.papTotal = '';
                      $scope.newFuelPricing[i].fuelPricing.expirationDate = '';*/
                  }
                  
              }
6275a96f0   Jaideep Singh   s
127

961a97a2f   Kuldeep Arora   Enhancement in de...
128
             // console.log('result',$scope.marginList)
9732e9b36   Swarn Singh   updates in fuel m...
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
              dashboardService.updateFuelPricing($scope.updateFuelPricing).then(function(result) {
                  toastr.success('Successfully Updated', {
                    closeButton: true
                  })
                  dashboardService.getFuelPricingNew().then(function(result) {
                      $scope.newFuelPricing = result;
                        for (var i = 0; i<$scope.newFuelPricing.length; i++) {
                          if ($scope.newFuelPricing[i].fuelPricing != null) {
                              if ($scope.newFuelPricing[i].fuelPricing.expirationDate != null && $scope.newFuelPricing[i].fuelPricing.expirationDate != '') {
                                  var newTime = new Date($scope.newFuelPricing[i].fuelPricing.expirationDate);
                                  var month = newTime.getUTCMonth() + 1; //months from 1-12
                                  var day = newTime.getUTCDate();
                                  var year = newTime.getUTCFullYear();
                                  $scope.newFuelPricing[i].fuelPricing.expirationDate = month+'/'+day+'/'+year;
                              }
                          }
                          if ($scope.newFuelPricing[i].futureFuelPricing != null) {
                              if ($scope.newFuelPricing[i].futureFuelPricing != null) {
                                  if ($scope.newFuelPricing[i].futureFuelPricing.nextExpiration != null && $scope.newFuelPricing[i].futureFuelPricing.nextExpiration != '') {
                                      var newTime = new Date($scope.newFuelPricing[i].futureFuelPricing.nextExpiration);
                                      var nextMonth = newTime.getUTCMonth() + 1; //months from 1-12
                                      var nextDay = newTime.getUTCDate();
                                      var nextYear = newTime.getUTCFullYear();
                                      $scope.newFuelPricing[i].futureFuelPricing.nextExpiration = nextMonth+'/'+nextDay+'/'+nextYear;
                                  }
                              }
                              if ($scope.newFuelPricing[i].futureFuelPricing != null) {
                                  if ($scope.newFuelPricing[i].futureFuelPricing.deployDate != null && $scope.newFuelPricing[i].futureFuelPricing.deployDate != '') {
                                      var newTime = new Date($scope.newFuelPricing[i].futureFuelPricing.deployDate);
                                      var dmonth = newTime.getUTCMonth() + 1; //months from 1-12
                                      var dday = newTime.getUTCDate();
                                      var dyear = newTime.getUTCFullYear();
                                      $scope.newFuelPricing[i].futureFuelPricing.deployDate = dmonth+'/'+dday+'/'+dyear;
                                  }
                              }
                          }
                        }
                        $scope.showLoader = false;
                  })
              })
              
          }
          
a49ef5361   Kuldeep Arora   dashboard & Sched...
172
173
174
175
176
177
178
179
180
181
          
          $scope.completeOrderCount = '';
          $scope.pendingOrderCount= '';
  
           dashboardService.getFuelordercount().then(function(result) {
               if(result[0].label=='Completed' && result[1].label=='Pending'){
                  $scope.completeOrderCount=result[0].value;
                  $scope.pendingOrderCount=result[1].value;
               }
                              
a49ef5361   Kuldeep Arora   dashboard & Sched...
182
          })
1b71872b2   Kuldeep Arora   email and code be...
183
184
185
186
187
188
189
190
191
192
           $scope.sendEmail = {};
          $scope.confirmMail = function(){
              if ($scope.sendEmail.pricing != '' && $scope.sendEmail.pricing != null && $scope.sendEmail.pricing != undefined) {
                  $('#confirm1').css('display', 'block');
  
              }
          }
          $scope.saveAndCloseConfirm = function(){
              $('#confirm1').css('display', 'none');
              updateFuelManagerService.sendMailToGroupMargin($scope.sendEmail.pricing).then(function(result) {
cefbd3ffa   Anchit Jindal   email related issues
193
194
195
196
197
198
199
200
201
202
                	$scope.sendEmail = {};
            		if(result.error) {
                  	toastr.error('' + result.error + '', {
                          closeButton: true
                      })
                  } else {
                  	toastr.success(''+result.success+'', {
                          closeButton: true
                    })
                  }
1b71872b2   Kuldeep Arora   email and code be...
203
204
205
206
207
208
209
              })
          }
          $scope.cancelAndCloseConfirm = function(){
              $scope.sendEmail = {};
              $scope.sendEmail.pricing = '';
              $('#confirm1').css('display', 'none');
          }
a49ef5361   Kuldeep Arora   dashboard & Sched...
210
211
212
          
          $scope.pendingMessageRecord=[];
           dashboardService.getPendingMessage().then(function(result) {
d1e8d9afb   Kuldeep Arora   fuel order & home...
213
           //   console.log("==message===",result)
a49ef5361   Kuldeep Arora   dashboard & Sched...
214
               $scope.pendingMessageRecord=result;
a49ef5361   Kuldeep Arora   dashboard & Sched...
215
           })
176381a3a   Anchit Jindal   minor changes
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
           
           
           $scope.orderCostAndCount = function() {
           	analyticsService.orderCostAndCount().then(function(result) {
           		$scope.ordersCost = result.cost;
                   $scope.ordersCount = result.count;
           	})
           }
  
           $scope.drf = {};
           $scope.hfp = {};
           $scope.cs = {};
           $scope.mfsValues = [];
           $scope.msfarray = [];
           $scope.getMFS = function() {
               //var makeId = makeId;
               analyticsService.getMFS().then(function(result) {
                   $scope.mfsValues = result;
                   $scope.optionsmfs = {
                       chart: {
                           type: 'multiBarChart',
                           height: 450,
fcb9c5ee6   Kuldeep Arora   monthly fuel char...
238
                           reduceXTicks: false,
176381a3a   Anchit Jindal   minor changes
239
240
241
242
243
244
245
246
247
248
                           margin: {
                               top: 45,
                               right: 20,
                               bottom: 45,
                               left: 45
                           },
                           clipEdge: true,
                           //staggerLabels: true,
                           duration: 500,
                           stacked: false,
d1e8d9afb   Kuldeep Arora   fuel order & home...
249
                           color: ["#A9A9A9", "#000099", "#990000", "#009900"],
176381a3a   Anchit Jindal   minor changes
250
251
252
253
254
255
256
257
                           xAxis: {
                               axisLabel: 'Months',
                               showMaxMin: false,
                           },
                           yAxis: {
                               axisLabel: 'Orders',
                               axisLabelDistance: -20,
                               tickFormat: function(d) {
7f6e3b1df   Kuldeep Arora   final code
258
                                   return d3.format(',')(d);
176381a3a   Anchit Jindal   minor changes
259
260
261
262
263
264
265
266
267
268
                               }
                           }
                       }
                   };
                   $scope.datamfs = $scope.mfsValues;
               })
           }
  
           $scope.orderCostAndCount();
           $scope.getMFS();
a49ef5361   Kuldeep Arora   dashboard & Sched...
269

feacde5ff   Rishav   setup acuefuel in...
270
271
      }
  })();