PageSourceSearch

https://www.cincyticket.com/admin/include/angular/controllers/BasketCtrl.js

js cincyticket.com collected 2026-10-03 21:38:32 UTC 7,719 bytes, 204 lines download raw bytes

1controllerModule.controller('BasketCtrl', function BasketCtrl($scope, $http, $window, _) {
2	/*global scope variables*/
3	$scope.errorMessages = [];
4	$scope.infoMessages = [];
5	$scope.pricingCodesPerPerformance = {};
6	$scope.ticketLineItemCheckboxes = {};
7	$scope.selectedPricingCode = {};
8	$scope.jsErrors = [];
9
10	
11	
12    $scope.getAvailablePricingCodesForPerformance = function(performanceID){
13        return $scope.pricingCodesPerPerformance[performanceID];
14    }
15	
16    $scope.pricingCodeDropdownChange = function(performanceID){}
17	
18    $scope.changePricing = function(){
19        var updateURL = "/BasketUpdate.asp?pricingcode=" + $scope.selectedPricingCode.PricingCode + "&activity=massChangePricing" 
20
21        var ticketIDs = "";
22        var checkedTickets = $scope.getCheckedTickets([]);
23        for(var i = 0; i < checkedTickets.length; i++){
24            ticketIDs += "&ticketID=" + checkedTickets[i]
25        }
26		
27        updateURL += ticketIDs;
28		
29        $http.get(updateURL).then(function(response){
30            var content = response.data;
31			$scope.$watch(
32				function(scope){
33					return angular.element(".jsErrors").first().val();
34				}, 
35				function(newVal, oldVal){
36					angular.element("#basket").submit();
37				}
38			);
39			$scope.jsErrors = _.uniq(content.errors);
40        });
41    }
42	
43    /*
44	initializes the booleans for each checkbox
45	*/
46    $scope.initLineItemCheckbox = function(performanceID, ticketID){
47        //ensure we have an array
48        $scope.ticketLineItemCheckboxes[performanceID] = $scope.ticketLineItemCheckboxes[performanceID] || {};
49		
50        //set initial value to false
51        $scope.ticketLineItemCheckboxes[performanceID][ticketID] = false
52    }
53	
54	
55    /*
56	This only affects tickets and does the initial checking of the boxes but for now a pure js function also runs to check these boxes over again and the other items.
57	*/
58    $scope.selectAllTickets = function(){
59        for(var performance in $scope.ticketLineItemCheckboxes){
60            for(var ticket in $scope.ticketLineItemCheckboxes[performance]){
61                if(typeof $scope.ticketLineItemCheckboxes[performance][ticket] !== "undefined"){
62                    $scope.ticketLineItemCheckboxes[performance][ticket] = true;
63                }
64            }
65        }
66    }
67	
68    $scope.deselectAllTickets = function(){
69        for(var performance in $scope.ticketLineItemCheckboxes){
70            for(var ticket in $scope.ticketLineItemCheckboxes[performance]){
71                if(typeof $scope.ticketLineItemCheckboxes[performance][ticket] !== "undefined"){
72                    $scope.ticketLineItemCheckboxes[performance][ticket] = false;
73                }
74            }
75        }
76    }
77
78    $scope.getPerformancesArray = function(performanceID, tickets){
79        var performances = [];
80        if(performanceID){
81            performances.push(performanceID);
82        }else{
83            for(var i = 0; i < tickets.length; i++){
84                for(var performance in $scope.ticketLineItemCheckboxes){
85                    for(var ticketID in $scope.ticketLineItemCheckboxes[performance]){
86                        if(tickets[i].TicketID == ticketID){
87                            performances.push(parseInt(performance));
88                        }
89                    }
90                }
91            }
92            performances = _.uniq(performances)
93        }
94        return performances;
95    }
96
97    $scope.refreshPricingCodeDropdown = function(sessionKey, performanceID){
98        $http
99		.get("/BasketUpdate.asp?activity=getSecureBasket", {"cache":"true"})
100		.then(
101			function(response){
102                var basketJSON = response.data;
103			    $scope.basket = angular.fromJson(basketJSON);
104				
105			    delete $scope.pricingCodesPerPerformance["undefined"];
106		
107			    var tickets = $scope.basket.items.tickets;
108				
109			    /*Get array of performances to act on*/
110			    var performances = $scope.getPerformancesArray(performanceID, tickets);
111
112			    //grab checked ticket ids
113			    var checkedTickets = $scope.getCheckedTickets(performances);				
114
115			    //grab tickets that are checked using the checked ticket ids
116			    tickets = _.filter(tickets, function(ticket){
117			        return _.contains(checkedTickets, ticket.TicketID);
118			    });
119				
120			    //organize pricing codes by performance
121			    $scope.pricingCodesPerPerformance[performanceID] = [];
122				
123			    for(var i = 0; i < tickets.length; i++){
124			        var ticket = tickets[i];
125			        if(ticket){
126			            $scope.pricingCodesPerPerformance[ticket.Performance] = $scope.pricingCodesPerPerformance[ticket.Performance] || [];
127						
128			            $scope.pricingCodesPerPerformance[ticket.Performance] = $scope.pricingCodesPerPerformance[ticket.Performance].concat(ticket.pricingCodes);
129			        }
130			    }
131
132
133			    //make sure pricing codes don't have duplicates
134			    for (var performancePricingCode in $scope.pricingCodesPerPerformance) {
135			        $scope.pricingCodesPerPerformance[performancePricingCode] = _.uniq(
136						$scope.pricingCodesPerPerformance[performancePricingCode], 
137						function(pricingCode){
138						    return pricingCode.PricingCode;
139						}
140					);
141			    }
142			}
143		);
144    }
145
146	
147    $scope.getCheckedTickets = function(performances){
148        var checkedTickets = [];
149		
150        if(performances.length > 0){
151            for(var i = 0; i < performances.length; i++){
152                var performance = performances[i];
153                if(performance){
154                    for(var ticketID in $scope.ticketLineItemCheckboxes[performance]){
155                        if($scope.ticketLineItemCheckboxes[performance][ticketID]){
156                            checkedTickets.push(parseInt(ticketID));
157                        }
158                    }
159                }
160            }
161        }else{
162            for(var performance in $scope.ticketLineItemCheckboxes){
163                for(var ticket in $scope.ticketLineItemCheckboxes[performance]){
164                    if(typeof $scope.ticketLineItemCheckboxes[performance][ticket] !== "undefined"){
165                        if($scope.ticketLineItemCheckboxes[performance][ticket]){
166                            checkedTickets.push(parseInt(ticket));
167                        }
168                    }
169                }
170            }
171        }
172		
173        return checkedTickets;
174    }
175
176    //show and hide controls for ticket changes, update messages accordingly.
177    $scope.canChangeTicketsPC = function (performance) {
178        $scope.hasMultiplePC = true;
179        $scope.isTicketsSelected = false;
180
181        if (performance) {
182            //see if tickets are checked for this performance only
183            for (var ticketID in $scope.ticketLineItemCheckboxes[performance]) {
184                if ($scope.ticketLineItemCheckboxes[performance][ticketID]) {
185                    //at least one ticket is checked, hide select message
186                    $scope.isTicketsSelected = true;
187                    //verify more than one option exists
188                    if ($scope.pricingCodesPerPerformance[performance].length > 1) {
189                        //show controls
190                        $scope.hasMultiplePC = true;
191                        return true;
192                    } else {
193                        //we have at least one ticket selected, but no options are available
194                        $scope.hasMultiplePC = false;
195                        return false;
196                    }
197                }
198            }
199        }
200    }
201	
202	$scope.refreshPricingCodeDropdown();
203
204});

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.