· 7 years ago · Dec 06, 2018, 09:48 AM
1/*
2 * createInsuranceProductService
3 *
4 * */
5app.register.factory('createInsuranceProductService', createInsuranceProductService);
6
7function createInsuranceProductService($http) {
8 return {};
9
10 //////////////////////////
11
12}
13
14createInsuranceProductService.$inject = ['$http'];
15
16app.register.controller('createInsuranceProduct', createInsuranceProduct);
17
18createInsuranceProduct.$inject = [
19 '$scope',
20 'Upload',
21 '$routeParams',
22 '$http',
23 '$location',
24 '$rootScope',
25 '$q',
26 '$window'
27];
28
29function createInsuranceProduct(
30 $scope,
31 Upload,
32 $routeParams,
33 $http,
34 $location,
35 $rootScope,
36 $q,
37 $window
38) {
39 $scope.$watch('productData', function (newValue, oldValue, scope) {
40 // console.log($scope.productData);
41 },true);
42// summernote configuration
43 $scope.summernoteOptions = {
44 height : 400,
45 focus : true,
46 toolbar: [
47 ['edit', ['undo', 'redo']],
48 ['headline', ['style']],
49 ['style', ['bold', 'italic', 'underline', 'superscript', 'subscript', 'strikethrough', 'clear']],
50 ['textsize', ['fontsize']],
51 ['fontclr', ['color']],
52 ['alignment', ['ul', 'ol', 'paragraph', 'lineheight']],
53 ['height', ['height']],
54 ['table', ['table']],
55 //['insert', ['link','picture','video','hr']],
56 ['view', ['fullscreen']],
57 //['view', ['fullscreen', 'codeview']],
58 // ['help', ['help']]
59 ]
60 };
61 // Prevent for access product on another company
62 $rootScope.$on('cfpLoadingBar:completed', function () {
63 // trik unik
64 setTimeout(function () {
65 var val_type = $('#inputTypeHidden').val();
66 if (val_type == '') {
67 //$('select').val('');
68 }
69 }, 1000);
70 // show if using hideTillLoaded
71 angular.element(document).find('.hideTillLoaded').removeClass('hideTillLoaded');
72 });
73 $scope.new_travel = function (type) {
74 switch (type) {
75 case 'domestic':
76 $scope.travel_domestic.push('new');
77 if ($scope.travel_domestic.length <= 2) {
78 var last = parseInt($scope.productData['rates']['domestic'][0]['days_min'], 10);
79 $scope.productData['rates']['domestic'][1] = {'days_min': last + 1};
80 } else {
81 var last = parseInt($scope.productData['rates']['domestic'][$scope.travel_domestic.length - 2]['days_min'], 10);
82 $scope.productData['rates']['domestic'][$scope.travel_domestic.length - 1] = {'days_min': last + 1};
83 }
84 break;
85 case 'asean':
86 $scope.travel_asean.push('new');
87 if ($scope.travel_asean.length <= 2) {
88 var last = parseInt($scope.productData['rates']['asean'][0]['days_min'], 10);
89 $scope.productData['rates']['asean'][1] = {'days_min': last + 1};
90 } else {
91 var last = parseInt($scope.productData['rates']['asean'][$scope.travel_asean.length - 2]['days_min'], 10);
92 $scope.productData['rates']['asean'][$scope.travel_asean.length - 1] = {'days_min': last + 1};
93 }
94 break;
95 case 'asia':
96 $scope.travel_asia.push('new');
97 if ($scope.travel_asia.length <= 2) {
98 var last = parseInt($scope.productData['rates']['asia'][0]['days_min'], 10);
99 $scope.productData['rates']['asia'][1] = {'days_min': last + 1};
100 } else {
101 var last = parseInt($scope.productData['rates']['asia'][$scope.travel_asia.length - 2]['days_min'], 10);
102 $scope.productData['rates']['asia'][$scope.travel_asia.length - 1] = {'days_min': last + 1};
103 }
104 break;
105 case 'wwis':
106 $scope.travel_wwis.push('new');
107 if ($scope.travel_wwis.length <= 2) {
108 var last = parseInt($scope.productData['rates']['wwis'][0]['days_min'], 10);
109 $scope.productData['rates']['wwis'][1] = {'days_min': last + 1};
110 } else {
111 var last = parseInt($scope.productData['rates']['wwis'][$scope.travel_wwis.length - 2]['days_min'], 10);
112 $scope.productData['rates']['wwis'][$scope.travel_wwis.length - 1] = {'days_min': last + 1};
113 }
114 break;
115 case 'wwes':
116 $scope.travel_wwes.push('new');
117 if ($scope.travel_wwes.length <= 2) {
118 var last = parseInt($scope.productData['rates']['wwes'][0]['days_min'], 10);
119 $scope.productData['rates']['wwes'][1] = {'days_min': last + 1};
120 } else {
121 var last = parseInt($scope.productData['rates']['wwes'][$scope.travel_wwes.length - 2]['days_min'], 10);
122 $scope.productData['rates']['wwes'][$scope.travel_wwes.length - 1] = {'days_min': last + 1};
123 }
124 break;
125 }
126 };
127 $rootScope.$on('$includeContentLoaded', function () {
128 var passing = $scope.productData['type_of_insurance'];
129
130 angular.element(function () {
131 //$("#inputTypeHidden").show();
132 if (passing != '' && typeof passing != 'undefined' && passing !== null) {
133 $('.inputTypeRadio').hide();
134 } else {
135 $('.inputTypeRadio').show();
136 }
137 if (passing == 'comprehensive') {
138 $('.comprehensive').show();
139 } else if (passing == 'total_loss_only') {
140 $('.tlo').show();
141 } else if (passing == 'all_risk' || passing == 'all') {
142 $('.comprehensive').show();
143 } else if (passing == 'standard') {
144 $('.tlo').show();
145 } else if (passing == 'earthquake') {
146 $('.tlo').show();
147 }
148 $('#save-button').show();
149 });
150 });
151
152 // preparing defer
153 $scope.defer = $q.defer();
154 //Promo Remaining Character function
155 $scope.promoMaxLength = 50;
156
157 //Capturing current state for redirect purpose
158 $scope.state = $routeParams.state;
159
160 if ($rootScope.currentUserData.provider_id > 0 && $rootScope.currentUserData.provider_slug != $routeParams.slug) {
161 toastr.error('You cannot create product on another insurance company', 'PREVENTION');
162 $location.path('/insurance/product');
163 }
164
165 $scope.refresh_selection = function () {
166 $scope.selection = [];
167 for (var zzz in $scope.productData['feature']) {
168 if (zzz != 'count' && zzz != 'product_id' && zzz != 'sort_features') {
169 if ($scope.productData['feature'][zzz] != null && $scope.productData['feature'][zzz] > 0) {
170 var axe = zzz.replace(/_/g, ' ');
171 $scope.selection.push({'data': zzz, 'name': axe});
172 }
173 }
174 }
175 };
176
177 $scope.life_repeat = [1];
178 $scope.life_others_repeat = [1];
179 $scope.life_childrens_repeat = [1];
180 $scope.travel_domestic = [1];
181 $scope.travel_asean = [1];
182 $scope.travel_asia = [1];
183 $scope.travel_wwis = [1];
184 $scope.travel_wwes = [1];
185 $scope.selection = [];
186 $scope.extra_domestic_enable = 0;
187 $scope.extra_asean_enable = 0;
188 $scope.extra_asia_enable = 0;
189 $scope.extra_wwis_enable = 0;
190 $scope.extra_wwes_enable = 0;
191
192 $scope.annual_domestic_enable = 0;
193 $scope.annual_asean_enable = 0;
194 $scope.annual_asia_enable = 0;
195 $scope.annual_wwis_enable = 0;
196 $scope.annual_wwes_enable = 0;
197 $scope.sort_features = [
198 {'id': 0, 'name': 'First Row'},
199 {'id': 1, 'name': 'Second Row'},
200 {'id': 2, 'name': 'Third Row'},
201 {'id': 3, 'name': 'Fourth Row'}];
202 $scope.belajar_berhitung = {1: 'one', 2: 'two', 3: 'three'};
203
204 var type = $routeParams.slugType;
205 var consolidate = {'comprehensive': {}, 'total_loss_only': {}, 'all': {}, 'standard': {}, 'earthquake': {}};
206 if (type == 'property') {
207 $http.get('/api/rate/all?type=' + type + '&category=all').then(function (response) {
208 consolidate.all = response.data;
209 });
210 $http.get('/api/rate/all?type=' + type + '&category=standard').then(function (response) {
211 consolidate.standard = response.data;
212 });
213 $http.get('/api/rate/all?type=' + type + '&category=earthquake').then(function (response) {
214 consolidate.earthquake = response.data;
215 });
216 } else if (type == 'car' || type == 'motorcycle') {
217 $http.get('/api/rate/all?type=' + type + '&category=comprehensive').then(function (response) {
218 consolidate.comprehensive = response.data;
219 });
220 $http.get('/api/rate/all?type=' + type + '&category=total_loss_only').then(function (response) {
221 consolidate.total_loss_only = response.data;
222 });
223 }
224
225 var alphabets = ['one', 'two', 'three', 'four', 'five'];
226 $scope.detail_consolidate = consolidate;
227 $scope.count = ['one'];
228 $scope.redirect = '';
229 $scope.productData = {};
230 $scope.productRadioCheck = {};
231 $scope.productFieldType = {};
232 $scope.productFieldMirror = {};
233 $scope.productFieldShowed = {};
234 $scope.productFieldCondition = {};
235 $scope.selector = {};
236 $scope.usePromo = false;
237 $scope.required = {};
238
239 $scope.picker_first = '';
240 $scope.picker_second = '';
241 $scope.picker_third = '';
242 $scope.picker_fourth = '';
243 $scope.pushCount = function (what) {
244 $scope.count.push(alphabets[what]);
245 };
246
247 var extra_domestic = 0;
248 var extra_asean = 0;
249 var extra_asia = 0;
250 var extra_wwis = 0;
251 var extra_wwes = 0;
252
253 // Provinsi kota dll
254 $scope.province = {};
255 $scope.cities = {};
256 $scope.subdistrict = {};
257 $http.get('/api/province?lang=en').then(function (response) {
258 $scope.province = response.data;
259 });
260 $scope.populateCity = function () {
261 // always reset selected when populate
262 $scope.productData['questionnaire'].city = '';
263 $http.get('https://ongkir.indowebdeveloper.com/bandingin/provinces/' + $scope.productData.questionnaire['province'] + '/cities/all?lang=en').then(function (response) {
264 $scope.cities = response.data.results;
265 });
266 };
267 $scope.populateSubdistrict = function () {
268 // always reset selected when populate
269 $scope.productData['questionnaire'].subdistrict = '';
270 $http.get('https://ongkir.indowebdeveloper.com/bandingin/cities/' + $scope.productData.questionnaire['city'] + '/subdistricts/all?lang=en').then(function (response) {
271 $scope.subdistrict = response.data.results;
272 });
273 };
274
275 $scope.update_sort = function (picker, value) {
276 if (typeof $scope.productData['feature']['sort_features'] == 'undefined' || $scope.productData['feature']['sort_features'] === null) {
277 $scope.productData['feature']['sort_features'] = {};
278 }
279 for (var pickss in $scope.productData['feature']['sort_features']) {
280 if ($scope.productData['feature']['sort_features'][pickss] == value) {
281 delete $scope.productData['feature']['sort_features'][pickss];
282 }
283 }
284 $scope.productData['feature']['sort_features'][picker] = value;
285 };
286
287 // get product detail by slug
288 $scope.select_feature = {'percentages': 'Percentages (%)', 'amount': 'Amount (IDR)'};
289
290 if ($routeParams.slugProduct) {
291 var realProductLoaded = $http.get('/api/insurance/product/getBySlug/' + $routeParams.slugType + '/' + $routeParams.slugProduct).then(function (response) {
292
293 if (response.data != 'null') {
294 // main information
295 $scope.productData['rates'] = {};
296 $scope.productData['id'] = response.data.id;
297 $scope.productData['premi'] = response.data.premi;
298 $scope.productData['name'] = response.data.name;
299 $scope.productData['brief_en'] = response.data.brief_en;
300 $scope.productData['brief_id'] = response.data.brief_id;
301 $scope.productData['type'] = response.data.type;
302 $scope.productData['product_code'] = response.data.product_code;
303 $scope.productData['type_of_insurance'] = response.data.type_of_insurance;
304 $scope.productData['affiliate_url'] = response.data.affiliate_url;
305 $scope.productData['override_url'] = response.data.override_url;
306 $scope.productData['promo_url'] = response.data.promo_url;
307 $scope.productData['partners'] = response.data.insurance_product_partners;
308 $scope.productData['request_callback_button'] = response.data.request_callback_button;
309 $scope.productData['email_me_button'] = response.data.email_me_button;
310 $scope.productData['website_button'] = response.data.website_button;
311 $scope.productData['contact_button'] = response.data.contact_button;
312 $scope.productData['features_sort'] = {};
313 if (response.data.promo) {
314 $scope.usePromo = 'oke';
315 $scope.productData['promo'] = response.data.promo;
316 }
317 // start manipulation
318 if (response.data.detail.length >= 2) {
319 $scope.productData['detail'] = response.data.detail;
320 }
321 if (response.data.logo != null) {
322 $scope.productData['logo'] = response.data.logo.image;
323 }
324 //;
325
326 // jadi disini gua pengen ngambil data si rates buat dicallback balik
327 // gua mesti cari tipe dia dulu, karena tiap tipe kategory punya masing masing tipe
328
329 switch ($scope.productData.type) {
330 case 'property':
331 var all = response.data.coverage_property_all;
332 var flexas = response.data.coverage_property_standard;
333 var freq = response.data.coverage_property_earthquake;
334 if (all.length > 0) {
335 $scope.productData['rates']['all'] = {};
336 var z = 1;
337 for (var i = 0; i < all.length; i++) {
338 //Check the data with the value rules array in controller
339 var first_match = 0;
340 var second_match = 0;
341 var third_match = 0;
342
343 $scope.productData['rates']['all'][z] = {
344 1 : all[i]['class_one_rate'].toString(),
345 2 : all[i]['class_two_rate'].toString(),
346 3 : all[i]['class_three_rate'].toString(),
347 'custom' : all[i]['class_custom_rate'],
348 'bundle_zone': all[i]['bundle_zone'],
349 'bundle_rsmd': all[i]['rsmd_zone']
350 };
351
352 if (!isNaN(all[i]['class_one_rate']) || all[i]['class_one_rate'] == 'custom') {
353 $scope.productData['rates']['all'][z]['custom_one'] = all[i]['class_one_rate'];
354 }
355 if (!isNaN(all[i]['class_two_rate']) || all[i]['class_two_rate'] == 'custom') {
356 $scope.productData['rates']['all'][z]['custom_two'] = all[i]['class_two_rate'];
357 }
358 if (!isNaN(all[i]['class_three_rate']) || all[i]['class_three_rate'] == 'custom') {
359 $scope.productData['rates']['all'][z]['custom_three'] = all[i]['class_three_rate'];
360 }
361
362 try {
363 if (!_.isUndefined(all[i]['bundle_zone'])) {
364 $scope.productData['bundle_zone'] = all[i]['bundle_zone'];
365 }
366 }
367 catch (error) {
368 (MyObj.showError()) ? console.log(error) : '';
369 }
370
371 try {
372 if (!_.isUndefined(all[i]['bundle_rsmd'])) {
373 $scope.productData['bundle_rsmd'] = all[i]['rsmd_zone'];
374 }
375 }
376 catch (error) {
377 (MyObj.showError()) ? console.log(error) : '';
378 }
379 z++;
380 }
381 /**
382 angular.element(document).ready(function(){
383 $("#inputTypeHidden").show();
384 $(".inputTypeRadio").hide();
385 $(".all_risk").show();
386 $("#save-button").show();
387
388 });
389 **/
390 }
391
392 if (flexas.length > 0) {
393 $scope.productData['rates']['standard'] = {};
394 var z = 1;
395 for (var i = 0; i < flexas.length; i++) {
396 //Check the data with the value rules array in controller
397 var first_match = 0;
398 var second_match = 0;
399 var third_match = 0;
400
401 $scope.productData['rates']['standard'][z] = {
402 1 : flexas[i]['class_one_rate'].toString(),
403 2 : flexas[i]['class_two_rate'].toString(),
404 3 : flexas[i]['class_three_rate'].toString(),
405 'custom': flexas[i]['class_custom_rate']
406 };
407
408 if (!isNaN(flexas[i]['class_one_rate']) || flexas[i]['class_one_rate'] == 'custom') {
409 $scope.productData['rates']['standard'][z]['custom_one'] = flexas[i]['class_one_rate'];
410 }
411 if (!isNaN(flexas[i]['class_two_rate']) || flexas[i]['class_two_rate'] == 'custom') {
412 $scope.productData['rates']['standard'][z]['custom_two'] = flexas[i]['class_two_rate'];
413 }
414 if (!isNaN(flexas[i]['class_three_rate']) || flexas[i]['class_three_rate'] == 'custom') {
415 $scope.productData['rates']['standard'][z]['custom_three'] = flexas[i]['class_three_rate'];
416 }
417
418 z++;
419 }
420 /**
421 angular.element(document).ready(function(){
422 $("#inputTypeHidden").show();
423 $(".inputTypeRadio").hide();
424 $(".flexas").show();
425 $("#save-button").show();
426 });
427 **/
428 }
429
430 if (freq.length > 0) {
431 $scope.productData['rates']['earthquake'] = {};
432 for (a = 1; a < 7; a++) {
433 $scope.productData['rates']['earthquake'][a] = {};
434 }
435 angular.forEach(freq, function (key, value) {
436 var first_match = 0;
437 var second_match = 0;
438 var third_match = 0;
439 var fourth_match = 0;
440 var fifth_match = 0;
441
442 var category = key.category;
443 var id_class = key.class;
444 var first_zone = key.zone_one_rate;
445 var second_zone = key.zone_two_rate;
446 var third_zone = key.zone_three_rate;
447 var fourth_zone = key.zone_four_rate;
448 var fifth_zone = key.zone_five_rate;
449
450 $scope.productData['rates']['earthquake'][category][id_class] = {
451 1 : first_zone.toString(),
452 2 : second_zone.toString(),
453 3 : third_zone.toString(),
454 4 : fourth_zone.toString(),
455 5 : fifth_zone.toString(),
456 'custom': key.zone_custom_rate
457 };
458
459 if (first_zone == 'custom' || !isNaN(first_zone)) {
460 $scope.productData['rates']['earthquake'][category][id_class]['custom_one'] = first_zone;
461 }
462 if (second_zone == 'custom' || !isNaN(second_zone)) {
463 $scope.productData['rates']['earthquake'][category][id_class]['custom_two'] = second_zone;
464 }
465 if (third_zone == 'custom' || !isNaN(third_zone)) {
466 $scope.productData['rates']['earthquake'][category][id_class]['custom_three'] = third_zone;
467 }
468 if (fourth_zone == 'custom' || !isNaN(fourth_zone)) {
469 $scope.productData['rates']['earthquake'][category][id_class]['custom_four'] = fourth_zone;
470 }
471 if (fifth_zone == 'custom' || !isNaN(fifth_zone)) {
472 $scope.productData['rates']['earthquake'][category][id_class]['custom_five'] = fifth_zone;
473 }
474 });
475 /**
476 angular.element(document).ready(function(){
477 $("#inputTypeHidden").show();
478 $(".inputTypeRadio").hide();
479 $(".earthquake").show();
480 $("#save-button").show();
481 });
482 **/
483 }
484 break;
485
486 // ini buat car atau motorcycle
487 case 'car':
488 case 'motorcycle':
489 if ($scope.productData.type == 'car') {
490 var comprehensive = response.data.coverage_car_comprehensive;
491 var tlo = response.data.coverage_car_total_loss_only;
492 } else {
493 var comprehensive = response.data.coverage_motorcycle_comprehensive;
494 var tlo = response.data.coverage_motorcycle_total_loss_only;
495 }
496 if (comprehensive.length > 0) {
497
498 $scope.productData['rates']['comprehensive'] = {};
499 var z = 1;
500 for (var i = 0; i < comprehensive.length; i++) {
501 //Check the data with the value rules array in controller
502 var first_match = 0;
503 var second_match = 0;
504 var third_match = 0;
505
506 $scope.productData['rates']['comprehensive'][z] = {
507 1 : comprehensive[i]['territory_one_rate'].toString(),
508 2 : comprehensive[i]['territory_two_rate'].toString(),
509 3 : comprehensive[i]['territory_three_rate'].toString(),
510 'custom': comprehensive[i]['territory_custom_rate']
511 };
512
513 if (!isNaN(comprehensive[i]['territory_one_rate']) || comprehensive[i]['territory_one_rate'] == 'custom') {
514 $scope.productData['rates']['comprehensive'][z]['custom_one'] = comprehensive[i]['territory_one_rate'];
515 }
516 if (!isNaN(comprehensive[i]['territory_two_rate']) || comprehensive[i]['territory_two_rate'] == 'custom') {
517 $scope.productData['rates']['comprehensive'][z]['custom_two'] = comprehensive[i]['territory_two_rate'];
518 }
519 if (!isNaN(comprehensive[i]['territory_three_rate']) || comprehensive[i]['territory_three_rate'] == 'custom') {
520 $scope.productData['rates']['comprehensive'][z]['custom_three'] = comprehensive[i]['territory_three_rate'];
521 }
522 z++;
523 }
524
525 /**
526 angular.element(document).ready(function(){
527 $("#inputTypeHidden").show();
528 $(".inputTypeRadio").hide();
529 $(".comprehensive").show();
530 $("#save-button").show();
531
532 });
533 **/
534 }
535
536 if (tlo.length > 0) {
537 $scope.productData['rates']['total_loss_only'] = {};
538
539 var z = 1;
540 for (var i = 0; i < tlo.length; i++) {
541 //Check the data with the value rules array in controller
542 var first_match = 0;
543 var second_match = 0;
544 var third_match = 0;
545
546 $scope.productData['rates']['total_loss_only'][z] = {
547 1 : tlo[i]['territory_one_rate'].toString(),
548 2 : tlo[i]['territory_two_rate'].toString(),
549 3 : tlo[i]['territory_three_rate'].toString(),
550 'custom': tlo[i]['territory_custom_rate']
551 };
552
553 if (!isNaN(tlo[i]['territory_one_rate']) || tlo[i]['territory_one_rate'] == 'custom') {
554 $scope.productData['rates']['total_loss_only'][z]['custom_one'] = tlo[i]['territory_one_rate'];
555 }
556 if (!isNaN(tlo[i]['territory_two_rate']) || tlo[i]['territory_two_rate'] == 'custom') {
557 $scope.productData['rates']['total_loss_only'][z]['custom_two'] = tlo[i]['territory_two_rate'];
558 }
559 if (!isNaN(tlo[i]['territory_three_rate']) || tlo[i]['territory_three_rate'] == 'custom') {
560 $scope.productData['rates']['total_loss_only'][z]['custom_three'] = tlo[i]['territory_three_rate'];
561 }
562 z++;
563 }
564 /**
565 angular.element(document).ready(function(){
566
567 $("#inputTypeHidden").show();
568 $(".inputTypeRadio").hide();
569 $(".tlo").show();
570 $("#save-button").show();
571 });
572 **/
573 }
574
575 break;
576
577 case 'personal.accident':
578 $scope.productData['rates']['main'] = [];
579 $scope.productData['rates']['other'] = [];
580
581 $scope.productData['rates']['main'][1] = response.data.coverage_self_accident[0].class_one_rate;
582 $scope.productData['rates']['main'][2] = response.data.coverage_self_accident[0].class_two_rate;
583 $scope.productData['rates']['main'][3] = response.data.coverage_self_accident[0].class_three_rate;
584 $scope.productData['rates']['main'][4] = response.data.coverage_self_accident[0].class_four_rate;
585 $scope.productData['rates']['main'][5] = response.data.coverage_self_accident[0].class_five_rate;
586
587 $scope.productData['rates']['other'][1] = response.data.coverage_self_accident_other[0].class_one_rate;
588 $scope.productData['rates']['other'][2] = response.data.coverage_self_accident_other[0].class_two_rate;
589 $scope.productData['rates']['other'][3] = response.data.coverage_self_accident_other[0].class_three_rate;
590 $scope.productData['rates']['other'][4] = response.data.coverage_self_accident_other[0].class_four_rate;
591 $scope.productData['rates']['other'][5] = response.data.coverage_self_accident_other[0].class_five_rate;
592
593 break;
594
595 case 'travel':
596 $scope.travel_domestic = [];
597 $scope.productData['rates']['domestic'] = {'extra': 'daily'};
598 var sorter = ['one_person', 'two_person', 'three_person', 'four_person', 'five_person'];
599
600 for (var i = 0; i < response.data.coverage_travel_domestic.length; i++) {
601 $scope.travel_domestic.push('new');
602 $scope.productData['rates']['domestic']['pancingan'] = true;
603 $scope.productData['rates']['domestic']['extra'] = response.data.coverage_travel_domestic[i].extra;
604 $scope.productData['rates']['domestic']['extra_price_one_person'] = response.data.coverage_travel_domestic[i].extra_one_person;
605 $scope.productData['rates']['domestic']['extra_price_two_person'] = response.data.coverage_travel_domestic[i].extra_two_person;
606 $scope.productData['rates']['domestic']['extra_price_three_person'] = response.data.coverage_travel_domestic[i].extra_three_person;
607 $scope.productData['rates']['domestic']['extra_price_four_person'] = response.data.coverage_travel_domestic[i].extra_four_person;
608 $scope.productData['rates']['domestic']['extra_price_five_person'] = response.data.coverage_travel_domestic[i].extra_five_person;
609 if (typeof response.data.coverage_travel_domestic[i].extra != 'undefined') {
610 if (response.data.coverage_travel_domestic[i].extra != null) {
611 var enable_domestic = 0;
612 for (var xyz = 0; xyz < sorter.length; xyz++) {
613 if (response.data.coverage_travel_domestic[i]['extra_' + sorter[xyz]] > 0) {
614 enable_domestic += 1;
615 }
616 }
617
618 if (enable_domestic > 0 && extra_domestic < 1) {
619 $scope.extra_domestic_enable = 1;
620 }
621 }
622 }
623 console.log('WAAAHHHH MYSSQL');
624 console.log($scope.extra_domestic_enable);
625
626 $scope.productData['rates']['domestic'][i] = {
627 'days_min' : response.data.coverage_travel_domestic[i].days_min,
628 'one_person' : response.data.coverage_travel_domestic[i].one_person,
629 'two_person' : response.data.coverage_travel_domestic[i].two_person,
630 'three_person': response.data.coverage_travel_domestic[i].three_person,
631 'four_person' : response.data.coverage_travel_domestic[i].four_person,
632 'five_person' : response.data.coverage_travel_domestic[i].five_person
633 };
634 }
635
636 $scope.travel_asean = [];
637 $scope.productData['rates']['asean'] = {'extra': 'daily'};
638 for (var i = 0; i < response.data.coverage_travel_asean.length; i++) {
639 $scope.travel_asean.push('new');
640 $scope.productData['rates']['asean']['pancingan'] = true;
641 $scope.productData['rates']['asean']['extra'] = response.data.coverage_travel_asean[i].extra;
642 $scope.productData['rates']['asean']['extra_price_one_person'] = response.data.coverage_travel_asean[i].extra_one_person;
643 $scope.productData['rates']['asean']['extra_price_two_person'] = response.data.coverage_travel_asean[i].extra_two_person;
644 $scope.productData['rates']['asean']['extra_price_three_person'] = response.data.coverage_travel_asean[i].extra_three_person;
645 $scope.productData['rates']['asean']['extra_price_four_person'] = response.data.coverage_travel_asean[i].extra_four_person;
646 $scope.productData['rates']['asean']['extra_price_five_person'] = response.data.coverage_travel_asean[i].extra_five_person;
647 if (typeof response.data.coverage_travel_asean[i].extra != 'undefined') {
648 if (response.data.coverage_travel_asean[i].extra != null) {
649 var enable_asean = 0;
650 for (var xyz = 0; xyz < sorter.length; xyz++) {
651 if (response.data.coverage_travel_asean[i]['extra_' + sorter[xyz]] > 0) {
652 enable_asean += 1;
653 }
654 }
655
656 if (enable_asean > 0 && extra_asean < 1) {
657 $scope.extra_asean_enable = 1;
658 }
659 }
660 }
661 $scope.productData['rates']['asean'][i] = {
662 'days_min' : response.data.coverage_travel_asean[i].days_min,
663 'one_person' : response.data.coverage_travel_asean[i].one_person,
664 'two_person' : response.data.coverage_travel_asean[i].two_person,
665 'three_person': response.data.coverage_travel_asean[i].three_person,
666 'four_person' : response.data.coverage_travel_asean[i].four_person,
667 'five_person' : response.data.coverage_travel_asean[i].five_person
668 };
669 }
670
671 $scope.travel_asia = [];
672 $scope.productData['rates']['asia'] = {'extra': 'daily'};
673 for (var i = 0; i < response.data.coverage_travel_asia.length; i++) {
674 $scope.travel_asia.push('new');
675 $scope.productData['rates']['asia']['pancingan'] = true;
676 $scope.productData['rates']['asia']['extra'] = response.data.coverage_travel_asia[i].extra;
677 $scope.productData['rates']['asia']['extra_price_one_person'] = response.data.coverage_travel_asia[i].extra_one_person;
678 $scope.productData['rates']['asia']['extra_price_two_person'] = response.data.coverage_travel_asia[i].extra_two_person;
679 $scope.productData['rates']['asia']['extra_price_three_person'] = response.data.coverage_travel_asia[i].extra_three_person;
680 $scope.productData['rates']['asia']['extra_price_four_person'] = response.data.coverage_travel_asia[i].extra_four_person;
681 $scope.productData['rates']['asia']['extra_price_five_person'] = response.data.coverage_travel_asia[i].extra_five_person;
682 if (typeof response.data.coverage_travel_asia[i].extra != 'undefined') {
683 if (response.data.coverage_travel_asia[i].extra != null) {
684 var enable_asia = 0;
685 for (var xyz = 0; xyz < sorter.length; xyz++) {
686 if (response.data.coverage_travel_asia[i]['extra_' + sorter[xyz]] > 0) {
687 enable_asia += 1;
688 }
689 }
690
691 if (enable_asia > 0 && extra_asia < 1) {
692 $scope.extra_asia_enable = 1;
693 }
694 }
695 }
696 $scope.productData['rates']['asia'][i] = {
697 'days_min' : response.data.coverage_travel_asia[i].days_min,
698 'one_person' : response.data.coverage_travel_asia[i].one_person,
699 'two_person' : response.data.coverage_travel_asia[i].two_person,
700 'three_person': response.data.coverage_travel_asia[i].three_person,
701 'four_person' : response.data.coverage_travel_asia[i].four_person,
702 'five_person' : response.data.coverage_travel_asia[i].five_person
703 };
704 }
705
706 $scope.travel_wwis = [];
707 $scope.productData['rates']['wwis'] = {'extra': 'daily'};
708 for (var i = 0; i < response.data.coverage_travel_worldwide_include_shenzeng.length; i++) {
709 $scope.travel_wwis.push('new');
710 $scope.productData['rates']['wwis']['pancingan'] = true;
711 $scope.productData['rates']['wwis']['extra'] = response.data.coverage_travel_worldwide_include_shenzeng[i].extra;
712 $scope.productData['rates']['wwis']['extra_price_one_person'] = response.data.coverage_travel_worldwide_include_shenzeng[i].extra_one_person;
713 $scope.productData['rates']['wwis']['extra_price_two_person'] = response.data.coverage_travel_worldwide_include_shenzeng[i].extra_two_person;
714 $scope.productData['rates']['wwis']['extra_price_three_person'] = response.data.coverage_travel_worldwide_include_shenzeng[i].extra_three_person;
715 $scope.productData['rates']['wwis']['extra_price_four_person'] = response.data.coverage_travel_worldwide_include_shenzeng[i].extra_four_person;
716 $scope.productData['rates']['wwis']['extra_price_five_person'] = response.data.coverage_travel_worldwide_include_shenzeng[i].extra_five_person;
717 if (typeof response.data.coverage_travel_worldwide_include_shenzeng[i].extra != 'undefined') {
718 if (response.data.coverage_travel_worldwide_include_shenzeng[i].extra != null) {
719 var enable_wwis = 0;
720 for (var xyz = 0; xyz < sorter.length; xyz++) {
721 if (response.data.coverage_travel_worldwide_include_shenzeng[i]['extra_' + sorter[xyz]] > 0) {
722 enable_wwis += 1;
723 }
724 }
725
726 if (enable_wwis > 0 && extra_wwis < 1) {
727 $scope.extra_wwis_enable = 1;
728 }
729 }
730 }
731 $scope.productData['rates']['wwis'][i] = {
732 'days_min' : response.data.coverage_travel_worldwide_include_shenzeng[i].days_min,
733 'one_person' : response.data.coverage_travel_worldwide_include_shenzeng[i].one_person,
734 'two_person' : response.data.coverage_travel_worldwide_include_shenzeng[i].two_person,
735 'three_person': response.data.coverage_travel_worldwide_include_shenzeng[i].three_person,
736 'four_person' : response.data.coverage_travel_worldwide_include_shenzeng[i].four_person,
737 'five_person' : response.data.coverage_travel_worldwide_include_shenzeng[i].five_person
738 };
739 }
740
741 $scope.travel_wwes = [];
742 $scope.productData['rates']['wwes'] = {'extra': 'daily'};
743 for (var i = 0; i < response.data.coverage_travel_worldwide_exclude_shenzeng.length; i++) {
744 $scope.travel_wwes.push('new');
745 $scope.productData['rates']['wwes']['pancingan'] = true;
746 $scope.productData['rates']['wwes']['extra'] = response.data.coverage_travel_worldwide_exclude_shenzeng[i].extra;
747 $scope.productData['rates']['wwes']['extra_price_one_person'] = response.data.coverage_travel_worldwide_exclude_shenzeng[i].extra_one_person;
748 $scope.productData['rates']['wwes']['extra_price_two_person'] = response.data.coverage_travel_worldwide_exclude_shenzeng[i].extra_two_person;
749 $scope.productData['rates']['wwes']['extra_price_three_person'] = response.data.coverage_travel_worldwide_exclude_shenzeng[i].extra_three_person;
750 $scope.productData['rates']['wwes']['extra_price_four_person'] = response.data.coverage_travel_worldwide_exclude_shenzeng[i].extra_four_person;
751 $scope.productData['rates']['wwes']['extra_price_five_person'] = response.data.coverage_travel_worldwide_exclude_shenzeng[i].extra_five_person;
752 if (typeof response.data.coverage_travel_worldwide_exclude_shenzeng[i].extra != 'undefined') {
753 if (response.data.coverage_travel_worldwide_exclude_shenzeng[i].extra != null) {
754 var enable_wwes = 0;
755 for (var xyz = 0; xyz < sorter.length; xyz++) {
756 if (response.data.coverage_travel_worldwide_exclude_shenzeng[i]['extra_' + sorter[xyz]] > 0) {
757 enable_wwes += 1;
758 }
759 }
760
761 if (enable_wwes > 0 && extra_wwes < 1) {
762 $scope.extra_wwes_enable = 1;
763 }
764 }
765 }
766 $scope.productData['rates']['wwes'][i] = {
767 'days_min' : response.data.coverage_travel_worldwide_exclude_shenzeng[i].days_min,
768 'one_person' : response.data.coverage_travel_worldwide_exclude_shenzeng[i].one_person,
769 'two_person' : response.data.coverage_travel_worldwide_exclude_shenzeng[i].two_person,
770 'three_person': response.data.coverage_travel_worldwide_exclude_shenzeng[i].three_person,
771 'four_person' : response.data.coverage_travel_worldwide_exclude_shenzeng[i].four_person,
772 'five_person' : response.data.coverage_travel_worldwide_exclude_shenzeng[i].five_person
773 };
774 }
775
776 for (var i = 0; i < response.data.coverage_travel_annual.length; i++) {
777 var types = response.data.coverage_travel_annual[i].type;
778 $scope.productData['rates'][types]['annual'] = response.data.coverage_travel_annual[i];
779 delete $scope.productData['rates'][types]['annual']['type'];
780 delete $scope.productData['rates'][types]['annual']['id'];
781 delete $scope.productData['rates'][types]['annual']['product_id'];
782 }
783
784 if (typeof $scope.productData['rates']['domestic']['annual'] != 'undefined') {
785 if ($scope.productData['rates']['domestic']['annual'] != null) {
786 var this_is_domestic = 0;
787 for (var keys in $scope.productData['rates']['domestic']['annual']) {
788 if ($scope.productData['rates']['domestic']['annual'][keys] > 0) {
789 this_is_domestic += 1;
790 }
791 }
792
793 if (this_is_domestic > 0) {
794 $scope.annual_domestic_enable = 1;
795 }
796 }
797 }
798 if (typeof $scope.productData['rates']['asean']['annual'] != 'undefined') {
799 if ($scope.productData['rates']['asean']['annual'] != null) {
800 var this_is_asean = 0;
801 for (var keys in $scope.productData['rates']['asean']['annual']) {
802 if ($scope.productData['rates']['asean']['annual'][keys] > 0) {
803 this_is_asean += 1;
804 }
805 }
806
807 if (this_is_asean > 0) {
808 $scope.annual_asean_enable = 1;
809 }
810 }
811 }
812 if (typeof $scope.productData['rates']['asia']['annual'] != 'undefined') {
813 if ($scope.productData['rates']['asia']['annual'] != null) {
814 var this_is_asia = 0;
815 for (var keys in $scope.productData['rates']['asia']['annual']) {
816 if ($scope.productData['rates']['asia']['annual'][keys] > 0) {
817 this_is_asia += 1;
818 }
819 }
820
821 if (this_is_asia > 0) {
822 $scope.annual_asia_enable = 1;
823 }
824 }
825 }
826 if (typeof $scope.productData['rates']['wwis']['annual'] != 'undefined') {
827 if ($scope.productData['rates']['wwis']['annual'] != null) {
828 var this_is_wwis = 0;
829 for (var keys in $scope.productData['rates']['wwis']['annual']) {
830 if ($scope.productData['rates']['wwis']['annual'][keys] > 0) {
831 this_is_wwis += 1;
832 }
833 }
834
835 if (this_is_wwis > 0) {
836 $scope.annual_wwis_enable = 1;
837 }
838 }
839 }
840 if (typeof $scope.productData['rates']['wwes']['annual'] != 'undefined') {
841 if ($scope.productData['rates']['wwes']['annual'] != null) {
842 var this_is_wwes = 0;
843 for (var keys in $scope.productData['rates']['wwes']['annual']) {
844 if ($scope.productData['rates']['wwes']['annual'][keys] > 0) {
845 this_is_wwes += 1;
846 }
847 }
848
849 if (this_is_wwes > 0) {
850 $scope.annual_wwes_enable = 1;
851 }
852 }
853 }
854
855 break;
856
857 case 'life':
858 $scope.productData['rates'] = [];
859 $scope.productData['others'] = [];
860 $scope.productData['childrens'] = [];
861
862 var counter = response.data.coverage_life_basic.length;
863 $scope.life_repeat = [];
864 for (var i = 0; i < counter; i++) {
865 $scope.life_repeat.push('new');
866 $scope.productData['rates'][i] = {
867 'age' : response.data.coverage_life_basic[i].age_min,
868 'yearly' : response.data.coverage_life_basic[i].yearly_rates,
869 'semester': response.data.coverage_life_basic[i].semester_rates,
870 'quartal' : response.data.coverage_life_basic[i].quartal_rates,
871 'monthly' : response.data.coverage_life_basic[i].monthly_rates
872 };
873 }
874
875 var counter_others = response.data.coverage_life_others.length;
876 $scope.life_others_repeat = [];
877 for (var i = 0; i < counter_others; i++) {
878 $scope.life_others_repeat.push('new');
879 $scope.productData['others'][i] = {
880 'age' : response.data.coverage_life_others[i].age_min,
881 'yearly' : response.data.coverage_life_others[i].yearly_rates,
882 'semester': response.data.coverage_life_others[i].semester_rates,
883 'quartal' : response.data.coverage_life_others[i].quartal_rates,
884 'monthly' : response.data.coverage_life_others[i].monthly_rates
885 };
886 }
887
888 var counter_childrens = response.data.coverage_life_childrens.length;
889 $scope.life_childrens_repeat = [];
890 for (var i = 0; i < counter_childrens; i++) {
891 $scope.life_childrens_repeat.push('new');
892 $scope.productData['childrens'][i] = {
893 'age' : response.data.coverage_life_childrens[i].age_min,
894 'yearly' : response.data.coverage_life_childrens[i].yearly_rates,
895 'semester': response.data.coverage_life_childrens[i].semester_rates,
896 'quartal' : response.data.coverage_life_childrens[i].quartal_rates,
897 'monthly' : response.data.coverage_life_childrens[i].monthly_rates
898 };
899 }
900
901 break;
902
903 case 'health':
904 $scope.productData['rates'] = [];
905 $scope.productData['others'] = [];
906 $scope.productData['childrens'] = [];
907
908 var counter = response.data.coverage_health.length;
909 $scope.life_repeat = [];
910 for (var i = 0; i < counter; i++) {
911 $scope.life_repeat.push('new');
912 $scope.productData['rates'][i] = {
913 'age' : response.data.coverage_health[i].age_min,
914 'yearly' : response.data.coverage_health[i].yearly_rates,
915 'semester': response.data.coverage_health[i].semester_rates,
916 'quartal' : response.data.coverage_health[i].quartal_rates,
917 'monthly' : response.data.coverage_health[i].monthly_rates
918 };
919 }
920
921 var counter_others = response.data.coverage_health_others.length;
922 $scope.life_others_repeat = [];
923 for (var i = 0; i < counter_others; i++) {
924 $scope.life_others_repeat.push('new');
925 $scope.productData['others'][i] = {
926 'age' : response.data.coverage_health_others[i].age_min,
927 'yearly' : response.data.coverage_health_others[i].yearly_rates,
928 'semester': response.data.coverage_health_others[i].semester_rates,
929 'quartal' : response.data.coverage_health_others[i].quartal_rates,
930 'monthly' : response.data.coverage_health_others[i].monthly_rates
931 };
932 }
933
934 var counter_childrens = response.data.coverage_health_childrens.length;
935 $scope.life_childrens_repeat = [];
936 for (var i = 0; i < counter_childrens; i++) {
937 $scope.life_childrens_repeat.push('new');
938 $scope.productData['childrens'][i] = {
939 'age' : response.data.coverage_health_childrens[i].age_min,
940 'yearly' : response.data.coverage_health_childrens[i].yearly_rates,
941 'semester': response.data.coverage_health_childrens[i].semester_rates,
942 'quartal' : response.data.coverage_health_childrens[i].quartal_rates,
943 'monthly' : response.data.coverage_health_childrens[i].monthly_rates
944 };
945 }
946 break;
947 case 'personal.accident.age':
948 $scope.productData['rates'] = [];
949 $scope.productData['couple'] = [];
950
951 var counter = response.data.coverage_self_accident_age_basic.length;
952 $scope.life_repeat = [];
953 for (var i = 0; i < counter; i++) {
954 $scope.life_repeat.push('new');
955 $scope.productData['rates'][i] = {
956 'age' : response.data.coverage_self_accident_age_basic[i].age_min,
957 'yearly' : response.data.coverage_self_accident_age_basic[i].yearly_rates,
958 'semester': response.data.coverage_self_accident_age_basic[i].semester_rates,
959 'quartal' : response.data.coverage_self_accident_age_basic[i].quartal_rates,
960 'monthly' : response.data.coverage_self_accident_age_basic[i].monthly_rates
961 };
962 }
963
964 var counter_couple = response.data.coverage_self_accident_age_couple.length;
965 $scope.life_others_repeat = [];
966 for (var i = 0; i < counter_couple; i++) {
967 $scope.life_others_repeat.push('new');
968 $scope.productData['couple'][i] = {
969 'age' : response.data.coverage_self_accident_age_couple[i].age_min,
970 'yearly' : response.data.coverage_self_accident_age_couple[i].yearly_rates,
971 'semester': response.data.coverage_self_accident_age_couple[i].semester_rates,
972 'quartal' : response.data.coverage_self_accident_age_couple[i].quartal_rates,
973 'monthly' : response.data.coverage_self_accident_age_couple[i].monthly_rates
974 };
975 }
976
977 break;
978
979 case 'personal.accident.sum.insured':
980 $scope.productData['percent'] = [];
981 $scope.productData['sum_insured'] = [];
982
983 var counter = response.data.coverage_self_accident_sum_insured.length;
984 $scope.life_repeat = [];
985 for (var i = 0; i < counter; i++) {
986 $scope.life_repeat.push('new');
987 $scope.productData['rates'][i] = {
988 'percent' : response.data.coverage_self_accident_sum_insured[i].percent,
989 'sum_insured' : response.data.coverage_self_accident_sum_insured[i].sum_insured,
990 };
991 }
992
993 break;
994 }
995
996 // end
997 // make sure response.data.{nama relasi yang harus di panggil}
998 switch ($routeParams.slugType) {
999 case 'property':
1000 $scope.productData['questionnaire'] = response.data.quest_property;
1001 $scope.productData['benefit'] = response.data.benefit_property;
1002 $scope.productData['feature'] = response.data.feature_property;
1003
1004 var asu = $scope.productData['questionnaire']['have_you_made_any_claim_in_5_year'];
1005 if (typeof asu === 'string') {
1006 $scope.productData['questionnaire']['have_you_made_any_claim_in_5_year'] = asu.split(',');
1007 }
1008
1009 var susu = [];
1010 for (var i = 0; i < alphabets.length; i++) {
1011 if (($scope.productData['questionnaire']['label_breakdown_' + alphabets[i]] != null && typeof $scope.productData['questionnaire']['label_breakdown_' + alphabets[i]] != 'undefined')) {
1012 susu.push(alphabets[i]);
1013 }
1014 }
1015 $scope.count = susu;
1016 break;
1017
1018 case 'car':
1019 $scope.productData['questionnaire'] = response.data.quest_car;
1020 $scope.productData['benefit'] = response.data.benefit_car;
1021 $scope.productData['feature'] = response.data.feature_car;
1022
1023 break;
1024
1025 case 'motorcycle':
1026 $scope.productData['questionnaire'] = response.data.quest_motorcycle;
1027 $scope.productData['benefit'] = response.data.benefit_motorcycle;
1028 $scope.productData['feature'] = response.data.feature_motorcycle;
1029 break;
1030
1031 case 'travel':
1032 $scope.productData['questionnaire'] = response.data.quest_travel;
1033 $scope.productData['benefit'] = response.data.benefit_travel;
1034 $scope.productData['feature'] = response.data.feature_travel;
1035 break;
1036
1037 case 'health':
1038 $scope.productData['questionnaire'] = response.data.quest_health;
1039 $scope.productData['benefit'] = response.data.benefit_health;
1040 $scope.productData['feature'] = response.data.feature_health;
1041
1042 var asu = $scope.productData['questionnaire']['do_you_have_any_pre-existing_medical_conditions'];
1043 if (typeof asu === 'string') {
1044 $scope.productData['questionnaire']['do_you_have_any_pre-existing_medical_conditions'] = asu.split(',');
1045 }
1046
1047 var susu = [];
1048 for (var i = 0; i < alphabets.length; i++) {
1049 if ($scope.productData['questionnaire']['label_claim_' + alphabets[i]] != null && typeof $scope.productData['questionnaire']['label_claim_' + alphabets[i]] != 'undefined') {
1050 susu.push(alphabets[i]);
1051 }
1052 }
1053 $scope.count = susu;
1054 break;
1055 case 'personal-accident':
1056 case 'personal-accident-age':
1057 case 'personal-accident-sum-insured':
1058 $scope.productData['questionnaire'] = response.data.quest_personal_accident;
1059 console.log("Datanya : " + $scope.productData['questionnaire']);
1060 $scope.productData['feature'] = response.data.feature_personal_accident;
1061
1062 var susu = [];
1063 for (var i = 0; i < alphabets.length; i++) {
1064 if ($scope.productData['questionnaire']['label_claim_' + alphabets[i]] != null && typeof $scope.productData['questionnaire']['label_claim_' + alphabets[i]] != 'undefined') {
1065 susu.push(alphabets[i]);
1066 }
1067 }
1068 $scope.count = susu;
1069 break;
1070
1071 case 'personal-accident-sum-insured':
1072 $scope.productData['questionnaire'] = response.data.quest_personal_accident_sum_insured;
1073 console.log("Datanya : " + $scope.productData['questionnaire']);
1074 $scope.productData['feature'] = response.data.feature_personal_accident_sum_insured;
1075
1076 var susu = [];
1077 for (var i = 0; i < alphabets.length; i++) {
1078 if ($scope.productData['questionnaire']['label_claim_' + alphabets[i]] != null && typeof $scope.productData['questionnaire']['label_claim_' + alphabets[i]] != 'undefined') {
1079 susu.push(alphabets[i]);
1080 }
1081 }
1082 $scope.count = susu;
1083 break;
1084
1085 case 'life':
1086 $scope.productData['questionnaire'] = response.data.quest_life;
1087 $scope.productData['feature'] = response.data.feature_life;
1088 break;
1089
1090 // lanjut semua dsini
1091 default:
1092 break;
1093 }
1094
1095// $scope.refresh_selection();
1096
1097 $scope.productData['features_additionals'] = {};
1098 if (typeof response.data.features_additional_prices != 'undefined') {
1099 for (var i = 0; i < response.data.features_additional_prices.length; i++) {
1100 var keyz = response.data.features_additional_prices[i]['key'];
1101 var typez = response.data.features_additional_prices[i]['type'];
1102 var valuez = response.data.features_additional_prices[i]['value'];
1103
1104 $scope.productData['features_additionals'][keyz] = {'key': keyz, 'type': typez, 'value': valuez};
1105 }
1106 }
1107
1108 // conditional feature & sorting nya
1109 if ($scope.productData['feature'] != null) {
1110 for (var zzz in $scope.productData['feature']) {
1111 if (zzz != 'count' && zzz != 'product_id' && zzz != 'sort_features') {
1112 if ($scope.productData['feature'][zzz] != null) {
1113 var axe = zzz.replace(/_/g, ' ');
1114 $scope.selection.push({'data': zzz, 'name': axe});
1115 }
1116 }
1117 }
1118 if ($scope.productData['feature']['sort_features'] != null) {
1119 var ftrs = JSON.parse($scope.productData['feature']['sort_features']);
1120 $scope.productData['feature']['sort_features'] = ftrs;
1121
1122 for (var fts in ftrs) {
1123 if (ftrs[fts] == '0') {
1124 $scope.picker_first = fts;
1125 }
1126 else if (ftrs[fts] == '1') {
1127 $scope.picker_second = fts;
1128 }
1129 else if (ftrs[fts] == '2') {
1130 $scope.picker_third = fts;
1131 }
1132 else if (ftrs[fts] == '3') {
1133 $scope.picker_fourth = fts;
1134 }
1135 }
1136 }
1137 }
1138
1139
1140 var negara = $scope.productData['questionnaire'].restrict_country;
1141 var country = new Array();
1142 var country = negara.split(',');
1143 // console.log(country);
1144
1145 $scope.productData['questionnaire'].restrict_country = country;
1146 if ($scope.productData['questionnaire'] != null) {
1147 if ($scope.productData['questionnaire'].province != '' && $scope.productData['questionnaire'].province > 0) {
1148 $scope.cities = $http.get('https://ongkir.indowebdeveloper.com/bandingin/provinces/' + $scope.productData.questionnaire['province'] + '/cities/all?lang=en')
1149 .then(function (response) {
1150
1151 return response.data.results;
1152 });
1153 }
1154 if ($scope.productData['questionnaire'].city != '' && $scope.productData['questionnaire'].city > 0) {
1155 $scope.subdistrict = $http.get('https://ongkir.indowebdeveloper.com/bandingin/cities/' + $scope.productData.questionnaire['city'] + '/subdistricts/all?lang=en')
1156 .then(function (response) {
1157 // console.log('oke');
1158 return response.data.results;
1159 });
1160 }
1161 }
1162
1163 // disini gua misah misahin antara tipe car, motor dan property dll kalo ada penambahan pasca release,
1164 // urus ndiri bete gua.
1165 switch (response.data.type) {
1166 case 'car':
1167 var additionals = response.data.additional_car;
1168 break;
1169 case 'motorcycle':
1170 var additionals = response.data.additional_motorcycle;
1171 break;
1172 case 'property':
1173 var additionals = response.data.additional_property;
1174 break;
1175 default:
1176 var additionals = [];
1177 }
1178
1179 $scope.savedAdditional = additionals;
1180 $scope.productData['additional'] = {};
1181 for (ky in additionals) {
1182 if (additionals.hasOwnProperty(ky)) {
1183 if (typeof additionals[ky] == 'number') {
1184 $scope.productData['additional'][ky] = additionals[ky].toString();
1185 } else {
1186 $scope.productData['additional'][ky] = additionals[ky];
1187 }
1188 }
1189
1190
1191 // for car
1192 if (ky == 'earthquake_with_tsunami_zone_one') {
1193 if (!isNaN($scope.productData['additional'][ky])) {
1194 $scope.productData['additional']['earthquake_with_tsunami_zone_one_custom'] = Number($scope.productData['additional'][ky]);
1195 $scope.productData['additional'][ky] = 'custom';
1196 }
1197 }
1198 if (ky == 'earthquake_with_tsunami_zone_two') {
1199 if (!isNaN($scope.productData['additional'][ky])) {
1200 $scope.productData['additional']['earthquake_with_tsunami_zone_two_custom'] = Number($scope.productData['additional'][ky]);
1201 $scope.productData['additional'][ky] = 'custom';
1202 }
1203 }
1204 if (ky == 'earthquake_with_tsunami_zone_three') {
1205 if (!isNaN($scope.productData['additional'][ky])) {
1206 $scope.productData['additional']['earthquake_with_tsunami_zone_three_custom'] = Number($scope.productData['additional'][ky]);
1207 $scope.productData['additional'][ky] = 'custom';
1208 }
1209 }
1210 if (ky == 'flood_with_tornado_zone_one') {
1211 if (!isNaN($scope.productData['additional'][ky])) {
1212 $scope.productData['additional']['flood_with_tornado_zone_one_custom'] = Number($scope.productData['additional'][ky]);
1213 $scope.productData['additional'][ky] = 'custom';
1214 }
1215 }
1216 if (ky == 'flood_with_tornado_zone_two') {
1217 if (!isNaN($scope.productData['additional'][ky])) {
1218 $scope.productData['additional']['flood_with_tornado_zone_two_custom'] = Number($scope.productData['additional'][ky]);
1219 $scope.productData['additional'][ky] = 'custom';
1220 }
1221 }
1222 if (ky == 'flood_with_tornado_zone_three') {
1223 if (!isNaN($scope.productData['additional'][ky])) {
1224 $scope.productData['additional']['flood_with_tornado_zone_three_custom'] = Number($scope.productData['additional'][ky]);
1225 $scope.productData['additional'][ky] = 'custom';
1226 }
1227 }
1228 }
1229 $scope.productData['additional']['type_of_insurance'] = response.data.type_of_insurance;
1230 if ($scope.productData['additional']['responsibility_third_party_by_law'] > 0 && $scope.productData['additional']['responsibility_third_party_by_law'] != null) {
1231 $scope.responsibility_third_party_by_law = 1;
1232 }
1233
1234 if ($scope.productData['additional']['responsibility_law_for_passenger'] > 0 && $scope.productData['additional']['responsibility_law_for_passenger'] != null) {
1235 $scope.responsibility_law_for_passenger = 1;
1236 }
1237 }
1238
1239 }).then(function (a) {
1240 $http.get('/api/insurance/getTmp/' + $routeParams.state).then(function (response) {
1241 if (response.data != 'null') {
1242 $scope.productData = Object.assign($scope.productData, response.data.data);
1243 //$scope.productData = response.data.data;
1244
1245 try {
1246 if (
1247 (!_.isUndefined($scope.productData.additional.type_of_insurance)) &&
1248 ($scope.productData.additional.type_of_insurance === 'all_risk')
1249 ) {
1250 //$scope.productData['bundle_zone'] = ($scope.productData['rates']['all'][1]['bundle_zone']) ? $scope.productData['rates']['all'][1]['bundle_zone'] : ($scope.productData['bundle_zone']) ? $scope.productData['bundle_zone'] : 0;
1251 if (_.isUndefined($scope.productData['bundle_zone'])) {
1252 $scope.productData['bundle_zone'] = $scope.productData['rates']['all'][1]['bundle_zone'];
1253 } else if ($scope.productData['bundle_zone'] === '') {
1254 if (_.isUndefined($scope.productData['rates']['all'][1]['bundle_zone'])) {
1255 $scope.productData['bundle_zone'] = $scope.productData['rates']['all'][1]['bundle_zone'];
1256 }
1257 }
1258
1259 }
1260 }
1261 catch (error) {
1262 (MyObj.showError()) ? console.log(error) : '';
1263 }
1264
1265 try {
1266 if (
1267 (!_.isUndefined($scope.productData.additional.type_of_insurance)) &&
1268 ($scope.productData.additional.type_of_insurance === 'all_risk')
1269 ) {
1270 // $scope.productData['bundle_rsmd'] = ($scope.productData['rates']['all'][1]['bundle_rsmd']) ? $scope.productData['rates']['all'][1]['bundle_rsmd'] : ($scope.productData['bundle_rsmd']) ? $scope.productData['bundle_rsmd'] : 0;
1271 if (_.isUndefined($scope.productData['bundle_rsmd'])) {
1272 $scope.productData['bundle_rsmd'] = $scope.productData['rates']['all'][1]['bundle_rsmd'];
1273 } else if ($scope.productData['bundle_rsmd'] === '') {
1274 if (_.isUndefined($scope.productData['rates']['all'][1]['bundle_rsmd'])) {
1275 $scope.productData['bundle_rsmd'] = $scope.productData['rates']['all'][1]['bundle_rsmd'];
1276 }
1277 }
1278
1279 }
1280 }
1281 catch (error) {
1282 (MyObj.showError()) ? console.log(error) : '';
1283 }
1284
1285 // check if product code exists or not
1286 if (!$scope.productData['product_code']) {
1287 $scope.productData['product_code'] = '';
1288 }
1289 $scope.productData['slug'] = $routeParams.slug;
1290 $scope.productData['slug_product'] = $routeParams.slugProduct;
1291 $scope.productData['slug_type'] = $routeParams.slugType;
1292
1293 // conditional feature & sorting nya
1294
1295 if ($scope.productData['feature'] != null) {
1296 $scope.selection = [];
1297 for (var zzz in $scope.productData['feature']) {
1298 if (zzz != 'count' && zzz != 'product_id' && zzz != 'sort_features' && zzz != 'dummy_benefit') {
1299 if ($scope.productData['feature'][zzz] != null) {
1300 var axe = zzz.replace(/_/g, ' ');
1301 $scope.selection.push({'data': zzz, 'name': axe});
1302 }
1303 }
1304 }
1305
1306 if ($scope.productData['feature']['sort_features'] != null) {
1307 try {
1308 var ftrs = JSON.parse($scope.productData['feature']['sort_features']);
1309 $scope.productData['feature']['sort_features'] = ftrs;
1310 } catch (e) {
1311 var ftrs = $scope.productData['feature']['sort_features'];
1312 }
1313
1314 for (var fts in ftrs) {
1315 if (ftrs[fts] == '0') {
1316 $scope.picker_first = fts;
1317 }
1318 else if (ftrs[fts] == '1') {
1319 $scope.picker_second = fts;
1320 }
1321 else if (ftrs[fts] == '2') {
1322 $scope.picker_third = fts;
1323 }
1324 else if (ftrs[fts] == '3') {
1325 $scope.picker_fourth = fts;
1326 }
1327 }
1328 }
1329 }
1330
1331 //Give state when in create but want to edit state
1332 if ($routeParams.slugType == 'travel') {
1333 var sorter2 = ['one_person', 'two_person', 'three_person', 'four_person', 'five_person'];
1334
1335 if(typeof $scope.productData['rates']['domestic']['extra'] != 'undefined'){
1336 if($scope.productData['rates']['domestic']['extra'] != null && $scope.productData['rates']['domestic']['extra']!= ''){
1337 var enable_domestic = 0;
1338
1339 for (var xyz = 0; xyz < sorter2.length; xyz++) {
1340 if ($scope.productData['rates']['domestic']['extra_price_' + sorter2[xyz]] > 0) {
1341 enable_domestic += 1;
1342 }
1343 }
1344
1345 if (enable_domestic > 0) {
1346 $scope.extra_domestic_enable = 1;
1347 extra_domestic = 1;
1348 console.log('WAAAHHHH waw');
1349 console.log($scope.extra_domestic_enable);
1350 }
1351 }
1352 }
1353 if(typeof $scope.productData['rates']['asean']['extra'] != 'undefined'){
1354 if($scope.productData['rates']['asean']['extra'] != null && $scope.productData['rates']['asean']['extra']!= ''){
1355 var enable_asean = 0;
1356
1357 for (var xyz = 0; xyz < sorter2.length; xyz++) {
1358 if ($scope.productData['rates']['asean']['extra_price_' + sorter2[xyz]] > 0) {
1359 enable_asean += 1;
1360 }
1361 }
1362
1363 if (enable_asean > 0) {
1364 $scope.extra_asean_enable = 1;
1365 extra_asean = 1;
1366 }
1367 }
1368 }
1369 if(typeof $scope.productData['rates']['asia']['extra'] != 'undefined'){
1370 if($scope.productData['rates']['asia']['extra'] != null && $scope.productData['rates']['asia']['extra']!= ''){
1371 var enable_asia = 0;
1372
1373 for (var xyz = 0; xyz < sorter2.length; xyz++) {
1374 if ($scope.productData['rates']['asia']['extra_price_' + sorter2[xyz]] > 0) {
1375 enable_asia += 1;
1376 }
1377 }
1378
1379 if (enable_asia > 0) {
1380 $scope.extra_asia_enable = 1;
1381 }
1382 }
1383 }
1384 if(typeof $scope.productData['rates']['wwis']['extra'] != 'undefined'){
1385 if($scope.productData['rates']['wwis']['extra'] != null && $scope.productData['rates']['wwis']['extra']!= ''){
1386 var enable_wwis = 0;
1387
1388 for (var xyz = 0; xyz < sorter2.length; xyz++) {
1389 if ($scope.productData['rates']['wwis']['extra_price_' + sorter2[xyz]] > 0) {
1390 enable_wwis += 1;
1391 }
1392 }
1393
1394 if (enable_wwis > 0) {
1395 $scope.extra_wwis_enable = 1;
1396 }
1397 }
1398 }
1399 if(typeof $scope.productData['rates']['wwes']['extra'] != 'undefined'){
1400 if($scope.productData['rates']['wwes']['extra'] != null && $scope.productData['rates']['wwes']['extra']!= ''){
1401 var enable_wwes = 0;
1402
1403 for (var xyz = 0; xyz < sorter2.length; xyz++) {
1404 if ($scope.productData['rates']['wwes']['extra_price_' + sorter2[xyz]] > 0) {
1405 enable_wwes += 1;
1406 }
1407 }
1408
1409 if (enable_wwes > 0) {
1410 $scope.extra_wwes_enable = 1;
1411 }
1412 }
1413 }
1414
1415 if (typeof $scope.productData['rates']['domestic']['annual'] != 'undefined') {
1416 if ($scope.productData['rates']['domestic']['annual'] != null) {
1417 var this_is_domestic = 0;
1418 for (var keys in $scope.productData['rates']['domestic']['annual']) {
1419 if ($scope.productData['rates']['domestic']['annual'][keys] > 0) {
1420 this_is_domestic += 1;
1421 }
1422 }
1423
1424 if (this_is_domestic > 0) {
1425 $scope.annual_domestic_enable = 1;
1426 }
1427 }
1428 }
1429
1430 if (typeof $scope.productData['rates']['asean']['annual'] != 'undefined') {
1431 if ($scope.productData['rates']['asean']['annual'] != null) {
1432 var this_is_asean = 0;
1433 for (var keys in $scope.productData['rates']['asean']['annual']) {
1434 if ($scope.productData['rates']['asean']['annual'][keys] > 0) {
1435 this_is_asean += 1;
1436 }
1437 }
1438
1439 if (this_is_asean > 0) {
1440 $scope.annual_asean_enable = 1;
1441 }
1442 }
1443 }
1444
1445 if (typeof $scope.productData['rates']['asia']['annual'] != 'undefined') {
1446 if ($scope.productData['rates']['asia']['annual'] != null) {
1447 var this_is_asia = 0;
1448 for (var keys in $scope.productData['rates']['asia']['annual']) {
1449 if ($scope.productData['rates']['asia']['annual'][keys] > 0) {
1450 this_is_asia += 1;
1451 }
1452 }
1453
1454 if (this_is_asia > 0) {
1455 $scope.annual_asia_enable = 1;
1456 }
1457 }
1458 }
1459
1460 if (typeof $scope.productData['rates']['wwis']['annual'] != 'undefined') {
1461 if ($scope.productData['rates']['wwis']['annual'] != null) {
1462 var this_is_wwis = 0;
1463 for (var keys in $scope.productData['rates']['wwis']['annual']) {
1464 if ($scope.productData['rates']['wwis']['annual'][keys] > 0) {
1465 this_is_wwis += 1;
1466 }
1467 }
1468
1469 if (this_is_wwis > 0) {
1470 $scope.annual_wwis_enable = 1;
1471 }
1472 }
1473 }
1474
1475 if (typeof $scope.productData['rates']['wwes']['annual'] != 'undefined') {
1476 if ($scope.productData['rates']['wwes']['annual'] != null) {
1477 var this_is_wwes = 0;
1478 for (var keys in $scope.productData['rates']['wwes']['annual']) {
1479 if ($scope.productData['rates']['wwes']['annual'][keys] > 0) {
1480 this_is_wwes += 1;
1481 }
1482 }
1483
1484 if (this_is_wwes > 0) {
1485 $scope.annual_wwes_enable = 1;
1486 }
1487 }
1488 }
1489
1490 if($scope.productData['product_code'] == ''){
1491 angular.forEach($scope.productData['rates']['domestic'], function (value, key) {
1492 if (key != 'extra' && key != 'extra_price_one_person' && key != 'extra_price_two_person' && key != 'extra_price_three_person' && key != 'extra_price_four_person' && key != 'extra_price_five_person' && key != 'annual' && key != '0') {
1493 $scope.travel_domestic.push('new');
1494 }
1495 });
1496 angular.forEach($scope.productData['rates']['asean'], function (value, key) {
1497 if (key != 'extra' && key != 'extra_price_one_person' && key != 'extra_price_two_person' && key != 'extra_price_three_person' && key != 'extra_price_four_person' && key != 'extra_price_five_person' && key != 'annual' && key != '0') {
1498 $scope.travel_asean.push('new');
1499 }
1500 });
1501 angular.forEach($scope.productData['rates']['asia'], function (value, key) {
1502 if (key != 'extra' && key != 'extra_price_one_person' && key != 'extra_price_two_person' && key != 'extra_price_three_person' && key != 'extra_price_four_person' && key != 'extra_price_five_person' && key != 'annual' && key != '0') {
1503 $scope.travel_asia.push('new');
1504 }
1505 });
1506 angular.forEach($scope.productData['rates']['wwis'], function (value, key) {
1507 if (key != 'extra' && key != 'extra_price_one_person' && key != 'extra_price_two_person' && key != 'extra_price_three_person' && key != 'extra_price_four_person' && key != 'extra_price_five_person' && key != 'annual' && key != '0') {
1508 $scope.travel_wwis.push('new');
1509 }
1510 });
1511 angular.forEach($scope.productData['rates']['wwes'], function (value, key) {
1512 if (key != 'extra' && key != 'extra_price_one_person' && key != 'extra_price_two_person' && key != 'extra_price_three_person' && key != 'extra_price_four_person' && key != 'extra_price_five_person' && key != 'annual' && key != '0') {
1513 $scope.travel_wwes.push('new');
1514 }
1515 });
1516 }
1517
1518 //$scope.productData['rates']['domestic'][0] = {
1519 // 'days_min':1
1520 ///};
1521 }
1522
1523 if ($routeParams.slugType == 'property') {
1524 var susu = [];
1525 for (var i = 0; i < alphabets.length; i++) {
1526 if (($scope.productData['questionnaire']['label_breakdown_' + alphabets[i]] != null && typeof $scope.productData['questionnaire']['label_breakdown_' + alphabets[i]] != 'undefined')) {
1527 susu.push(alphabets[i]);
1528 }
1529 }
1530 $scope.count = susu;
1531 }
1532
1533 if ($routeParams.slugType == 'life' || $routeParams.slugType == 'health') {
1534 $scope.life_repeat = [1];
1535 var length = $scope.productData['rates'].length;
1536 if (length > 0) {
1537 $scope.life_repeat = [];
1538 }
1539 for (var i = 0; i <= length - 1; i++) {
1540 $scope.life_repeat.push('new');
1541 }
1542 $scope.life_others_repeat = [1];
1543 var length_others = $scope.productData['others'].length;
1544 if (length_others > 0) {
1545 $scope.life_others_repeat = [];
1546 }
1547 for (var i = 0; i <= length_others - 1; i++) {
1548 $scope.life_others_repeat.push('new');
1549 }
1550 $scope.life_childrens_repeat = [1];
1551 var length_childrens = $scope.productData['childrens'].length;
1552 if (length_childrens > 0) {
1553 $scope.life_childrens_repeat = [];
1554 }
1555 for (var i = 0; i <= length_childrens - 1; i++) {
1556 $scope.life_childrens_repeat.push('new');
1557 }
1558 }
1559
1560 if ($routeParams.slugType == 'personal-accident-age') {
1561 $scope.life_repeat = [1];
1562 var length = $scope.productData['rates'].length;
1563 if (length > 0) {
1564 $scope.life_repeat = [];
1565 }
1566 for (var i = 0; i <= length - 1; i++) {
1567 $scope.life_repeat.push('new');
1568 }
1569
1570 $scope.life_others_repeat = [1];
1571 var length_others = $scope.productData['couple'].length;
1572 if (length_others > 0) {
1573 $scope.life_others_repeat = [];
1574 }
1575 for (var i = 0; i <= length_others - 1; i++) {
1576 $scope.life_others_repeat.push('new');
1577 }
1578 }
1579
1580
1581 var passing = $scope.productData['type_of_insurance'];
1582
1583 angular.element(function () {
1584 //$("#inputTypeHidden").show();
1585 if (passing != '' && typeof passing != 'undefined' && passing !== null) {
1586 $('.inputTypeRadio').hide();
1587 } else {
1588 $('.inputTypeRadio').show();
1589 }
1590 if (passing == 'comprehensive') {
1591 $('.comprehensive').show();
1592 } else if (passing == 'total_loss_only') {
1593 $('.tlo').show();
1594 } else if (passing == 'all_risk' || passing == 'all') {
1595 $('.comprehensive').show();
1596 } else if (passing == 'standard') {
1597 $('.tlo').show();
1598 } else if (passing == 'earthquake') {
1599 $('.tlo').show();
1600 }
1601 $('#save-button').show();
1602 });
1603
1604 if ($routeParams.slugType == 'travel'){
1605
1606 // Zul.. bener yang gw bilang.. itu ga mau ke assign karena lu coba assign object ke dalam array yang udh jadi
1607 // di JS beda sama PHP, kalau di PHP lu assign object kedalam array bakal otomatis jadi colllection..
1608 // kalau di JS kaga mau.. nah jadi solusinya, harus diubah jadi collection dulu meski ga ada extra..
1609 // karena faktanya, sebelum dicentang extra maupun annual, isi array itu kan key integer.. nah si JS anggep itu sebagai Array
1610 // terus pas mau lu assign extra maupun annual, itu kan key nya "string", nah si JS nolak.. makanya ini solusi nya diubah jadi collection dulu pake underscorejs
1611 // sisanya diupdate sendiri ya, ini gw contohin untuk rates asean sama domestic..
1612 // udah gw test dan working.. tapi tetep test lagi buat make sure 100%.. terlebih jangan lupa cek pas di bagian UPLOAD excel
1613 // sama pesen gw, lu sambil sering baca2 soal underscorejs and lodash, ini banyak bisa ngebantu soal js buat lu punya kerjaan..
1614
1615 $scope.productData.rates.domestic = _.object(_.map($scope.productData.rates.domestic, function(item,key) {
1616 return [key, item]
1617 }));
1618
1619 $scope.productData.rates.asean = _.object(_.map($scope.productData.rates.asean, function(item,key) {
1620 return [key, item]
1621 }));
1622
1623 $scope.productData.rates.asia = _.object(_.map($scope.productData.rates.asia, function(item,key) {
1624 return [key, item]
1625 }));
1626
1627 $scope.productData.rates.wwis = _.object(_.map($scope.productData.rates.wwis, function(item,key) {
1628 return [key, item]
1629 }));
1630
1631 $scope.productData.rates.wwes = _.object(_.map($scope.productData.rates.wwes, function(item,key) {
1632 return [key, item]
1633 }));
1634
1635
1636 }
1637 }
1638 // pura pura ambil data ceritanya
1639 if (typeof $scope.productData['features_dummy'] == 'undefined') {
1640 if ($scope.productData['feature']['dummy_benefit']) {
1641 var dummy_pake = JSON.parse($scope.productData['feature']['dummy_benefit']);
1642 $scope.productData['features_dummy'] = {};
1643 for (var dummy_key in dummy_pake) {
1644 var the_keys = Object.keys(dummy_pake[dummy_key])[0];
1645 $scope.productData['features_dummy'][dummy_key] = {
1646 'type' : the_keys,
1647 'value': dummy_pake[dummy_key][the_keys],
1648 'key' : dummy_key
1649 };
1650
1651
1652 }
1653 }
1654 }
1655 });
1656
1657 });
1658
1659 }
1660
1661 $scope.productData['slug'] = $routeParams.slug;
1662 $scope.productData['slug_product'] = $routeParams.slugProduct;
1663 $scope.productData['slug_type'] = $routeParams.slugType;
1664 $scope.bind_html_data = 'app/partials/insuranceManagement/provider/product/questionnaire/' + $routeParams.slugType + '.html';
1665 $scope.bind_html_detail = 'app/partials/insuranceManagement/provider/product/detail/' + $routeParams.slugType + '.html';
1666
1667 // get cloned productdata if state exists
1668
1669 $scope.step = {
1670 category: 'current',
1671 features: 'not',
1672 details : 'not'
1673 };
1674
1675 $scope.addPromo = function () {
1676 if ($scope.promoter.length < 4) {
1677 $scope.promoter.push('');
1678 }
1679 };
1680
1681 $scope.removePromo = function () {
1682 if ($scope.promoter.length > 1) {
1683 $scope.promoter.pop();
1684 }
1685 };
1686
1687 $scope.initialLoadRadioCheck = function (url, use_slug) {
1688 if (use_slug) {
1689 url += '?type=' + $scope.productData['slug_type'];
1690 }
1691 $http({
1692 method : 'GET',
1693 url : url,
1694 headers: {
1695 'Content-Type': 'application/x-www-form-urlencoded'
1696 } // set the headers so angular passing info as form data (not request payload)
1697 })
1698 .then(function successCallback(response) {
1699 if ($rootScope.currentUserData.provider_id != 0 && url == '/api/type') {
1700 var user_slug = $rootScope.currentUserData.type_slugs;
1701 var all_slug = response.data;
1702 var slugger = [];
1703 all_slug.forEach(function (item, index) {
1704 if (user_slug.indexOf(item.name) >= 0) {
1705 slugger.push({
1706 name : item.name,
1707 label: item.label
1708 });
1709 }
1710 });
1711 $scope.productRadioCheck = slugger;
1712 } else {
1713 $scope.productRadioCheck = response.data;
1714 }
1715 }, function errorCallback(response) {
1716
1717 });
1718 };
1719
1720 $scope.removeItem = function (cat) {
1721 var state = 'create';
1722 if ($scope.productData['product_code'] != '') {
1723 state = 'update';
1724 }
1725 if (cat == 'life' || cat == 'health' || cat == 'personal_accident_age') {
1726 if ($scope.productData['rates']) {
1727 var last_key = $scope.productData['rates'].length - 1;
1728 var count_others = $scope.life_repeat.length - 1;
1729
1730 //Remove last array from productData
1731 if (last_key == count_others) {
1732 $scope.productData['rates'].splice(last_key, 1);
1733 }
1734 $scope.life_repeat.pop();
1735 } else {
1736 $scope.life_repeat.pop();
1737 }
1738 }
1739 if (cat == 'personal_accident_age_couple') {
1740 if ($scope.productData['couple']) {
1741 var last_key = $scope.productData['couple'].length - 1;
1742 var count_others = $scope.life_others_repeat.length - 1;
1743
1744 //Remove last array from productData
1745 if (last_key == count_others) {
1746 $scope.productData['couple'].splice(last_key, 1);
1747 }
1748 $scope.life_others_repeat.pop();
1749 } else {
1750 $scope.life_others_repeat.pop();
1751 }
1752 }
1753 if (cat == 'life_others' || cat == 'health_others') {
1754 if ($scope.productData['others']) {
1755 var last_key = $scope.productData['others'].length - 1;
1756 var count_others = $scope.life_others_repeat.length - 1;
1757
1758 //Remove last array from productData
1759 if (last_key == count_others) {
1760 $scope.productData['others'].splice(last_key, 1);
1761 }
1762 $scope.life_others_repeat.pop();
1763 } else {
1764 $scope.life_others_repeat.pop();
1765 }
1766 }
1767 if (cat == 'life_childrens' || cat == 'health_childrens') {
1768 if ($scope.productData['childrens']) {
1769 var last_key = $scope.productData['childrens'].length - 1;
1770 var count_others = $scope.life_childrens_repeat.length - 1;
1771
1772 //Remove last array from productData
1773 if (last_key == count_others) {
1774 $scope.productData['childrens'].splice(last_key, 1);
1775 }
1776 $scope.life_childrens_repeat.pop();
1777 } else {
1778 $scope.life_childrens_repeat.pop();
1779 }
1780 }
1781 if (cat == 'travel_domestic') {
1782 if ($scope.productData['rates']) {
1783 var count = 0;
1784 angular.forEach($scope.productData['rates']['domestic'], function (value, key) {
1785 if (key != 'extra_price_one_person' && key != 'extra_price_two_person' && key != 'extra_price_three_person' && key != 'extra_price_four_person' && key != 'extra_price_five_person' && key != '0' && key != 'extra' && key != 'annual') {
1786 count++;
1787 }
1788 });
1789
1790 //Remove last array from productData
1791 delete $scope.productData['rates']['domestic'][count];
1792
1793 $scope.travel_domestic.pop();
1794 } else {
1795 $scope.travel_domestic.pop();
1796 }
1797 }
1798 if (cat == 'travel_asean') {
1799 if ($scope.productData['rates']) {
1800 var count = 0;
1801 angular.forEach($scope.productData['rates']['asean'], function (value, key) {
1802 if (key != 'extra_price_one_person' && key != 'extra_price_two_person' && key != 'extra_price_three_person' && key != 'extra_price_four_person' && key != 'extra_price_five_person' && key != '0' && key != 'extra' && key != 'annual') {
1803 count++;
1804 }
1805 });
1806
1807 //Remove last array from productData
1808 delete $scope.productData['rates']['asean'][count];
1809
1810 $scope.travel_asean.pop();
1811 } else {
1812 $scope.travel_asean.pop();
1813 }
1814 }
1815 if (cat == 'travel_asia') {
1816 if ($scope.productData['rates']) {
1817 var count = 0;
1818 angular.forEach($scope.productData['rates']['asia'], function (value, key) {
1819 if (key != 'extra_price_one_person' && key != 'extra_price_two_person' && key != 'extra_price_three_person' && key != 'extra_price_four_person' && key != 'extra_price_five_person' && key != '0' && key != 'extra' && key != 'annual') {
1820 count++;
1821 }
1822 });
1823
1824 //Remove last array from productData
1825 delete $scope.productData['rates']['asia'][count];
1826
1827 $scope.travel_asia.pop();
1828 } else {
1829 $scope.travel_asia.pop();
1830 }
1831 }
1832 if (cat == 'travel_wwis') {
1833 if ($scope.productData['rates']) {
1834 var count = 0;
1835 angular.forEach($scope.productData['rates']['wwis'], function (value, key) {
1836 if (key != 'extra_price_one_person' && key != 'extra_price_two_person' && key != 'extra_price_three_person' && key != 'extra_price_four_person' && key != 'extra_price_five_person' && key != '0' && key != 'extra' && key != 'annual') {
1837 count++;
1838 }
1839 });
1840
1841 //Remove last array from productData
1842 delete $scope.productData['rates']['wwis'][count];
1843
1844 $scope.travel_wwis.pop();
1845 } else {
1846 $scope.travel_wwis.pop();
1847 }
1848 }
1849 if (cat == 'travel_wwes') {
1850 if ($scope.productData['rates']) {
1851 var count = 0;
1852 angular.forEach($scope.productData['rates']['wwes'], function (value, key) {
1853 if (key != 'extra_price_one_person' && key != 'extra_price_two_person' && key != 'extra_price_three_person' && key != 'extra_price_four_person' && key != 'extra_price_five_person' && key != '0' && key != 'extra' && key != 'annual') {
1854 count++;
1855 }
1856 });
1857
1858 //Remove last array from productData
1859 delete $scope.productData['rates']['wwes'][count];
1860
1861 $scope.travel_wwes.pop();
1862 } else {
1863 $scope.travel_wwes.pop();
1864 }
1865 }
1866 };
1867
1868 $scope.initialLoadFielder = function (url, use_slug) {
1869 if (use_slug) {
1870 url += '?type=' + $scope.productData['slug_type'];
1871 }
1872 // console.log(url);
1873 $http({
1874 method : 'GET',
1875 url : url,
1876 headers: {
1877 'Content-Type': 'application/x-www-form-urlencoded'
1878 } // set the headers so angular passing info as form data (not request payload)
1879 })
1880 .then(function successCallback(response) {
1881 $scope.productFieldType = response.data;
1882 // console.log($scope.productFieldType);
1883
1884 }, function errorCallback(response) {
1885
1886 });
1887 };
1888
1889 $scope.remover = function (datas) {
1890 if (typeof datas != 'undefined') {
1891 for (var i = 0; datas.length > i; i++) {
1892 $scope.productFieldShowed[datas[i]] = false;
1893 }
1894 }
1895 };
1896
1897 $scope.initialLoadFieldType = function (url, use_slug, prefix) {
1898 if (use_slug) {
1899 url += '?col=slug_type&data=' + $scope.productData['slug_type'];
1900 }
1901
1902 $http({
1903 method : 'GET',
1904 url : url,
1905 headers: {
1906 'Content-Type': 'application/x-www-form-urlencoded'
1907 } // set the headers so angular passing info as form data (not request payload)
1908 })
1909 .then(function successCallback(response) {
1910
1911 $scope.productData[prefix] = [];
1912
1913 for (var i = 0; response.data.length > i; i++) {
1914 $scope.productData[prefix][response.data[i].id] = {};
1915 $scope.productData[prefix][response.data[i].id]['id'] = response.data[i].id;
1916 $scope.productFieldType[response.data[i].id] = {};
1917 // $scope.productFieldMirror[response.data[i].id] = '';
1918 try {
1919 $scope.productFieldCondition[response.data[i].id] = JSON.parse(response.data[i].condition);
1920 $scope.productFieldShowed[response.data[i].id] = false;
1921 } catch (e) {
1922 $scope.productFieldShowed[response.data[i].id] = true;
1923 }
1924
1925 try {
1926 $scope.productFieldType[response.data[i].id][response.data[i].name] = JSON.parse(response.data[i].value);
1927 } catch (e) {
1928 $scope.productFieldType[response.data[i].id][response.data[i].name] = response.data[i].value;
1929 }
1930 }
1931
1932 }, function errorCallback(response) {
1933
1934 });
1935 };
1936
1937 /**
1938 * Get all roles JSON and then set the selected
1939 $http.get('/api/all-roles').then(function(response) {
1940 $scope.roles = response.data.roles;
1941 $scope.productData.role = {
1942 id: $scope.productData.role
1943 }
1944 })
1945 */
1946
1947 // lu lempar dulu ajaxnya baru replace yang baru
1948
1949 if ($routeParams.state != null) {
1950 $q.all(['realProductLoaded']).then(function (data) {
1951 setTimeout(function () {
1952 }, 10);
1953
1954 });
1955 }
1956 // Form Scope
1957 // process the form
1958 $scope.submitFormCompany = function (cat) {
1959
1960 // $scope.insuranceData.roleID = $scope.insuranceData.role.id;
1961 angular.element('.form-actions button').prop('disabled', true);
1962
1963 if ($scope.productData['type'] == 'car') {
1964 switch ($scope.productData['type_of_insurance']) {
1965 case 'comprehensive':
1966 delete $scope.productData['rates']['total_loss_only'];
1967 break;
1968 case 'total_loss_only':
1969 delete $scope.productData['rates']['comprehensive'];
1970 break;
1971 }
1972 }
1973
1974 if ($scope.productData['type'] === 'property') {
1975 if (
1976 ($scope.productData['type_of_insurance'] === 'standard') ||
1977 ($scope.productData['type_of_insurance'] === 'earthquake')
1978 ) {
1979 delete $scope.productData['bundle_rsmd'];
1980 delete $scope.productData['bundle_zone'];
1981 }
1982 }
1983
1984 var data = {
1985 'step' : cat,
1986 'data' : $scope.productData,
1987 'state': $routeParams.state
1988 };
1989
1990
1991 if (cat == 'feature') {
1992 var null_count = 0;
1993 angular.forEach($scope.productData.feature, function (value, key) {
1994 if (key != 'product_id' && key != 'count') {
1995 var value = parseInt(value);
1996 if (value)
1997 null_count++;
1998 }
1999 });
2000 if (null_count < 1) {
2001 swal({
2002 title : 'Are you sure?',
2003 text : 'You have no features in this product, are you sure?',
2004 type : 'warning',
2005 showCancelButton : true,
2006 confirmButtonColor: '#3085d6',
2007 cancelButtonColor : '#d33',
2008 confirmButtonText : 'Yes, continue!',
2009 cancelButtonText : 'No, cancel!',
2010 confirmButtonClass: 'btn btn-success',
2011 cancelButtonClass : 'btn btn-danger'
2012 }, function (isConfirm) {
2013 if (isConfirm) {
2014 $http({
2015 method : 'POST',
2016 url : '/api/insurance/stepper',
2017 data : $.param(data), // pass in data as strings
2018 headers: {
2019 'Content-Type': 'application/x-www-form-urlencoded'
2020 } // set the headers so angular passing info as form data (not request payload)
2021 })
2022 .then(function successCallback(response) {
2023 if (!response.data.success) {
2024 // if not successful, bind errors to error variables
2025 toastr.error('Something went wrong..', 'Whoops');
2026 angular.element('.form-actions button').prop('disabled', false);
2027 } else {
2028 // if successful, bind success message to message
2029 toastr.success('Your perform has been successful', 'Well Done');
2030 $location.path(response.data.redirect);
2031 }
2032 }, function errorCallback(response) {
2033 // if not successful, bind errors to error variables
2034 $scope.required = response.data.required;
2035 toastr.error('Something went wrong..', 'Whoops');
2036 angular.element('.form-actions button').prop('disabled', false);
2037 });
2038 } else {
2039 angular.element('.form-actions button').prop('disabled', false);
2040 }
2041 });
2042 return false;
2043 } else {
2044 $http({
2045 method : 'POST',
2046 url : '/api/insurance/stepper',
2047 data : $.param(data), // pass in data as strings
2048 headers: {
2049 'Content-Type': 'application/x-www-form-urlencoded'
2050 } // set the headers so angular passing info as form data (not request payload)
2051 }).then(function successCallback(response) {
2052 if (!response.data.success) {
2053 // if not successful, bind errors to error variables
2054 toastr.error('Something went wrong..', 'Whoops');
2055 angular.element('.form-actions button').prop('disabled', false);
2056 } else {
2057 // if successful, bind success message to message
2058 toastr.success('Your perform has been successful', 'Well Done');
2059 $location.path(response.data.redirect);
2060 }
2061 }, function errorCallback(response) {
2062 // if not successful, bind errors to error variables
2063 $scope.required = response.data.required;
2064 toastr.error('Something went wrong..', 'Whoops');
2065 angular.element('.form-actions button').prop('disabled', false);
2066 });
2067 }
2068 } else {
2069 $http({
2070 method : 'POST',
2071 url : '/api/insurance/stepper',
2072 data : $.param(data), // pass in data as strings
2073 headers: {
2074 'Content-Type': 'application/x-www-form-urlencoded'
2075 } // set the headers so angular passing info as form data (not request payload)
2076 })
2077 .then(function successCallback(response) {
2078 if (!response.data.success) {
2079 // if not successful, bind errors to error variables
2080 toastr.error('Something went wrong..', 'Whoops');
2081 angular.element('.form-actions button').prop('disabled', false);
2082 } else {
2083
2084 try {
2085 // if successful, bind success message to message
2086 toastr.success('Your perform has been successful', 'Well Done');
2087
2088 if (
2089 ($scope.productData['type'] === 'property') ||
2090 ($scope.productData['slug_type'] === 'property')
2091 ) {
2092 if ($scope.productData['type_of_insurance'] === 'all_risk') {
2093 // category, detail, additional
2094 if (
2095 (cat !== 'category') &&
2096 (cat !== 'additional') &&
2097 (cat !== 'questionnaire') &&
2098 (cat !== 'brief') &&
2099 (cat !== 'partnership') &&
2100 (cat !== 'summary')) {
2101 if (
2102 (
2103 $scope.productData['bundle_zone'] === true ||
2104 $scope.productData['bundle_zone'] === 'true' ||
2105 $scope.productData['bundle_zone'] === '1' ||
2106 $scope.productData['bundle_zone'] === 1
2107 ) &&
2108 (
2109 $scope.productData['bundle_rsmd'] === true ||
2110 $scope.productData['bundle_rsmd'] === 'true' ||
2111 $scope.productData['bundle_rsmd'] === '1' ||
2112 $scope.productData['bundle_rsmd'] === 1
2113 )
2114 ) {
2115 return $window.location.href = '/management#!/insurance/' + $scope.productData.slug + '/product/' + $scope.productData.slug_type + '/' + $scope.productData.slug_product + '/feature/' + $scope.state + '';
2116 }
2117 }
2118 }
2119 }
2120
2121 $location.path(response.data.redirect);
2122 }
2123 catch (error) {
2124 (MyObj.showError()) ? console.log(error) : '';
2125 }
2126
2127 }
2128 }, function errorCallback(response) {
2129 // if not successful, bind errors to error variables
2130 $scope.required = response.data.required;
2131 toastr.error('Something went wrong..', 'Whoops');
2132 angular.element('.form-actions button').prop('disabled', false);
2133 });
2134 }
2135 };
2136
2137 $scope.appendTravel = function (category) {
2138 if (category == 'domestic') {
2139 var last_key = 0;
2140 var last_days = 0;
2141 angular.forEach($scope.productData['rates']['domestic'], function (value, key) {
2142 if (key != 'extra_one_person' && key != 'extra_two_person' && key != 'extra_three_person' && key != 'extra_four_person' && key != 'extra_five_person' && key != '0') {
2143 last_key = parseInt(key);
2144 last_days = parseInt(value.days_min);
2145 }
2146 });
2147
2148 last_days = last_days + 1;
2149
2150 last_key = last_key + 1;
2151
2152 $scope.travel_domestic.push('new');
2153
2154 $scope.productData['rates']['domestic'][last_key] = {
2155 days_min: last_days
2156 };
2157 }
2158 if (category == 'asean') {
2159 var last_key = 0;
2160 var last_days = 0;
2161 angular.forEach($scope.productData['rates']['asean'], function (value, key) {
2162 if (key != 'extra_one_person' && key != 'extra_two_person' && key != 'extra_three_person' && key != 'extra_four_person' && key != 'extra_five_person' && key != '0') {
2163 last_key = parseInt(key);
2164 last_days = parseInt(value.days_min);
2165 }
2166 });
2167
2168 last_days = last_days + 1;
2169
2170 last_key = last_key + 1;
2171
2172 $scope.travel_asean.push('new');
2173
2174 $scope.productData['rates']['asean'][last_key] = {
2175 days_min: last_days
2176 };
2177 }
2178 if (category == 'asia') {
2179 var last_key = 0;
2180 var last_days = 0;
2181 angular.forEach($scope.productData['rates']['asia'], function (value, key) {
2182 if (key != 'extra_one_person' && key != 'extra_two_person' && key != 'extra_three_person' && key != 'extra_four_person' && key != 'extra_five_person' && key != '0') {
2183 last_key = parseInt(key);
2184 last_days = parseInt(value.days_min);
2185 }
2186 });
2187
2188 last_days = last_days + 1;
2189
2190 last_key = last_key + 1;
2191
2192 $scope.travel_asia.push('new');
2193
2194 $scope.productData['rates']['asia'][last_key] = {
2195 days_min: last_days
2196 };
2197 }
2198 if (category == 'wwis') {
2199 var last_key = 0;
2200 var last_days = 0;
2201 angular.forEach($scope.productData['rates']['wwis'], function (value, key) {
2202 if (key != 'extra_one_person' && key != 'extra_two_person' && key != 'extra_three_person' && key != 'extra_four_person' && key != 'extra_five_person' && key != '0') {
2203 last_key = parseInt(key);
2204 last_days = parseInt(value.days_min);
2205 }
2206 });
2207
2208 last_days = last_days + 1;
2209
2210 last_key = last_key + 1;
2211
2212 $scope.travel_wwis.push('new');
2213
2214 $scope.productData['rates']['wwis'][last_key] = {
2215 days_min: last_days
2216 };
2217 }
2218 if (category == 'wwes') {
2219 var last_key = 0;
2220 var last_days = 0;
2221 angular.forEach($scope.productData['rates']['wwes'], function (value, key) {
2222 if (key != 'extra_one_person' && key != 'extra_two_person' && key != 'extra_three_person' && key != 'extra_four_person' && key != 'extra_five_person' && key != '0') {
2223 last_key = parseInt(key);
2224 last_days = parseInt(value.days_min);
2225 }
2226 });
2227
2228 last_days = last_days + 1;
2229
2230 last_key = last_key + 1;
2231
2232 $scope.travel_wwes.push('new');
2233
2234 $scope.productData['rates']['wwes'][last_key] = {
2235 days_min: last_days
2236 };
2237 }
2238 };
2239
2240 $scope.submitFinal = function (url) {
2241 // $scope.insuranceData.roleID = $scope.insuranceData.role.id;
2242 // endpoint info
2243 // /api/insurance/product/save-product-by-category <-- save product di step 1
2244 // /api/insurance/product/save-product-by-rates <-- save product di step 2
2245 // /api/insurance/product/save-product-by-feature <-- save product di step 3
2246 // /api/insurance/product/save-product-by-questionnaire <-- save product di step 4
2247 $http({
2248 method : 'POST',
2249 url : url,
2250 data : $.param($scope.productData), // pass in data as strings
2251 headers: {
2252 'Content-Type': 'application/x-www-form-urlencoded'
2253 } // set the headers so angular passing info as form data (not request payload)
2254 }).then(function successCallback(response) {
2255 if (!response.data.success) {
2256 // if not successful, bind errors to error variables
2257 toastr.error('Something went wrong..', 'Whoops');
2258 } else {
2259 // if successful, bind success message to message
2260 toastr.success('Your perform has been successful', 'Well Done');
2261 $location.path(response.data.redirect);
2262 }
2263 }, function errorCallback(response) {
2264 // if not successful, bind errors to error variables
2265 $scope.required = response.data.required;
2266 toastr.error('Something went wrong..', 'Whoops');
2267 });
2268 };
2269
2270 $scope.ratesUpload = function (file, cat) {
2271 Upload.upload({
2272 url : '/api/insurance/rate/excel/upload/' + cat,
2273 method: 'POST',
2274 data : {
2275 file: file
2276 }
2277 }).then(function (response) {
2278 if ($routeParams.slugType == 'travel') {
2279 if (response.data.status == 'empty') {
2280 toastr.error('there is an empty value on your excel, please fill all values');
2281 } else {
2282 $scope.productData['rates'] = response.data;
2283
2284 var last_key = 0;
2285 $scope.travel_domestic = [];
2286 $scope.travel_asean = [];
2287 $scope.travel_asia = [];
2288 $scope.travel_wwis = [];
2289 $scope.travel_wwes = [];
2290 angular.forEach($scope.productData['rates']['domestic'], function (value, key) {
2291 var integer_key = parseInt(key);
2292 if (!isNaN(integer_key)) {
2293 $scope.travel_domestic.push('new');
2294 }
2295 });
2296 // if($scope.travel_domestic.length>1){
2297 // $scope.travel_domestic.splice(-1,1); // remove the last
2298 // }
2299
2300 angular.forEach($scope.productData['rates']['asean'], function (value, key) {
2301 var integer_key = parseInt(key);
2302 if (!isNaN(integer_key)) {
2303 $scope.travel_asean.push('new');
2304 }
2305 });
2306
2307 // if($scope.travel_asean.length>1){
2308 // $scope.travel_asean.splice(-1,1); // remove the last
2309 // }
2310
2311 angular.forEach($scope.productData['rates']['asia'], function (value, key) {
2312 var integer_key = parseInt(key);
2313 if (!isNaN(integer_key)) {
2314 $scope.travel_asia.push('new');
2315 }
2316 });
2317
2318 // if($scope.travel_asean.length>1){
2319 // $scope.travel_asean.splice(-1,1); // remove the last
2320 // }
2321
2322 angular.forEach($scope.productData['rates']['wwis'], function (value, key) {
2323 var integer_key = parseInt(key);
2324 if (!isNaN(integer_key)) {
2325 $scope.travel_wwis.push('new');
2326 }
2327 });
2328
2329 // if($scope.travel_wwis.length>1){
2330 // $scope.travel_wwis.splice(-1,1); // remove the last
2331 // }
2332
2333 angular.forEach($scope.productData['rates']['wwes'], function (value, key) {
2334 var integer_key = parseInt(key);
2335 if (!isNaN(integer_key)) {
2336 $scope.travel_wwes.push('new');
2337 }
2338 });
2339
2340 // if($scope.travel_wwes.length>1){
2341 // $scope.travel_wwes.splice(-1,1); // remove the last
2342 // }
2343 }
2344 }
2345
2346 if ($routeParams.slugType == 'health') {
2347 if (response.data.status == 'empty') {
2348 toastr.error('there is an empty value on your excel, please fill all values');
2349 } else {
2350 $scope.life_repeat = [];
2351 $scope.life_others_repeat = [];
2352 $scope.life_childrens_repeat = [];
2353 $scope.productData['rates'] = response.data[0];
2354 $scope.productData['others'] = response.data[1];
2355 $scope.productData['childrens'] = response.data[2];
2356
2357 var rates_length = $scope.productData['rates'].length;
2358 var others_length = $scope.productData['others'].length;
2359 var childrens_length = $scope.productData['childrens'].length;
2360
2361 if (rates_length > 1) {
2362 for (var i = 0; i < rates_length; i++) {
2363 $scope.life_repeat.push('new');
2364 }
2365 }
2366
2367 if (others_length > 1) {
2368 for (var i = 0; i < others_length; i++) {
2369 $scope.life_others_repeat.push('new');
2370 }
2371 }
2372
2373 if (childrens_length > 1) {
2374 for (var i = 0; i < childrens_length; i++) {
2375 $scope.life_childrens_repeat.push('new');
2376 }
2377 }
2378 }
2379 }
2380
2381 if ($routeParams.slugType == 'life') {
2382 if (response.data.status == 'empty') {
2383 toastr.error('there is an empty value on your excel, please fill all values');
2384 } else {
2385 $scope.life_repeat = [];
2386 $scope.life_others_repeat = [];
2387 $scope.life_childrens_repeat = [];
2388 $scope.productData['rates'] = response.data[0];
2389 $scope.productData['others'] = response.data[1];
2390 $scope.productData['childrens'] = response.data[2];
2391
2392 var rates_length = $scope.productData['rates'].length;
2393 var others_length = $scope.productData['others'].length;
2394 var childrens_length = $scope.productData['childrens'].length;
2395
2396 if (rates_length > 1) {
2397 for (var i = 0; i < rates_length; i++) {
2398 $scope.life_repeat.push('new');
2399 }
2400 }
2401
2402 if (others_length > 1) {
2403 for (var i = 0; i < others_length; i++) {
2404 $scope.life_others_repeat.push('new');
2405 }
2406 }
2407
2408 if (childrens_length > 1) {
2409 for (var i = 0; i < childrens_length; i++) {
2410 $scope.life_childrens_repeat.push('new');
2411 }
2412 }
2413 }
2414 }
2415
2416 if ($routeParams.slugType == 'personal-accident-age') {
2417 if (response.data.status == 'empty') {
2418 toastr.error('there is an empty value on your excel, please fill all values');
2419 } else {
2420 $scope.life_repeat = [];
2421 $scope.life_others_repeat = [];
2422 $scope.productData['rates'] = response.data[0];
2423 $scope.productData['couple'] = response.data[1];
2424
2425 var rates_length = $scope.productData['rates'].length;
2426 var others_length = $scope.productData['couple'].length;
2427
2428 if (rates_length > 1) {
2429 for (var i = 0; i < rates_length; i++) {
2430 $scope.life_repeat.push('new');
2431 }
2432 }
2433
2434 if (others_length > 1) {
2435 for (var i = 0; i < others_length; i++) {
2436 $scope.life_others_repeat.push('new');
2437 }
2438 }
2439 }
2440 }
2441
2442 if ($routeParams.slugType == 'personal-accident-sum-insured') {
2443 if (response.data.status == 'empty') {
2444 toastr.error('there is an empty value on your excel, please fill all values');
2445 } else {
2446 $scope.life_repeat = [];
2447 $scope.life_others_repeat = [];
2448 $scope.productData['rates'] = response.data[0];
2449 // console.log($scope.productData['rates']);
2450 var rates_length = $scope.productData['rates'].length;
2451
2452 if (rates_length > 1) {
2453 for (var i = 0; i < rates_length; i++) {
2454 $scope.life_repeat.push('new');
2455 // console.log($scope.life_repeat.push('new'));
2456 }
2457 }
2458 }
2459 }
2460
2461 toastr.success('Your file has been successfully uploaded');
2462 });
2463 };
2464
2465 /*
2466 * property stuff
2467 *
2468 * */
2469 let MyObj = {
2470 disabled : false,
2471 allType : 'all_risk',
2472 standardType : 'standard',
2473 earthquakeType : 'earthquake',
2474 checkOverrideAll : checkOverrideAll,
2475 checkOverrideStandard : checkOverrideStandard,
2476 checkOverrideEarthquake : checkOverrideEarthquake,
2477 checkDisabledAllType : checkDisabledAllType,
2478 checkDisabledStandardType : checkDisabledStandardType,
2479 checkDisabledEarthquakeType: checkDisabledEarthquakeType,
2480 showError : (val = false) => {
2481 return val;
2482 }
2483 };
2484
2485 $scope.checkOverride = checkOverride;
2486 $scope.checkDisabled = checkDisabled;
2487 $scope.removeAnnualOption = removeAnnualOption;
2488 $scope.removeExtraOption = removeExtraOption;
2489 $scope.checkDisabledEarthquake = checkDisabledEarthquake;
2490 $scope.toggleBundle = toggleBundle;
2491
2492 activate();
2493
2494 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2495
2496 function activate() {
2497
2498 $scope.productData['bundle_zone'] = (!_.isUndefined($scope.productData['bundle_zone'])) ? $scope.productData['bundle_zone'] : 1;
2499 $scope.productData['bundle_rsmd'] = (!_.isUndefined($scope.productData['bundle_rsmd'])) ? $scope.productData['bundle_rsmd'] : 1;
2500
2501 // $scope.productData['bundle_zone'] = 1;
2502 // $scope.productData['bundle_rsmd'] = 1;
2503 }
2504
2505 function checkOverride(product, questionKey, subKey = 0) {
2506 // try {
2507 // if (product['type_of_insurance'] === MyObj.allType) {
2508 // MyObj.checkOverrideAll(product, questionKey);
2509 // } else if (product['type_of_insurance'] === MyObj.standardType) {
2510 // MyObj.checkOverrideStandard(product, questionKey);
2511 // } else if (product['type_of_insurance'] === MyObj.earthquakeType) {
2512 // MyObj.checkOverrideEarthquake(product, questionKey, subKey);
2513 // }
2514 // }
2515 // catch (error) {
2516 // (MyObj.showError()) ? console.log(error) : '';
2517 // }
2518 }
2519
2520 function checkDisabled(type, questionKey) {
2521 let disabled = MyObj.disabled;
2522 try {
2523 disabled = (type === MyObj.allType)
2524 ? MyObj.checkDisabledAllType(questionKey)
2525 : (type === MyObj.standardType) ? MyObj.checkDisabledStandardType(questionKey) : false;
2526 }
2527 catch (error) {
2528 (MyObj.showError(true)) ? console.log(error) : '';
2529 }
2530
2531 return disabled;
2532 }
2533
2534 function removeAnnualOption(typs) {
2535 let types = ['one_person', 'two_person', 'three_person', 'four_person', 'five_person'];
2536
2537 for (let i = 0; i < types.length; i++) {
2538 $scope.productData['rates'][typs]['annual'][types[i]] = null;
2539 }
2540 }
2541
2542 function removeExtraOption(typs) {
2543 let types = ['one_person', 'two_person', 'three_person', 'four_person', 'five_person'];
2544 $scope.productData['rates'][typs]['extra'] = null;
2545 // console.log($scope.productData['rates']);
2546 for (let i = 0; i < types.length; i++) {
2547 $scope.productData['rates'][typs]['extra_price_' + types[i]] = null;
2548 }
2549 }
2550
2551 function checkDisabledEarthquake(type, questionKey, subKey = 0) {
2552 let disabled = MyObj.disabled;
2553 try {
2554 disabled = (type === MyObj.earthquakeType)
2555 ? MyObj.checkDisabledEarthquakeType(questionKey, subKey)
2556 : false;
2557 }
2558 catch (error) {
2559 (MyObj.showError()) ? console.log(error) : '';
2560 }
2561
2562 return disabled;
2563 }
2564
2565 function toggleBundle() {
2566 if (
2567 (
2568 $scope.productData['bundle_zone'] === true ||
2569 $scope.productData['bundle_zone'] === 'true' ||
2570 $scope.productData['bundle_zone'] === 1 ||
2571 $scope.productData['bundle_zone'] === '1'
2572 )
2573 &&
2574 (
2575 $scope.productData['bundle_rsmd'] === true ||
2576 $scope.productData['bundle_rsmd'] === 'true' ||
2577 $scope.productData['bundle_rsmd'] === 1 ||
2578 $scope.productData['bundle_rsmd'] === '1'
2579 )
2580 ) {
2581 return true;
2582 } else {
2583 return false;
2584 }
2585 }
2586
2587 function checkOverrideAll(product, key) {
2588 try {
2589 if (product['rates']['all'][key]['custom'] > 0) {
2590 $scope.productData['rates']['all'][key]['custom'] = product['rates']['all'][key]['custom'];
2591 }
2592
2593 if (
2594 (_.isNumber(product['rates']['all'][key]['custom']))
2595 || (_.isString(product['rates']['all'][key]['custom']))
2596 ) {
2597 let custom = ['custom_one', 'custom_two', 'custom_three'], y = 1;
2598 try {
2599 for (let x = 0; x < custom.length; x++) {
2600 $scope.productData['rates']['all'][key][y] = 'custom';
2601 $scope.productData['rates']['all'][key][custom[x]] = 0;
2602 y++;
2603 }
2604 }
2605 catch (error) {
2606 (MyObj.showError()) ? console.log(error) : '';
2607 }
2608 } else if (_.isUndefined(product['rates']['all'][key]['custom'])) {
2609 let custom = ['custom_one', 'custom_two', 'custom_three'], y = 1;
2610 try {
2611 for (let x = 0; x < custom.length; x++) {
2612 if (product['rates']['all'][key][y] === 'top') {
2613 $scope.productData['rates']['all'][key][y] = 'top';
2614 $scope.productData['rates']['all'][key][custom[x]] = void 0;
2615 } else if (product['rates']['all'][key][y] === 'bottom') {
2616 $scope.productData['rates']['all'][key][y] = 'bottom';
2617 $scope.productData['rates']['all'][key][custom[x]] = void 0;
2618 } else if (product['rates']['all'][key][y] === 'custom') {
2619 if (
2620 ($scope.productData['rates']['all'][key][custom[x]] === 0)
2621 || ($scope.productData['rates']['all'][key][custom[x]] === '0')
2622 ) {
2623 $scope.productData['rates']['all'][key][y] = 'top';
2624 $scope.productData['rates']['all'][key][custom[x]] = void 0;
2625 } else {
2626 $scope.productData['rates']['all'][key][y] = 'custom';
2627 $scope.productData['rates']['all'][key][custom[x]] = product['rates']['all'][key][custom[x]];
2628 }
2629 } else {
2630 $scope.productData['rates']['all'][key][y] = 'custom';
2631 $scope.productData['rates']['all'][key][custom[x]] = product['rates']['all'][key][custom[x]];
2632 }
2633 y++;
2634 }
2635 }
2636 catch (error) {
2637 (MyObj.showError()) ? console.log(error) : '';
2638 }
2639 }
2640 }
2641 catch (error) {
2642 (MyObj.showError()) ? console.log(error) : '';
2643 }
2644 }
2645
2646 function checkOverrideStandard(product, key) {
2647 try {
2648 if (product['rates']['standard'][key]['custom'] > 0) {
2649 $scope.productData['rates']['standard'][key]['custom'] = product['rates']['standard'][key]['custom'];
2650 }
2651
2652 if (
2653 (_.isNumber(product['rates']['standard'][key]['custom']))
2654 || (_.isString(product['rates']['standard'][key]['custom']))
2655 ) {
2656 let custom = ['custom_one', 'custom_two', 'custom_three'], y = 1;
2657 try {
2658 for (let x = 0; x < custom.length; x++) {
2659 $scope.productData['rates']['standard'][key][y] = 'custom';
2660 $scope.productData['rates']['standard'][key][custom[x]] = 0;
2661 y++;
2662 }
2663 }
2664 catch (error) {
2665 (MyObj.showError()) ? console.log(error) : '';
2666 }
2667 } else if (_.isUndefined(product['rates']['standard'][key]['custom'])) {
2668 let custom = ['custom_one', 'custom_two', 'custom_three'], y = 1;
2669 try {
2670 for (let x = 0; x < custom.length; x++) {
2671 if (product['rates']['standard'][key][y] === 'top') {
2672 $scope.productData['rates']['standard'][key][y] = 'top';
2673 $scope.productData['rates']['standard'][key][custom[x]] = void 0;
2674 } else if (product['rates']['standard'][key][y] === 'bottom') {
2675 $scope.productData['rates']['standard'][key][y] = 'bottom';
2676 $scope.productData['rates']['standard'][key][custom[x]] = void 0;
2677 } else if (product['rates']['standard'][key][y] === 'custom') {
2678 if (
2679 ($scope.productData['rates']['standard'][key][custom[x]] === 0)
2680 || ($scope.productData['rates']['standard'][key][custom[x]] === '0')
2681 ) {
2682 $scope.productData['rates']['standard'][key][y] = 'top';
2683 $scope.productData['rates']['standard'][key][custom[x]] = void 0;
2684 } else {
2685 $scope.productData['rates']['standard'][key][y] = 'custom';
2686 $scope.productData['rates']['standard'][key][custom[x]] = product['rates']['standard'][key][custom[x]];
2687 }
2688 } else {
2689 $scope.productData['rates']['standard'][key][y] = 'top';
2690 $scope.productData['rates']['standard'][key][custom[x]] = void 0;
2691 }
2692 y++;
2693 }
2694 }
2695 catch (error) {
2696 (MyObj.showError()) ? console.log(error) : '';
2697 }
2698 }
2699 }
2700 catch (error) {
2701 (MyObj.showError()) ? console.log(error) : '';
2702 }
2703 }
2704
2705 function checkOverrideEarthquake(product, keyFirst, keySecond) {
2706 try {
2707 if (product['rates']['earthquake'][keyFirst][keySecond]['custom'] > 0) {
2708 $scope.productData['rates']['earthquake'][keyFirst][keySecond]['custom'] = product['rates']['earthquake'][keyFirst][keySecond]['custom'];
2709 }
2710
2711 if (
2712 (_.isNumber(product['rates']['earthquake'][keyFirst][keySecond]['custom']))
2713 || (_.isString(product['rates']['earthquake'][keyFirst][keySecond]['custom']))
2714 ) {
2715
2716 if (
2717 ((keyFirst === 1) && (keySecond === 1))
2718 || ((keyFirst === 2) && (keySecond === 1))
2719 ) {
2720 let custom = ['custom_one', 'custom_two', 'custom_three', 'custom_four', 'custom_five'], y = 1;
2721 try {
2722 for (let x = 0; x < custom.length; x++) {
2723 $scope.productData['rates']['earthquake'][keyFirst][keySecond][y] = 'custom';
2724 $scope.productData['rates']['earthquake'][keyFirst][keySecond][custom[x]] = 0;
2725 y++;
2726 }
2727 }
2728 catch (error) {
2729 (MyObj.showError()) ? console.log(error) : '';
2730 }
2731 }
2732 } else if (_.isUndefined(product['rates']['earthquake'][keyFirst][keySecond]['custom'])) {
2733 if (
2734 ((keyFirst === 1) && (keySecond === 1))
2735 || ((keyFirst === 2) && (keySecond === 1))
2736 ) {
2737 let custom = ['custom_one', 'custom_two', 'custom_three', 'custom_four', 'custom_five'], y = 1;
2738 try {
2739 for (let x = 0; x < custom.length; x++) {
2740 if (product['rates']['earthquake'][keyFirst][keySecond][y] === 'fixed') {
2741 $scope.productData['rates']['earthquake'][keyFirst][keySecond][y] = 'fixed';
2742 $scope.productData['rates']['earthquake'][keyFirst][keySecond][custom[x]] = void 0;
2743 } else if (product['rates']['earthquake'][keyFirst][keySecond][y] === 'custom') {
2744 if (
2745 ($scope.productData['rates']['earthquake'][key][custom[x]] === 0)
2746 || ($scope.productData['rates']['earthquake'][key][custom[x]] === '0')
2747 ) {
2748 $scope.productData['rates']['earthquake'][keyFirst][keySecond][y] = 'fixed';
2749 $scope.productData['rates']['earthquake'][keyFirst][keySecond][custom[x]] = void 0;
2750 } else {
2751 $scope.productData['rates']['earthquake'][keyFirst][keySecond][y] = 'custom';
2752 $scope.productData['rates']['earthquake'][keyFirst][keySecond][custom[x]] = product['rates']['earthquake'][keyFirst][keySecond][custom[x]];
2753 }
2754 } else {
2755 $scope.productData['rates']['earthquake'][keyFirst][keySecond][y] = 'fixed';
2756 $scope.productData['rates']['earthquake'][keyFirst][keySecond][custom[x]] = void 0;
2757 }
2758 y++;
2759 }
2760 }
2761 catch (error) {
2762 (MyObj.showError()) ? console.log(error) : '';
2763 }
2764 }
2765 }
2766 }
2767 catch (error) {
2768 (MyObj.showError()) ? console.log(error) : '';
2769 }
2770 }
2771
2772 function checkDisabledAllType(questionKey) {
2773 let disabled = MyObj.disabled;
2774 try {
2775 if (!_.isUndefined($scope.productData['rates'])) {
2776 if (questionKey === 1) {
2777 try {
2778 if (
2779 (!_.isUndefined($scope.productData['rates']['all'][1]['custom']))
2780 && (!_.isNull($scope.productData['rates']['all'][1]['custom']))
2781 && ($scope.productData['rates']['all'][1]['custom'] >= 0)
2782 // && ($scope.productData['rates']['all'][1]['custom'] !== '')
2783 ) {
2784 disabled = (questionKey === 1);
2785 }
2786 }
2787 catch (error) {
2788 (MyObj.showError()) ? console.log(error) : '';
2789 }
2790 }
2791 else if (questionKey === 2) {
2792 try {
2793 if (
2794 (!_.isUndefined($scope.productData['rates']['all'][2]['custom']))
2795 && (!_.isNull($scope.productData['rates']['all'][2]['custom']))
2796 && ($scope.productData['rates']['all'][2]['custom'] >= 0)
2797 // && ($scope.productData['rates']['all'][2]['custom'] !== '')
2798 ) {
2799 disabled = (questionKey === 2);
2800 }
2801 }
2802 catch (error) {
2803 (MyObj.showError()) ? console.log(error) : '';
2804 }
2805 }
2806 else if (questionKey === 3) {
2807 try {
2808 if (
2809 (!_.isUndefined($scope.productData['rates']['all'][3]['custom']))
2810 && (!_.isNull($scope.productData['rates']['all'][3]['custom']))
2811 && ($scope.productData['rates']['all'][3]['custom'] >= 0)
2812 // && ($scope.productData['rates']['all'][3]['custom'] !== '')
2813 ) {
2814 disabled = (questionKey === 3);
2815 }
2816 }
2817 catch (error) {
2818 (MyObj.showError()) ? console.log(error) : '';
2819 }
2820 }
2821 else if (questionKey === 4) {
2822 try {
2823 if (
2824 (!_.isUndefined($scope.productData['rates']['all'][4]['custom']))
2825 && (!_.isNull($scope.productData['rates']['all'][4]['custom']))
2826 && ($scope.productData['rates']['all'][4]['custom'] >= 0)
2827 // && ($scope.productData['rates']['all'][4]['custom'] !== '')
2828 ) {
2829 disabled = (questionKey === 4);
2830 }
2831 }
2832 catch (error) {
2833 (MyObj.showError()) ? console.log(error) : '';
2834 }
2835 }
2836 else if (questionKey === 5) {
2837 try {
2838 if (
2839 (!_.isUndefined($scope.productData['rates']['all'][5]['custom']))
2840 && (!_.isNull($scope.productData['rates']['all'][5]['custom']))
2841 && ($scope.productData['rates']['all'][5]['custom'] >= 0)
2842 // && ($scope.productData['rates']['all'][5]['custom'] !== '')
2843 ) {
2844 disabled = (questionKey === 5);
2845 }
2846 }
2847 catch (error) {
2848 (MyObj.showError()) ? console.log(error) : '';
2849 }
2850 }
2851 else if (questionKey === 6) {
2852 try {
2853 if (
2854 (!_.isUndefined($scope.productData['rates']['all'][6]['custom']))
2855 && (!_.isNull($scope.productData['rates']['all'][6]['custom']))
2856 && ($scope.productData['rates']['all'][6]['custom'] >= 0)
2857 // && ($scope.productData['rates']['all'][6]['custom'] !== '')
2858 ) {
2859 disabled = (questionKey === 6);
2860 }
2861 }
2862 catch (error) {
2863 (MyObj.showError()) ? console.log(error) : '';
2864 }
2865 }
2866 else if (questionKey === 7) {
2867 try {
2868 if (
2869 (!_.isUndefined($scope.productData['rates']['all'][7]['custom']))
2870 && (!_.isNull($scope.productData['rates']['all'][7]['custom']))
2871 && ($scope.productData['rates']['all'][7]['custom'] >= 0)
2872 // && ($scope.productData['rates']['all'][7]['custom'] !== '')
2873 ) {
2874 disabled = (questionKey === 7);
2875 }
2876 }
2877 catch (error) {
2878 (MyObj.showError()) ? console.log(error) : '';
2879 }
2880 }
2881 }
2882 }
2883 catch (error) {
2884 (MyObj.showError()) ? console.log(error) : '';
2885 }
2886
2887 return disabled;
2888 }
2889
2890 function checkDisabledStandardType(questionKey) {
2891 let disabled = MyObj.disabled;
2892 try {
2893 if (questionKey === 1) {
2894 try {
2895 if (
2896 (!_.isUndefined($scope.productData['rates']['standard'][1]['custom']))
2897 && (!_.isNull($scope.productData['rates']['standard'][1]['custom']))
2898 && ($scope.productData['rates']['standard'][1]['custom'] >= 0)
2899 // && ($scope.productData['rates']['standard'][1]['custom'] !== '')
2900 ) {
2901 disabled = (questionKey === 1);
2902 }
2903 }
2904 catch (error) {
2905 (MyObj.showError()) ? console.log(error) : '';
2906 }
2907 }
2908 else if (questionKey === 2) {
2909 try {
2910 if (
2911 (!_.isUndefined($scope.productData['rates']['standard'][2]['custom']))
2912 && (!_.isNull($scope.productData['rates']['standard'][2]['custom']))
2913 && ($scope.productData['rates']['standard'][2]['custom'] >= 0)
2914 // && ($scope.productData['rates']['standard'][2]['custom'] !== '')
2915 ) {
2916 disabled = (questionKey === 2);
2917 }
2918 }
2919 catch (error) {
2920 (MyObj.showError()) ? console.log(error) : '';
2921 }
2922 }
2923 else if (questionKey === 3) {
2924 try {
2925 if (
2926 (!_.isUndefined($scope.productData['rates']['standard'][3]['custom']))
2927 && (!_.isNull($scope.productData['rates']['standard'][3]['custom']))
2928 && ($scope.productData['rates']['standard'][3]['custom'] >= 0)
2929 // && ($scope.productData['rates']['standard'][3]['custom'] !== '')
2930 ) {
2931 disabled = (questionKey === 3);
2932 }
2933 }
2934 catch (error) {
2935 (MyObj.showError()) ? console.log(error) : '';
2936 }
2937 }
2938 else if (questionKey === 4) {
2939 try {
2940 if (
2941 (!_.isUndefined($scope.productData['rates']['standard'][4]['custom']))
2942 && (!_.isNull($scope.productData['rates']['standard'][4]['custom']))
2943 && ($scope.productData['rates']['standard'][4]['custom'] >= 0)
2944 // && ($scope.productData['rates']['standard'][4]['custom'] !== '')
2945 ) {
2946 disabled = (questionKey === 4);
2947 }
2948 }
2949 catch (error) {
2950 (MyObj.showError()) ? console.log(error) : '';
2951 }
2952 }
2953 else if (questionKey === 5) {
2954 try {
2955 if (
2956 (!_.isUndefined($scope.productData['rates']['standard'][5]['custom']))
2957 && (!_.isNull($scope.productData['rates']['standard'][5]['custom']))
2958 && ($scope.productData['rates']['standard'][5]['custom'] >= 0)
2959 // && ($scope.productData['rates']['standard'][5]['custom'] !== '')
2960 ) {
2961 disabled = (questionKey === 5);
2962 }
2963 }
2964 catch (error) {
2965 (MyObj.showError()) ? console.log(error) : '';
2966 }
2967 }
2968 else if (questionKey === 6) {
2969 try {
2970 if (
2971 (!_.isUndefined($scope.productData['rates']['standard'][6]['custom']))
2972 && (!_.isNull($scope.productData['rates']['standard'][6]['custom']))
2973 && ($scope.productData['rates']['standard'][6]['custom'] >= 0)
2974 // && ($scope.productData['rates']['standard'][6]['custom'] !== '')
2975 ) {
2976 disabled = (questionKey === 6);
2977 }
2978 }
2979 catch (error) {
2980 (MyObj.showError()) ? console.log(error) : '';
2981 }
2982 }
2983 else if (questionKey === 7) {
2984 try {
2985 if (
2986 (!_.isUndefined($scope.productData['rates']['standard'][7]['custom']))
2987 && (!_.isNull($scope.productData['rates']['standard'][7]['custom']))
2988 && ($scope.productData['rates']['standard'][7]['custom'] >= 0)
2989 // && ($scope.productData['rates']['standard'][7]['custom'] !== '')
2990 ) {
2991 disabled = (questionKey === 7);
2992 }
2993 }
2994 catch (error) {
2995 (MyObj.showError()) ? console.log(error) : '';
2996 }
2997 }
2998 }
2999 catch (error) {
3000 (MyObj.showError()) ? console.log(error) : '';
3001 }
3002
3003 return disabled;
3004 }
3005
3006 function checkDisabledEarthquakeType(questionKey, subKey) {
3007 let disabled = MyObj.disabled;
3008 try {
3009 if ((questionKey === 1) && (subKey === 1)) {
3010 try {
3011 if (
3012 (!_.isUndefined($scope.productData['rates']['earthquake'][1][1]['custom']))
3013 && (!_.isNull($scope.productData['rates']['earthquake'][1][1]['custom']))
3014 && ($scope.productData['rates']['earthquake'][1][1]['custom'] >= 0 )
3015 // && ($scope.productData['rates']['earthquake'][1][1]['custom'] !== '')
3016 ) {
3017 disabled = ((questionKey === 1) && (subKey === 1));
3018 }
3019 }
3020 catch (error) {
3021 (MyObj.showError()) ? console.log(error) : '';
3022 }
3023 } else if ((questionKey === 2) && (subKey === 1)) {
3024 try {
3025 if (
3026 (!_.isUndefined($scope.productData['rates']['earthquake'][2][1]['custom']))
3027 && (!_.isNull($scope.productData['rates']['earthquake'][2][1]['custom']))
3028 && ($scope.productData['rates']['earthquake'][2][1]['custom'] >= 0)
3029 // && ($scope.productData['rates']['earthquake'][2][1]['custom'] !== '')
3030 ) {
3031 disabled = ((questionKey === 2) && (subKey === 1));
3032 }
3033 }
3034 catch (error) {
3035 (MyObj.showError()) ? console.log(error) : '';
3036 }
3037 }
3038 }
3039 catch (error) {
3040 (MyObj.showError()) ? console.log(error) : '';
3041 }
3042
3043 return disabled;
3044 }
3045}