PageSourceSearch

https://topkinisis.com/js/controllers/charterflightscontrollers.js

js topkinisis.com collected 2026-10-02 11:38:13 UTC 18,613 bytes, 487 lines download raw bytes

1mainApp.controller("SearchCharterFlightCtrl", function ($scope, sessionUtil, specialOffersService, localize, carouselNavigatorServices,HotelService) {
2
3    sessionUtil.removeObjectInTempSession('charterFlightsSearchCriteries');
4	sessionUtil.removeObjectInTempSession('charterflightsSearchCrit');
5    sessionUtil.removeObjectInTempSession('charterFlightSearchResult');
6	sessionUtil.removeObjectInTempSession('flightsSearchCriterias');
7    sessionUtil.removeObjectInTempSession('myBasket');
8	
9	HotelService.getHotels(localize.language).then(function (data) {
10		$scope.HotelCities = data;
11	});
12	HotelService.getHotelNames(localize.language).then(function (data) {
13		$scope.HotelNames = data;
14	});
15	HotelService.getHotelCountries(localize.language).then(function (data) {
16		$scope.HotelCountries = data;
17	});
18	
19	//$scope.depcustomtexts = {checkAll: localize.getLocalizedString("cflight.dep.checkall"), uncheckAll: localize.getLocalizedString("cflight.dep.uncheckall"), buttonDefaultText: localize.getLocalizedString("cflight.dep.btndef"), dynamicButtonTextSuffix: localize.getLocalizedString("cflight.dep.btndyn")};
20    //$scope.arrcustomtexts = {checkAll: localize.getLocalizedString("cflight.arr.checkall"), uncheckAll: localize.getLocalizedString("cflight.arr.uncheckall"), buttonDefaultText: localize.getLocalizedString("cflight.arr.btndef"), dynamicButtonTextSuffix: localize.getLocalizedString("cflight.arr.btndyn")};
21
22	//localize.language="en";
23
24	if (localize.language !== '') {
25		var slidesObj = specialOffersService.getCharterFlightOffers(localize.language);
26		slidesObj.then(function (data) {
27			$scope.slides = data;
28		});
29	}
30
31	$scope.$watch(function () {
32		return localize.language;
33	}, function () {
34		if (localize.language !== '') {
35			slidesObj = specialOffersService.getCharterFlightOffers(localize.language);			
36			slidesObj.then(function (data) {
37				$scope.slides = data;
38			});
39		}
40	});
41	
42	$scope.onClikcOffer = function (linkOption) {
43		
44		carouselNavigatorServices.navicateToOffer(linkOption, $scope.searchPackageCriteria, $scope.airports, $scope.searchFlightFields, $scope.searchCharterFlightFields, $scope.HotelCities, $scope.HotelCountries, $scope.HotelNames);
45		
46	};
47		
48});
49
50mainApp.controller("SearchCharterPanelCtrl", function ($scope, $location, $timeout, airportService, sessionUtil, localize, specialOffersService) {
51	
52    $scope.initPassenger = function () {
53
54        $('html').click(function (e) {
55            e = e || window.event;
56            e = e.target || e.srcElement;
57            //console.log(e.nodeName);
58            //console.log(e.id);
59            if ($('#passangers').next('div.popover:visible').length) {
60                if (e.nodeName === 'INPUT' || e.nodeName === 'DIV' || e.nodeName === 'H1') {
61                    if (e.id === 'flightDates' || e.id.indexOf('cItem') === 0 || e.id.indexOf('cCaption') === 0 || e.id === 'searchTitleSP' || e.id === 'searchTitleH1') {
62                        $('.popoverLinkPassengers').popover('hide');
63                    }
64                }
65            }
66        });
67
68        $("#passangers").focus(function () {
69
70            $(".popoverLinkPassengers").popover({
71                html: true,
72                placement: 'bottom',
73                content: function () {
74                    return $('#popoverPassengers').html();
75                }
76            });
77
78        });
79
80    };
81
82    $scope.searchCharterFlightFields = {fromairport: [], toairport: [], fromdate: '', todate: '', numberOfAdults: '', numberOfChildren: '', numberOfInfants: ''};
83
84    $scope.disableSearch = true;
85    $scope.fetchingOption = true;
86    //get all the airports
87    airportService.getAirportForCharterFlight().then(function (data) {
88        $scope.fetchingOption = false;
89        if (data) {
90            $scope.disableSearch = false;
91            $scope.airports = data; 
92            /*for (var i = 0; i < data[0].length; i++) {
93                var obj = data[0][i];
94                //$scope.searchCharterFlightFields.fromairport.push({id: obj.ac});
95            }
96
97            for (var i = 0; i < data[1].length; i++) {
98                var obj = data[1][i];
99                //$scope.searchCharterFlightFields.toairport.push({id: obj.ac});
100            }*/            
101            $scope.originto = data[1];
102
103            $scope.fromValChg = data[0].length;            
104        }
105    });
106
107    $scope.customesettings = {idProp: 'ac'};
108	//localize.setLanguage("en");
109	//localize.setUrl(localize.buildUrl());
110	//localize.successCallback();
111	//var a=localize.initLocalizedResources();
112	
113	
114	//	localize.successCallback(localize.url);
115		
116	
117	//localize.successCallback(a);
118	
119	//var a = angular.module('tmApp.localization');
120	
121    $scope.depcustomtexts = {checkAll: localize.getLocalizedString("cflight.dep.checkall"), uncheckAll: localize.getLocalizedString("cflight.dep.uncheckall"), buttonDefaultText: localize.getLocalizedString("cflight.dep.btndef"), dynamicButtonTextSuffix: localize.getLocalizedString("cflight.dep.btndyn")};
122    $scope.arrcustomtexts = {checkAll: localize.getLocalizedString("cflight.arr.checkall"), uncheckAll: localize.getLocalizedString("cflight.arr.uncheckall"), buttonDefaultText: localize.getLocalizedString("cflight.arr.btndef"), dynamicButtonTextSuffix: localize.getLocalizedString("cflight.arr.btndyn")};
123
124    $scope.depText = localize.getLocalizedString("cflight.depText");
125
126    $scope.$watch('fromValChg', function (newValue, oldValue) {
127        if (!newValue) {
128            return;
129        }
130
131        if (newValue === 0) {
132            $scope.airports[1] = [];
133            $scope.searchCharterFlightFields.toairport = [];
134        }
135        if (newValue && (oldValue || oldValue === 0)) {
136            if (parseInt(newValue) !== parseInt(oldValue)) {
137                if (newValue !== '') {
138                    var validate = [];
139                    var obj = [];
140                    for (var i = 0; i < $scope.searchCharterFlightFields.fromairport.length; i++) {
141                        for (var j = 0; j < $scope.airports[2].length; j++) {
142                            if ($scope.searchCharterFlightFields.fromairport[i].id === $scope.airports[2][j].airportCodeCon) {
143                                if ($.inArray($scope.airports[2][j].ac, validate) === -1) {
144                                    obj.push($scope.airports[2][j]);
145                                    validate.push($scope.airports[2][j].ac);
146                                }
147                            }
148                        }
149                    }
150
151                    $scope.airports[1] = obj;
152
153                    /*var ci = []; //auto select toairport (old busines)
154                    for (var i = 0; i < obj.length; i++) {
155                        ci.push({id: obj[i].ac});
156                    }
157                    $scope.searchCharterFlightFields.toairport = ci;*/
158
159                }
160            }
161        }
162    });
163	
164	var search = sessionUtil.getObjectInTempSession("charterflightsSearchCrit");
165	if (search) {
166		$timeout(function () {	
167			
168			$scope.searchCharterFlightFields.fromairport = search.fromairport;
169			$scope.searchCharterFlightFields.toairport = search.toairport;
170			
171			var totaladu = search.flightPassengers.numberOfAdults;
172			$("#totalAdult").val(parseInt(totaladu));
173			$("#adultsNumberHTML").html(parseInt(totaladu));
174			$(".passengersCell #adultsNumberHTML").html(parseInt(totaladu));
175
176			var totalchi = search.flightPassengers.numberOfChildren;
177			$("#totalChildren").val(parseInt(totalchi));
178			$("#childNumberHTML").html(parseInt(totalchi));
179			$(".passengersCell #childNumberHTML").html(parseInt(totalchi));
180			
181			var totalinf = search.flightPassengers.numberOfInfants;
182			$("#totalInfant").val(parseInt(totalinf));
183			$("#infantNumberHTML").html(parseInt(totalinf));
184			$(".passengersCell #infantNumberHTML").html(parseInt(totalinf));
185			
186			var total = parseInt(totaladu) + parseInt(totalchi) +  parseInt(totalinf);
187			$("#passangers").val(total + " Passengers");
188		}, 1000);
189	}
190
191    $scope.searchCharterFlight = function () {
192        var subForm = true;
193
194        $scope.errFromAirportRequired = false;
195        if ($scope.searchCharterFlightFields.fromairport.length === 0) {
196            subForm = false;
197            $scope.errFromAirportRequired = true;
198        } else {
199            $scope.searchCharterFlightFields.fromairportcodearray = [];
200            for (var i = 0; i < $scope.searchCharterFlightFields.fromairport.length; i++) {
201                $scope.searchCharterFlightFields.fromairportcodearray.push($scope.searchCharterFlightFields.fromairport[i].id);
202            }
203        }
204
205        $scope.errToAirportRequired = false;
206        if ($scope.searchCharterFlightFields.toairport.length === 0) {
207            subForm = false;
208            $scope.errToAirportRequired = true;
209        } else {
210            $scope.searchCharterFlightFields.toairportcodearray = [];
211            for (var i = 0; i < $scope.searchCharterFlightFields.toairport.length; i++) {
212                $scope.searchCharterFlightFields.toairportcodearray.push($scope.searchCharterFlightFields.toairport[i].id);
213            }
214        }
215
216        var totPass = $("#passengerNumber").val();
217        $scope.errRequiredPassenger = false;
218        if (!totPass) {
219            subForm = false;
220            $scope.errRequiredPassenger = true;
221        } else {
222            if (parseInt(totPass) === 0) {
223                subForm = false;
224                $scope.errRequiredPassenger = true;
225            } else {
226                $scope.searchCharterFlightFields.flightPassengers = {};
227                $scope.searchCharterFlightFields.flightPassengers.numberOfAdults = parseInt($("#totalAdult").val());
228                $scope.searchCharterFlightFields.flightPassengers.numberOfChildren = parseInt($("#totalChildren").val());
229                $scope.searchCharterFlightFields.flightPassengers.numberOfInfants = parseInt($("#totalInfant").val());
230            }
231        }
232
233        if (subForm) {
234            //console.log(JSON.stringify($scope.searchCharterFlightFields));
235            sessionUtil.setObjectInTempSession("charterflightsSearchCrit", $scope.searchCharterFlightFields);
236            if ('/charterflightsresult' === $location.path()) {
237                $location.path("/charterflightsredirectresult");
238            } else {
239                $location.path("/charterflightsresult");
240            }
241        } else {
242            $scope.submitted = true;
243        }
244
245    };
246
247});
248
249mainApp.controller("SearchCharterResultCtrl", function ($scope, $location, $filter, airportService, sessionUtil, charterFlightServices, myBasketService, flightService, localize) {
250
251    $scope.filterReturn = true;
252    $scope.filterOneWay = true;
253    $scope.fetchingData = true;
254    $scope.showNoData = false;
255    var search = sessionUtil.getObjectInTempSession("charterflightsSearchCrit");
256    $scope.userSearch = search;
257    $scope.fetchFareData = false;
258
259    var avaSeats = flightService.getAvaliableSeatsHouseKeeping();
260    avaSeats.then(function (data) {
261        $scope.avaSeatsMaxMin = data;
262    });
263
264    $scope.initResultObj = function () {
265        $(".popoverLinkLuggage").popover({
266            html: true,
267            placement: 'top',
268            trigger: 'hover',
269            content: function () {
270                return $('#popoverLuggageAllowed').html();
271            }
272        });
273
274        $(".popoverLinkNoLuggage").popover({
275            html: true,
276            placement: 'top',
277            trigger: 'hover',
278            content: function () {
279                return $('#popoverLuggageNotAllowed').html();
280            }
281        });
282
283        /*Opens the specific popover for each search result item*/
284        $(".popoverTotalAmount").popover({
285            html: true,
286            placement: 'top',
287            trigger: 'hover',
288            content: function () {
289                var thisID = $(this).attr('id');
290                return $('#' + thisID + 'Content').html();
291            }
292        });
293    };
294
295    airportService.getAirportForCharterFlight().then(function (data) {
296        var list = [];
297        var dlist = [];
298        var alist = [];
299        for (var i = 0; i < data[0].length; i++) {
300            if ($.inArray(data[0][i].ac, search.fromairportcodearray) > -1) {
301                dlist.push({code: data[0][i].ac, city: data[0][i].ci, on: false});
302            }
303        }
304        list.push(dlist);
305        for (var i = 0; i < data[1].length; i++) {
306            if ($.inArray(data[1][i].ac, search.toairportcodearray) > -1) {
307                alist.push({code: data[1][i].ac, city: data[1][i].ci, on: false});
308            }
309        }
310        list.push(alist);
311        $scope.cityList = list;
312    });
313	search.product="cflight";
314
315    var searchResult = charterFlightServices.searchForFlight(search);
316    searchResult.then(function (data) {
317        $scope.datesArray = [];
318        $scope.filterCharterFlightDate = "";
319        $scope.fetchingData = false;
320        
321        $scope.result = $filter("orderBy")(data, ['sdepdate', 'sdepdlo', 'sdepalo']);
322        $scope.orignflights = data;
323        $scope.recordCount = $scope.result.length;
324        if ($scope.result.length === 0) {
325            $scope.showNoData = true;
326        }
327        $scope.scroll = 0;
328        $scope.numPerPage = 5;
329        $scope.currentPage = 1;
330
331        for (var i = 0; i < $scope.result.length; i++) {
332            if ($.inArray($scope.filterFlightDateWithPatt($scope.result[i].dfs[0].dda, 'd/M/yyyy'), $scope.datesArray) === -1) {
333                $scope.datesArray.push($scope.filterFlightDateWithPatt($scope.result[i].dfs[0].dda, 'd/M/yyyy'));
334            }
335        }
336    });
337
338    $scope.clearAll = function () {
339        $scope.filterReturn = true;
340        $scope.filterOneWay = true;
341        $scope.clearDepCity();
342        $scope.clearArrCity();
343        $scope.clearFilterDate();
344    };
345
346    $scope.clearDepCity = function () {
347        for (var i = 0; i < $scope.cityList[0].length; i++) {
348            $scope.cityList[0][i].on = false;
349        }
350    };
351
352    $scope.clearArrCity = function () {
353        for (var i = 0; i < $scope.cityList[1].length; i++) {
354            $scope.cityList[1][i].on = false;
355        }
356    };
357
358    $scope.clearFilterDate = function () {
359        $scope.filterCharterFlightDate = "";
360    };
361
362    $scope.showCFAvaliableSeats = function (numSeatsOneWay, departureSeatsRoundTrip, arrivalSeatsRoundTrip, flightStatus, isDeparture) {
363        if ($scope.avaSeatsMaxMin) {
364            var max = $scope.avaSeatsMaxMin.maxAvaSeatCF;
365            var min = $scope.avaSeatsMaxMin.minAvaSeatCF;
366            //console.log(numSeats +" , "+ flightStatus)
367			var seats = 0;
368            if(isDeparture === "true"){
369				if (numSeatsOneWay !== null){
370					seats = numSeatsOneWay;
371				} else {
372					seats = parseInt(departureSeatsRoundTrip);
373				}
374			} else {
375				seats = parseInt(arrivalSeatsRoundTrip);
376			}
377			if(seats > 0) {
378				if (flightStatus === 'OnRequest' ) {
379					return localize.getLocalizedString("cv.on.request");
380				} else {
381					if (seats >= max) {                        
382						return localize.getLocalizedString("cv.on.available");
383					} else if (seats > min && seats < max) {
384						return localize.getLocalizedString("cv.only")+" " + seats + " "+localize.getLocalizedString("cv.seats");
385					}
386				}
387			} else {
388				return localize.getLocalizedString("cv.on.request");
389			}
390        }
391    };
392
393    $scope.$watch('scroll', function (newValue, oldValue) {
394        if (newValue !== oldValue) {
395            if (newValue > 0) {
396                $scope.loadMore();
397            }
398        }
399    });
400
401    $scope.$watch('filterCharterFlightDate', function (newValue, oldValue) {
402        if (newValue !== oldValue) {
403            //$scope.selectData(1);
404        }
405    });
406
407    $scope.loadMore = function () {
408        $scope.scroll = 0;
409        $scope.currentPage = $scope.currentPage + 1;
410    };
411
412    $scope.selectData = function (page) {
413        if (!$scope.result) {
414            return;
415        }
416        var start = 0; //(page - 1) * $scope.numPerPage;
417        var end = page * $scope.numPerPage;
418        var arr = $scope.result;
419        if ($scope.result.length < $scope.orignflights.length) {
420            $scope.result = $scope.orignflights;
421            $scope.result = $filter("orderBy")($scope.result, ['sdepdate', 'sdepdlo', 'sdepalo']);
422            arr = $scope.result;
423        }
424        var filtered = [];
425        filtered = $filter("filterFlightOptions")(arr, $scope);
426        filtered = $filter("filterCharterFlightCities")(filtered, $scope);
427        filtered = $filter("filterCharterFlightDate")(filtered, $scope);
428        $scope.result = filtered.slice(start, end);
429        $scope.result = $filter('orderBy')($scope.result, ['sdepdate', 'sdepdlo', 'sdepalo']);//$filter("orderBy")($scope.result, 'pri', false);
430        $scope.currentPage = page;		
431        //$scope.recordCount = $scope.result.length;
432		
433		$scope.recordCount = filtered.length;
434		
435    };
436
437    $scope.clickBook = function (flightRec) {
438        //console.log("let book");        
439        var myBasket = myBasketService.getNewBasket();
440        myBasketService.setFlights(myBasket, flightRec);
441        myBasketService.setPasengers(myBasket, $scope.userSearch.flightPassengers);
442        //var isUserLoggedIn = sessionUtil.getObjectInSession("loggedInUser");
443        var isUserLoggedIn = sessionUtil.getObjectInSession("userInfo");
444        myBasket.isLogIn = false;
445        if (isUserLoggedIn) {
446            myBasket.isLogIn = true;
447            myBasketService.setContactDetails(myBasket, isUserLoggedIn);
448        } else {
449            //  myBasket.cInf = {};
450        }
451        myBasket.retrunToCharter = true;
452        //console.log("myBasket: "+JSON.stringify(myBasket));
453        sessionUtil.setObjectInTempSession("myBasket", myBasket);
454
455        $location.path("/flightspassenger");
456    };
457
458    $scope.displayFareRulesCF = function (flightDet) {
459
460        if ($scope.fetchFareData) {
461            $scope.closeFareRule();
462        }
463
464        var id = flightDet.cfid;
465        var type = false;
466        if (flightDet.rfs && flightDet.rfs.length > 0) {
467            type = true;
468        }
469        var fareRuleOgj = charterFlightServices.getFareRueForCharterFlight(id, type);
470        fareRuleOgj.then(function (data) {
471            var fareRuleSre = "";
472            for (var i = 0; i < data.length; i++) {
473                fareRuleSre = fareRuleSre + data[i] + "\n";
474            }
475            $('#fareRulesContent').text(fareRuleSre);
476            $scope.fetchFareData = true;
477        });
478    };
479
480    $scope.closeFareRule = function () {
481        $scope.fetchFareData = false;
482        $('#fareRulesContent').text('');
483    };
484
485});
486
487

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.