define(['quote/quote'], function (quote) { quote.controller('Bundles', ['$rootScope', '$scope', '$http', '$q', '$timeout', 'VehicleHelpers', 'Idle', '$mdDialog', function ($rootScope, $scope, $http, $q, $timeout, VehicleHelpers, Idle, $mdDialog) { eval(document.getElementById("mvdInit").innerHTML); $scope.mvdActive = _mvdActive; $scope.BuildYourDiscountPackage = $scope.Quote.DiscountDetails; $scope.BuildYourDiscountPackageTotal = $scope.Quote.DiscountTotal; if ($rootScope.IsBroker) { $scope.HeaderText = 'Client insurance package'; } else { $scope.HeaderText = 'Your insurance package'; } //Set the header dependent upon the status of Bundles Loaded $scope.$watch('Bundles.Loading', function (val) { if (val == true) { $scope.SetStepLoading(); $scope.SetStepHeader('We\'re busy constructing your Auto & General cover.', 'In a moment you\'ll be able to choose the cover option that best suits your needs.'); } else if (val == false) { if ($scope.Quote.Type == 'Amendment') { $scope.SetStepHeader($scope.HeaderText, ''); } else { $scope.SetStepHeader($scope.HeaderText, 'Here is a comprehensive bundle based on the personal information you have provided. You can choose this option, or build your own insurance package below to suit your needs.'); } $scope.SetStepLoaded(); $timeout(function () { //starts idle timer for chat pop up only after page loads Idle.watch(); }, 1); } }); $scope.Tooltips = { VMIV: "This value represents the amount that you'll be paid if your car's damaged beyond repair or stolen and not recovered. It'll either be the amount you specified or the market value at the time of the claim - whichever is lower. Bettercar insurance will replace your vehicle with the same model, which is one year newer or with 20,000 kms less on the clock than the written off vehicle *T&Cs apply", VMAD: "The Accident Damage Cover option will provide you with cover in the event of damages caused as a result of an accident. The damages will be covered up to the amount chosen by you. Where the cost of the repair exceeds the chosen insured amount, you will be liable for the difference. This type of cover automatically forms part of comprehensive insurance, but is optional if you choose not to insure your vehicle comprehensively. By choosing to include Accident Damage Cover you will also be afforded the following assist benefits: Accident Assist and Loan Assist.", VMFF: "Cover for the accessories of your 4x4. Cover of R10,000 is automatically included when you choose to insure your vehicle with Off-road Vehicle Cover, but you're welcome to increase the amount of cover for a small premium.", VMEX: "The excess amount is the first amount that you pay when you claim before the insurance company pays out.", VMTE: "If you choose to include Theft Excess Buster you will not have to pay the additional theft excess if your vehicle is stolen. The product is only available if your chosen cover type includes theft cover and can only be included if your vehicle does not have a tracking device.", VMCH: "On valid claims, we'll pay for a hired car, up to the maximum stated on your schedule while the vehicle is being repaired &/or if the vehicle is stolen. Executive Package: Car hire available for a vehicle with a 1600cc engine and aircon for the maximum days. Standard Package: Car hire available for a vehicle with a 1300cc engine and no aircon for the maximum days.", VMSA: "SASRIA stands for the South African Special Risks Insurance Association and it covers your vehicle against accidental or deliberate damage that's caused by someone taking part in a riot, strike, lock-out or civil commotion. It includes damage caused by people with a political social or economic agenda with the intention to protest influence or overthrow any sphere of government or to induce public fear. Lastly it is limited to things happening in South Africa.", VMPL: "The Third party Liability Cover option covers you in the event that the regular driver is legally liable for an accident that caused damage to another party's property, then the other party will be indemnified for damages, costs and expenses. This type of cover is automatically included if your vehicle is comprehensively insured and is optional if your vehicle is not insured comprehensively. By choosing to include Third Party Liability Cover in this instance you will also be afforded the following assist benefits: Accident Assist and Loan Assist.", VMAS: "The Accident Damage Cover option will provide you with cover in the event of damages caused as a result of an accident. The damages will be covered up to the amount chosen by you. Where the cost of the repair exceeds the chosen insured amount, you will be liable for the difference. This type of cover automatically forms part of comprehensive insurance, but is optional if you choose not to insure your vehicle comprehensively. By choosing to include Accident Damage Cover you will also be afforded the following assist benefits: Accident Assist and Loan Assist.", BMIV: "The insured value is the total amount we will pay out for your motorcycle if it is damaged beyond repair or stolen and not recovered. This will either be the amount stated here or the market value at the time of the claim - whichever is lower.", BMEX: "The excess amount is the first amount that you pay when you claim before the insurance company pays out.", BMSA: "SASRIA stands for the South African Special Risks Insurance Association and it covers your vehicle against accidental or deliberate damage that's caused by someone taking part in a riot, strike, lock-out or civil commotion. It includes damage caused by people with a political social or economic agenda with the intention to protest influence or overthrow any sphere of government or to induce public fear. Lastly it is limited to things happening in South Africa.", BMAS: "The assistance suite includes: Medical assist, home assist, trauma assist, legal assist and entertainment assist.", HHIV: "The insured value is the maximum amount we will pay out for damaged items at your home or items stolen from your home.", HHPL: "Personal Liability indemnifies you if a member of your household or someone who works for you is injured or passes away accidentally at the insured address or suffers damage to his/her property at the insured address.", HHEX: "The excess amount is the first amount that you pay when you claim before the insurance company pays out.", HHSA: "SASRIA stands for the South African Special Risks Insurance Association and it covers your vehicle against accidental or deliberate damage that's caused by someone taking part in a riot, strike, lock-out or civil commotion. It includes damage caused by people with a political social or economic agenda with the intention to protest influence or overthrow any sphere of government or to induce public fear. Lastly it is limited to things happening in South Africa.", HHAS: "The Assistance Suite includes: Home Assist", SPIV: "This value represents the total amount we will pay out for your borehole and swimming pool equipment if it is damaged beyond repair or stolen and not recovered.", SPEX: "The excess amount is the first amount that you pay when you claim before the insurance company pays out.", HOIV: "The insured value is the maximum amount we will pay out for damage to the physical structures of your home and it's outbuildings.", HOPL: "Personal Liability indemnifies you if a member of your household or someone who works for you is injured or passes away accidentally at the insured address or suffers damage to his/her property at the insured address.", HOEX: "The excess amount is the first amount that you pay when you claim before the insurance company pays out.", HOSA: "SASRIA stands for the South African Special Risks Insurance Association and it covers your vehicle against accidental or deliberate damage that's caused by someone taking part in a riot, strike, lock-out or civil commotion. It includes damage caused by people with a political social or economic agenda with the intention to protest influence or overthrow any sphere of government or to induce public fear. Lastly it is limited to things happening in South Africa.", HOAS: "The Assistance Suite includes: Home Assist", AUIV: "This value represents the total amount we will pay out for your unspecified portable possessions if they are damaged beyond repair or stolen and not recovered.", AUEX: "The excess amount is the first amount that you pay when you claim before the insurance company pays out.", AJIV: "This value represents the total amount we will pay out for this specified portable possession if it is damaged beyond repair or stolen and not recovered.", AJEX: "The excess amount is the first amount that you pay when you claim before the insurance company pays out.", CPIV: "This value represents the total amount we will pay out for this cellphone if it is damaged beyond repair or stolen and not recovered.", CPEX: "The excess amount is the first amount that you pay when you claim before the insurance company pays out.", PCIV: "This value represents the total amount we will pay out for this bicycle if it is damaged beyond repair or stolen and not recovered.", PCEX: "The excess amount is the first amount that you pay when you claim before the insurance company pays out.", CLIV: "This value represents the total amount we will pay out for this pair of prescription glasses or contact lenses if they are damaged beyond repair or stolen and not recovered.", CLEX: "The excess amount is the first amount that you pay when you claim before the insurance company pays out.", }; $scope.mvd = { VMCO: "When you add 2 or more comprehensively insured vehicles to your policy you automatically qualify for our Mulit-Vehicle Discount on each comprehensively insured vehicle." } if (typeof _ShowChat != "undefined" && _ShowChat == false) $scope.chatpopupOnce = 1; else $scope.chatpopupOnce = 0; $scope.$on('IdleStart', function () { $rootScope.$apply(function () { if ($scope.chatpopupOnce < 1) { $rootScope.toggleSmallChatForm(); $scope.chatpopupOnce++; } }); }); $scope.Bundles = { Loading: true, LoadingBuildYourOwn: false }; //when the currently selected Vehicle changes $scope.changeIndex = function (vehicle) { var index = VehicleHelpers.getVehicleIndex(vehicle); $scope.index = index; $scope.listIndex = VehicleHelpers.getLastVehicleIndexByType($scope.Quote.Vehicles[$scope.index], 'IsCar'); $scope.GetAmendBundleData(); }; //when a Vehicle is added $scope.addItem = function addItem() { $scope.changeIndex($scope.Quote.Vehicles.length - 1); }; $scope.init = function () { VehicleHelpers.setupState($scope, 'IsCar'); } $scope.setAccesoriesDefault = function () { if ($scope.Quote.Vehicles[$scope.index].FFAccessories == null) $scope.Quote.Vehicles[$scope.index].FFAccessories = { Editable: $scope.Quote.Vehicles[$scope.index].AmendBundle.Editable }; //if ($scope.Quote.Vehicles[$scope.index].FFAccessories != null && $scope.Quote.Vehicles[$scope.index].FFAccessories.Editable == null) // $scope.Quote.Vehicles[$scope.index].FFAccessories.Editable = $scope.Quote.Vehicles[$scope.index].AmendBundle.Editable || "N"; if ($scope.Quote.Vehicles[$scope.index].AmendBundle != null && $scope.Quote.Vehicles[$scope.index].AmendBundle.CoverType == "4X") $scope.Quote.Vehicles[$scope.index].FFAccessories.Editable = "Y"; if ($scope.Quote.Vehicles[$scope.index].AmendBundle != null && $scope.Quote.Vehicles[$scope.index].AmendBundle.CoverType != "4X" && $scope.Quote.Vehicles[$scope.index].FFAccessories.Editable == "Y") { $scope.Quote.Vehicles[$scope.index].FFAccessories.Value = "*N"; $scope.Quote.Vehicles[$scope.index].AccessoriesValue = 0; } if ($scope.Quote.Vehicles[$scope.index].AmendBundle != null && $scope.Quote.Vehicles[$scope.index].AmendBundle.CoverType == "4X") { $scope.Quote.Vehicles[$scope.index].FFAccessories.Value = "10000"; $scope.Quote.Vehicles[$scope.index].AccessoriesValue = 10000; $scope.Quote.Vehicles[$scope.index].MarketRetail = "R"; $scope.Quote.Vehicles[$scope.index].WindscreenCover = "Y"; //$scope.Quote.Vehicles[$scope.index].FFAccessories.DropDownList = $filter('filter')($scope.Quote.Vehicles[$scope.index].FFAccessories.DropDownList, "!*N", $scope.comp); $scope.Quote.Vehicles[$scope.index].MarketRetail = "R"; } if ($scope.Quote.Vehicles[$scope.index].AmendBundle != null && $scope.Quote.Vehicles[$scope.index].AmendBundle.CoverType == "CO") $scope.Quote.Vehicles[$scope.index].WindscreenCover = "Y"; if ($scope.Quote.Vehicles[$scope.index].AmendBundle != null && $scope.Quote.Vehicles[$scope.index].AmendBundle.CoverTypeValue == "TO") $scope.Quote.Vehicles[$scope.index].WindscreenCover = "N"; if ($scope.Quote.Vehicles[$scope.index].VehicleFinanced == 'Y') $scope.Quote.Vehicles[$scope.index].HailCover = "Y"; if ($scope.Quote.Vehicles[$scope.index].RoadsideAssistance == 'Y' && $scope.Quote.Vehicles[$scope.index].RoadsideAssistance2 == 'Y') $scope.Quote.Vehicles[$scope.index].BuyAssist = "Y"; else $scope.Quote.Vehicles[$scope.index].BuyAssist = "N"; } $scope.BrokerCarHire = false; $scope.GetAmendBundleData = function () { $http({ method: 'POST', url: "/Quote/Bundles/GetAmendBundleData", params: { vehicleSequenceNumber: $scope.Quote.Vehicles[$scope.index].VehicleSequenceNumber, referenceNumber: $scope.Quote.ReferenceNumber, currentCoverType: $scope.Quote.Vehicles[$scope.index].AmendBundle && $scope.Quote.Vehicles[$scope.index].AmendBundle.CoverType || $scope.Quote.Vehicles[$scope.index].CoverType } }).success(function (data) { $scope.AmendBundle = data; $scope.BrokerCarHire = data.BrokerCarHire; $scope.setAccesoriesDefault(); $scope.AmendBundle.FourByFourAccessoryOptionsDisplay = ($scope.AmendBundle.FourByFourAccessoryOptions.filter(function (option) { return (option.Code != '*N'); })); $scope.NavigationInProgress = false;//re-enable button }); }; $scope.displayCoverType = function (CoverType) { //This function converts the CoverType Code to sucessfully match/display the correct CoverType if (CoverType == "A" || CoverType == "G") return "CO"; else if (CoverType == "B") return "TF"; else if (CoverType == "C") return "TO"; else if (CoverType == "D") return "4X"; }; $scope.InitAmendmentBundles = function () { $scope.Bundles.Loading = false; $scope.init(); $scope.GetAmendBundleData(); // set defaults $scope.Quote.Vehicles[$scope.index].AmendBundle = { BasicExcess: !$scope.Quote.Vehicles[$scope.index].AdditionalExcessCode ? "0" : $scope.Quote.Vehicles[$scope.index].AdditionalExcessCode, CoverType: $scope.displayCoverType($scope.Quote.Vehicles[$scope.index].CoverType), } }; $scope.GetRecommendedBundle = function () { return $http({ method: 'POST', url: '/Quote/Bundles/getRecommendedBundle', params: { ReferenceNumber: $scope.Quote.ReferenceNumber } }).then( function (data, status, headers, config) { $scope.RecommendedPackage = data.data; $scope.PackageHeadingList = data.data.PackageRowHeadingList; } ); }; $scope.GetRecommendedBundleHeading = function () { return $http({ method: 'POST', url: '/Quote/Bundles/getRecommendedBundleHeadings', params: { ReferenceNumber: $scope.Quote.ReferenceNumber } }).then( function (data, status, headers, config) { $scope.RecommendedPackage_Headings = data.data; } ); }; $scope.GetBuildYourOwnBundle = function () { return $http({ method: 'POST', url: '/Quote/Bundles/getBuildYourOwnBundle', params: { ReferenceNumber: $scope.Quote.ReferenceNumber }, data: $scope.Quote.Vehicles }).then( function (data, status, headers, config) { $scope.BuildYourOwnPackage = data.data; $scope.BuildYourOwnPackageHeadingList = data.data.PackageRowHeadingList; } ); }; $scope.GetBuildYourOwnBundleHeading = function () { return $http({ method: 'POST', url: '/Quote/Bundles/getBuildYourOwnBundleHeadings', params: { ReferenceNumber: $scope.Quote.ReferenceNumber } }).then( function (data, status, headers, config) { $scope.BuildYourOwnPackage_Headings = data.data; } ); }; $scope.GetPayoutDetail = function () { return $http({ method: 'POST', url: '/Quote/Bundles/GetPayoutDetail', params: { ReferenceNumber: $scope.Quote.ReferenceNumber } }).then( function (data, status, headers, config) { $scope.PayoutDetail = data.data; } ); }; $scope.GetBundleData = function () { $q.all([$scope.GetRecommendedBundleHeading(), $scope.GetRecommendedBundle(), $scope.GetBuildYourOwnBundleHeading()]). then(function () { $scope.GetBuildYourOwnBundle(). //getting headings last seems to clear the selected covertype on tape so wait for it then get bundle then(function () { // assuming we have to load bundles before getting cashback $scope.GetPayoutDetail().then(function () { if (($scope.RecommendedPackage.TotalPremium <= 30 || $scope.BuildYourOwnPackage.TotalPremium <= 30) && $scope.Quote.Type == "Lead") window.location = "/quote/" + $scope.Quote.ReferenceNumberDisplay + "#/refertomanager"; else $scope.Bundles.Loading = false; }); }); }); }; $scope.InitBundles = function () { $scope.Bundles.Loading = true; $scope.GetBundleData(); }; $scope.AmendCashback = function (packageItem, item, cashbackVal, bundleCode) { if (cashbackVal.indexOf('Y') > 0) { $scope.Quote.Personal.CashBack = true; } else { $scope.Quote.Personal.CashBack = false; } $scope.AmendBundle(packageItem, item, bundleCode); } $scope.AmendBundle = function (packageItem, item, bundleCode) { if (!bundleCode) bundleCode = "BB"; // default to BB if (bundleCode == "BB") { $scope.Bundles.LoadingBuildYourOwn = true; } else { $scope.Bundles.Loading = true; } //MVD covertype change popup hasDiscount var vehilceDiscount = $scope.BuildYourOwnPackage.PackageList || null ? $scope.BuildYourOwnPackage.PackageList.filter(function (v) { return (v.PackageIndex == packageItem.RiskNumber); }) : null; if (vehilceDiscount != null && $scope.Quote.DiscountAmounts != null) { if (!$scope.mvdNotified && item.Values[0].Value != 'CO' && vehilceDiscount.length > 0 && $scope.Quote.DiscountAmounts.length != 0 && vehilceDiscount[0].RISKQUALIFIESFORDISCOUNT) { $mdDialog.show( $mdDialog.alert().clickOutsideToClose(true).disableParentScroll(false) .title('Multi Vehicle Discount') .content("Should your cover type change, it may affect the comprehensive vehicle cover discount you qualified for, which works as follows: " + $scope.Quote.DiscountAmounts[0].NumberOfVehicles + " car = no discount, " + $scope.Quote.DiscountAmounts[1].NumberOfVehicles + " cars = up to " + $scope.Quote.DiscountAmounts[1].DiscountPercentage + "%, " + $scope.Quote.DiscountAmounts[2].NumberOfVehicles + " cars = up to " + $scope.Quote.DiscountAmounts[2].DiscountPercentage + "%, " + $scope.Quote.DiscountAmounts[3].NumberOfVehicles + " cars = up to " + $scope.Quote.DiscountAmounts[3].DiscountPercentage + "% each.") .ok('OK!') ); $scope.mvdNotified = true; } } var amendParameters = { AmendValues: { Text: [], Value: [item.Values[0].Value] }, BundleIndex: packageItem.BundleIndex, BundleType: bundleCode, ComponentCode: item.ItemCode, ReferenceNumber: $scope.Quote.ReferenceNumber, RiskNumber: packageItem.RiskNumber, RiskType: packageItem.RiskType } $http({ method: 'POST', url: "/Quote/Bundles/GetAmendBundle", data: { anAmendRequest: amendParameters } }).success(function (data) { if (bundleCode === "BB") { $scope.BuildYourOwnPackage = data; $scope.Bundles.LoadingBuildYourOwn = false; } else { $scope.RecommendedPackage = data; $scope.Bundles.Loading = false; } }); }; $scope.SubmitAmendBundle = function () { $scope.BundlesSubmit(); }; $scope.SetUpBrokerCarHire = function (packageDetails) { var vehiclePackages = new Array(); packageDetails.PackageList.forEach(function (Package) { if (Package.RiskType === "VM") { vehiclePackages.push(Package); } }); $scope.Quote.Vehicles.forEach(function (vehicle) { vehiclePackages.forEach(function (vehiclePackage) { if (vehicle.VehicleSequenceNumber === vehiclePackage.RiskNumber) { var items = vehiclePackage.ItemList; items.forEach(function (item) { if (item.ItemCode === "VMCH") { vehicle.CarHireWhichCar = item.Values[0].Value; } if (item.ItemCode === "LVCHRYN") { vehicle.CarHireYN = item.Values[0].Value; } }); } }); }); } $scope.SubmitBuildYourOwn = function () { if (typeof ($scope.Quote.IsBroker) !== "undefined" && $scope.Quote.IsBroker !== null && $scope.Quote.IsBroker && $scope.Quote.Type !== "Amendment") { $scope.SetUpBrokerCarHire($scope.BuildYourOwnPackage); } $scope.Quote.Bundles.BundleIndex = 1; $scope.Quote.Bundles.BundleType = "BB"; $scope.BundlesSubmit(); }; $scope.SubmitComprehensive = function () { if (typeof ($scope.Quote.IsBroker) !== "undefined" && $scope.Quote.IsBroker !== null && $scope.Quote.IsBroker && $scope.Quote.Type !== "Amendment") { $scope.SetUpBrokerCarHire($scope.RecommendedPackage); } $scope.Quote.Bundles.BundleIndex = 2; $scope.Quote.Bundles.BundleType = "SB"; $scope.BundlesSubmit(); }; $scope.SubmitCorrectBundle = function (type) { if (type == "Amendment") { $scope.SubmitAmendBundle(); } } if ($scope.Quote.Type == 'Amendment') { $scope.InitAmendmentBundles(); // amend bundle watches $scope.$watch('Quote.Vehicles[index].MarketRetail', function (val) { if (val && $scope.AmendBundle && $scope.AmendBundle.InsuredValues) { if (val == "M") $scope.Quote.Vehicles[$scope.index].InsuredValue = $scope.AmendBundle.InsuredValues.MARKETVALUE; else if (val == "R") $scope.Quote.Vehicles[$scope.index].InsuredValue = $scope.AmendBundle.InsuredValues.RETAILVALUE; else if (val == "T") $scope.Quote.Vehicles[$scope.index].InsuredValue = $scope.AmendBundle.InsuredValues.TRADEVALUE; else if (val == "B") $scope.Quote.Vehicles[$scope.index].InsuredValue = $scope.AmendBundle.InsuredValues.BETTERCARVALUE; } }); $scope.DisableCarHireEvent = false; $scope.$watch('Quote.Vehicles[index].CarHireWhichCar', function (val) { if (val) { if (val === "N") { $scope.DisableCarHireEvent = true; $scope.Quote.Vehicles[$scope.index].CarHireYN = "N"; } else { $scope.DisableCarHireEvent = false; } } }); if ($scope.Quote.Vehicles[$scope.index].CoverType === "" || $scope.Quote.Vehicles[$scope.index].CoverType === null) { $scope.Quote.Vehicles[$scope.index].AmendBundle.CoverType = "CO"; $scope.Quote.Vehicles[$scope.index].CarHireWhichCar = "A"; $scope.Quote.Vehicles[$scope.index].CarHireYN = "E"; } $scope.$watch('AmendBundle.CoverTypeOptions', function (val) { if (val) { $scope.AmendBundle.Has4x4 = false; angular.forEach(val, function (value, key) { if (value && value.Description.indexOf('4x') > 0) { // has 4x4 $scope.AmendBundle.Has4x4 = true; } }); } }); $scope.$watch('Quote.Vehicles[index].AmendBundle.CoverType', function (val) { $scope.Quote.Vehicles[$scope.index].BuyAssistDisabled = true; $scope.Quote.Vehicles[$scope.index].BuyAssist = "N"; if (val == "TL" || val == "T1" || val == "T2" || val == "T3") { $scope.Quote.Vehicles[$scope.index].BuyAssistDisabled = false; } //Third Party Fire and Storm if (val == "TF") { $scope.Quote.Vehicles[$scope.index].HailCover = "N"; //Hail cover not available (disabled in index) } //Third Party Only if (val == "TO") { $scope.Quote.Vehicles[$scope.index].HailCover = "N"; //Hail cover not available (disabled in index) $scope.Quote.Vehicles[$scope.index].WindscreenCover = "N"; //Windscreen cover not available (disabled in index) $scope.Quote.Vehicles[$scope.index].CarHire = "N"; //Carhire cover not available (disabled in index) if ($scope.Quote.IsBroker) { $scope.Quote.Vehicles[$scope.index].CarHireWhichCar = "N"; $scope.Quote.Vehicles[$scope.index].CarHireYN = "N"; } } if (val == "CO" || val == "4X") { if ($scope.Quote.Vehicles[$scope.index].VehicleFinanced == "Y" && $scope.Quote.Vehicles[$scope.index].ExtendedLiability == null) $scope.Quote.Vehicles[$scope.index].ExtendedLiability = "Y"; if ($scope.Quote.IsBroker) { $scope.Quote.Vehicles[$scope.index].CarHireYN = "E"; } } if (val == "CO" && $scope.Quote.Vehicles[$scope.index].VehicleFinanced == "N" && $scope.Quote.Vehicles[$scope.index].ExtendedLiability == null) { $scope.Quote.Vehicles[$scope.index].ExtendedLiability = "N"; } //If a non-financed 4x4 has Theft as a cover type, extended liability must default to R5 million if (val == "4X" && $scope.Quote.Vehicles[$scope.index].VehicleFinanced == "N") { $scope.Quote.Vehicles[$scope.index].ExtendedLiability = "Y"; } if ((val == "TF" || val == "TO")) { $scope.Quote.Vehicles[$scope.index].ExtendedLiability = "N"; if ($scope.Quote.IsBroker) { $scope.Quote.Vehicles[$scope.index].CarHireYN = "D"; } } if (!$scope.Quote.Vehicles[$scope.index].FFAccessories) { $scope.Quote.Vehicles[$scope.index].FFAccessories = { Editable: "N" }; } if (val == "4X") { $scope.Quote.Vehicles[$scope.index].FFAccessories.Editable = "Y" } else { $scope.Quote.Vehicles[$scope.index].FFAccessories.Editable = "N" } }); } else { $scope.InitBundles(); } if ($scope.Quote.Vehicles && $scope.index) { if ($scope.Quote.Vehicles[$scope.index] && $scope.Quote.Vehicles[$scope.index].VehicleFinanced == "Y" && $scope.Quote.AmendmentMode == 'Add') $scope.Quote.Vehicles[$scope.index].Sasria = "Y"; } $scope.AllowVehicleAdd = $scope.Quote.Vehicles.length < 6; //Allow Home content if it was never added or it was removed $scope.AllowHomeAdd = !$scope.Quote.HomeContent.HomeContentsValue && !($scope.Quote.HomeContent.HomeContentsValue == 0 && $scope.Quote.HomeContent.TrueAndCorrect == false); $scope.AllowBuildingAdd = !$scope.Quote.Building.BuildingValue; // amend bundle setters $scope.SetCoverType = function () { if ($scope.NavigationInProgress == true) { return; } $scope.NavigationInProgress = true;//disable button if ($scope.Quote.Vehicles[$scope.index].AmendBundle.CoverType != "CO")//stop it from changing page load default { $scope.Quote.Vehicles[$scope.index].AmendBundle.BasicExcess = 0;//ensure the default third party is being selected $scope.SetExcess(false); //MVD covertype change popup hasDiscount var vehilceDiscount = $scope.Quote.DiscountDetails ? $scope.Quote.DiscountDetails.filter(function (v) { return (v.vehicleSequenceNumber == $scope.Quote.Vehicles[$scope.index].VehicleSequenceNumber); }) : null; if (typeof (vehilceDiscount) != "undefined" && vehilceDiscount != null && vehilceDiscount.length > 0 && $scope.Quote.DiscountAmounts.length != 0 && vehilceDiscount[0].hasDiscount) $mdDialog.show( $mdDialog.alert().clickOutsideToClose(true).disableParentScroll(false) .title('Multi Vehicle Discount') .content("Should your cover type change, it may affect the comprehensive vehicle cover discount you qualified for, which works as follows: " + $scope.Quote.DiscountAmounts[0].NumberOfVehicles + " car = no discount, " + $scope.Quote.DiscountAmounts[1].NumberOfVehicles + " cars = up to " + $scope.Quote.DiscountAmounts[1].DiscountPercentage + "%, " + $scope.Quote.DiscountAmounts[2].NumberOfVehicles + " cars = up to " + $scope.Quote.DiscountAmounts[2].DiscountPercentage + "%, " + $scope.Quote.DiscountAmounts[3].NumberOfVehicles + " cars = up to " + $scope.Quote.DiscountAmounts[3].DiscountPercentage + "% each.") .ok('OK!') ); } $http({ method: 'POST', url: '/Quote/Bundles/SetCoverTypeForVehicle', params: { referenceNumber: $scope.Quote.ReferenceNumber, vehicleSequenceNumber: $scope.Quote.Vehicles[$scope.index].VehicleSequenceNumber, bundleCode: $scope.Quote.Vehicles[$scope.index].AmendBundle.CoverType } }).success(function (data, status, headers, config) { $scope.GetAmendBundleData(); }); }; $scope.SetExcess = function (GetAmendBundle) { if ($scope.NavigationInProgress == true) { return; } $scope.NavigationInProgress = true;//disable button $http({ method: 'POST', url: '/Quote/Bundles/SetExcessBasedonCode', params: { referenceNumber: $scope.Quote.ReferenceNumber, vehicleSequenceNumber: $scope.Quote.Vehicles[$scope.index].VehicleSequenceNumber, bundleCode: $scope.Quote.Vehicles[$scope.index].AmendBundle.BasicExcess } }).success(function (data, status, headers, config) { if (GetAmendBundle) { $scope.GetAmendBundleData(); } }); }; $scope.SetCarhire = function () { if ($scope.NavigationInProgress == true) { return; } $scope.NavigationInProgress = true;//disable button $http({ method: 'POST', url: '/Quote/Bundles/SetCarhirebyBundleCode', params: { referenceNumber: $scope.Quote.ReferenceNumber, vehicleSequenceNumber: $scope.Quote.Vehicles[$scope.index].VehicleSequenceNumber, bundleCode: $scope.Quote.Vehicles[$scope.index].CarHireWhichCar } }).success(function (data, status, headers, config) { $scope.Quote.Vehicles[$scope.index].CarHireYN = $scope.Quote.Vehicles[$scope.index].CarHireWhichCar === "N" ? "N" : "Y"; $scope.GetAmendBundleData(); }); }; $scope.saverOptions = function () { return function (option) { return (option.Code != 'TL' && option.Code != 'T1' && option.Code != 'T2' && option.Code != 'T3' && option.Code != 'A1' && option.Code != 'A2' && option.Code != 'A3') } } $scope.IsVehicleAbsoluteAntiTheft = $scope.Quote.Vehicles.filter(function (v) { return (v.IsVehicleAbsoluteAntiTheft); }).length > 0; $scope.checkVehicleAdherence = function (risknumber) { var vehicle = $scope.Quote.Vehicles.filter(function (v) { return (v.IsVehicleAbsoluteAntiTheft && v.VehicleSequenceNumber == risknumber); }); if (vehicle.length > 0) { return function (option) { return (option.Code != 'CO' && option.Code != 'TF' && option.Code != '4X') } } return ''; } }]) .config(["IdleProvider", "KeepaliveProvider", "TitleProvider", function (IdleProvider, KeepaliveProvider, TitleProvider) { // configure Idle settings IdleProvider.idle(30); // in seconds IdleProvider.keepalive(false); TitleProvider.enabled(false); // it is enabled by default }]) });