· 6 years ago · Sep 03, 2019, 11:20 AM
1import { PricingPage } from './../pricing/pricing';
2//(C) Copyright International Business Machines Corporation, 2015, 2018
3import { Component, ViewEncapsulation, NgZone , ChangeDetectorRef} from '@angular/core';
4import { IonicPage, NavController, NavParams , LoadingController,AlertController } from 'ionic-angular';
5import { AppStateProvider } from '../../providers/app-state/app-state';
6import { DetailPage } from '../detail/detail';
7import { RetrivenonautodiscountProvider } from '../../providers/retrivenonautodiscount/retrivenonautodiscount';
8import { QuoteService } from '../../providers/quote-service';
9import { SelectedsbclistProvider } from '../../providers/selectedsbclist/selectedsbclist';
10import { DomSanitizer} from '@angular/platform-browser';
11import { ViewquotesPage } from '../viewquotes/viewquotes';
12import { NativePageTransitions, NativeTransitionOptions } from '@ionic-native/native-page-transitions';
13import { HomePage } from '../home/home';
14import { Keyboard } from '@ionic-native/keyboard';
15import { UserData } from '../../providers/user-data';
16
17/**
18 * Generated class for the PriceRequestPage page.
19 *
20 * See http://ionicframework.com/docs/components/#navigation for more info
21 * on Ionic pages and navigation.
22 */
23@IonicPage()
24@Component({
25 selector: 'page-price-request',
26 templateUrl: 'price-request.html',
27 encapsulation: ViewEncapsulation.None,
28})
29export class PriceRequestPage {
30
31private rebalance: any;
32
33public cart : any[] =[];
34
35public pro_cart : any[] =[];
36
37public discomment: any;
38
39seenNames: any = {};
40
41count:any = 0;
42
43user:any;
44
45selSBC: any;
46
47public product_title : string = '';
48
49//Price Request Header List Show and Hide Variable
50
51public price_request_header_screen = true;
52
53//Price Request Footer Show and Hide Variable
54
55public submit_pricing_request_footer = false;
56
57//Change Background Color of Decision Maker and Channel Contact Page (boolean condition class check)
58
59isChanged: boolean = false;
60
61
62//Declaration variable of Decision Maker Edit Page
63
64custprojectname:string;
65
66decisionmakername:string;
67
68decisionmakertitle:string;
69
70decisionmakeremail:string;
71
72title:string;
73
74
75public decision_maker_edited = false;
76
77public discount_apply_edited = false;
78
79
80
81//End Declaration variable of Decision Maker Edit Page
82
83
84//Declaration variable of Channel Contact Edit Page
85
86sp1bptypedescription:string;
87
88sp1bpcontactname:string;
89
90sp1requesterphone:string;
91
92sp1bpcontactemail:string;
93
94public channel_contact_edited = false;
95
96//End Declaration variable of Channel Contact Edit Page
97
98
99//Declaration Variable of Pricing Information Bid Justification Page
100
101public pricing_information_comment_edited = false;
102
103public price_info :string;
104
105todo_justification:string;
106
107// End Declaration Variable of Pricing Information Bid Justification Page
108
109
110
111//Declaration Variable of Special Bid Code Page
112
113public pricing_special_bid_edited = false;
114
115tmp:any;
116
117private loader : any;
118
119sbcalreadyapplied:any;
120
121modelArray: RetrivenonautodiscountProvider[] = [];
122
123tmp_retrive:any;
124
125
126
127
128//End Declaration Variable of Special Bid Code Page
129
130
131//Start Declaration Variable of Edit Quote Level Page
132
133sb_special_code:string;
134
135sb_approval_name:string;
136
137usersJson: any = {};
138
139public submitpricingeditquotelevelspecialcode = false;
140
141
142//End Declaration Variable of Edit Quote Level Page
143
144//Start Declaration Variable of Add Quote Special Bid Code
145
146public add_approval_sub_item = false;
147
148public add_specialbid_head_item = false;
149
150public add_specialbid_sub_item = false;
151
152add_user:any;
153
154add_tmp:any;
155
156add_tmp_re:any[] = [];
157
158public add_cart : any[] =[];
159
160public sbcapprovalinfo_sbclist:any[]=[];
161
162public sbcinfo:any[] = [];
163
164public add_results : any[] = [];
165
166public add_modi_cart : any[] =[];
167
168private add_loader : any;
169
170 add_temp:any;
171
172 add_tmp_cart : any[] = [];
173
174 add_tre:any;
175
176 add_whatToDo: any = false;
177
178 add_bks: SelectedsbclistProvider[] = [];
179
180 add_seenNames: any = {};
181
182 add_sbcalreadyapplied:any[] = [];
183
184 public submit_pricing_addquotelevelspecialcode = false;
185
186 //Done Button show and hide
187
188 public price_request_done_button = false;
189
190//End Declaration Variable of Add Quote Special Bid Code
191
192// Start Declaration Variable of Product Level Special Bid Code
193
194extended_end_user_price:string|number;
195
196end_user_discount:string|number;
197
198pro_usersJson: any = {};
199
200 pro_tmp:any;
201
202 public submit_pricing_productlevelspecialcode = false;
203
204 public submit_pricing_subproductlevelspecialcode = false;
205
206// End Declaration Variable of Product Level Special Bid Code
207
208
209//Start Declaration Variable for Submit and Save Quote
210
211public header_val : any[] =[];
212
213public dealReglist_val : any[] =[];
214
215//public installAddress_val : any[] =[];
216
217public selectedSbcList_val : any[] =[];
218
219//Approval Variable Declaration
220
221add_approval_name:string;
222
223
224
225 //Header Object Declarartion Variable
226 geocode:string;
227 quotestatusdesc:string;
228 quotemanager:string;
229 tier1companyname:string;
230 creatortype:string;
231 bpreasoncode:string;
232 isquotevalid:string;
233 quotestatus:string;
234 currencycode:string;
235 parent_val:string; //countrycode and id are declared variable
236
237 deal_reg :any;
238
239//End----------------------
240
241
242
243// Declarartion Variable
244 ccmsnb:string;
245 customertypecode:string;
246 decMakersEmail:string;
247 decMakersName:string;
248 decMakersProjName:string;
249 decMakersTitle:string;
250 bidType:string;
251 country:string;
252 id:string;
253 countrycode:string;
254
255 quoteTitle:string;
256
257 addresstype:string;
258
259 custCode:string;
260
261
262ctrycode:string;
263
264quoteid: number;
265
266bpcomments:string;
267
268autoRebalancecheckFlag:string;
269
270componentpriceslist : string;
271
272//Take Final submit Value
273
274rt_val:any;
275
276submit_data :any;
277
278deal_id_val:string;
279
280 //End----------------------
281
282//Status Variable for Save and Submit
283
284save_status:any;
285
286//End
287
288//Collection data variable for Retrive Non Auto Discount
289
290dt_retri:any;
291
292pro_index:any;
293
294max_update_val:any[] = [];
295
296generic_val:any[]=[];
297
298generic_val_drop:any[]=[];
299
300//component SBC List
301
302compsbclist:any[]= [];
303
304//Take Model DecisionMaker Variable
305
306st_bck_decisionmaker:any;
307
308
309generic_modal_val:any;
310
311//Generid Component Hide and Show
312
313public generic_edited = false;
314
315public generic_edited_drop = false;
316
317//Increment SBC Value
318
319_autoincrement:number = 0;
320
321//Push SBC Exception Array Value
322
323sbc_exception:any[] = [];
324
325//Temporary Array for Product Level Special Bid Code
326
327sbc_temp_pro_array:any[] = [];
328
329//Tag Name Declaration Variable for Generic Editor
330
331tagName:any;
332
333 newItem:any = {
334
335 quotePriceRequest:{
336
337 addExtraSbcBox: [],
338 optionsOfSelectBox2 : [],
339 masterSbcList : [],
340 headerSbcList : [],
341 selectedSbcList : [],
342 selectedHeaderSBC : '',
343 previousLastSbc:'',
344 componentpriceslist:{
345 specialBidCodesList : [],
346 selectBox : [],
347 selectedOptionOfSelectedBox1 : '',
348 genericDropDownSelectArray:[],
349 countAppliedProductsSbc:[]
350
351 }
352
353 }
354 };
355
356
357channelInformationItem:any = {
358channelinfo:{pcs: {sp2bptype:'',sp1customernumber:'',sp1bptypedescription:'',sp1bptype:'',sp1requesterphone:'',sp2companyname:'',sp1contactemail:'',sp2contactemail:'',sp1contactname:'',sp1companyname:'',sp2bptypedescription:'',bptier2bpcompanynameasentryfield:'Y',bptier2option:'Y'},
359 redirectionappname:"PCS",
360 typecode:""
361 },
362
363 isVnsp:"N"
364
365
366 };
367
368
369
370
371Value:any = {};
372
373//Approved Quote Hide and Show Variable
374
375public removeForwardArrow = false;
376
377//Install Address
378
379public install_address_edited = false;
380
381//Install Address Id Count Variable
382
383installAddressCount:number = 0;
384
385//installAddressid:number =0;
386
387//Product Component Id
388
389proComponentId:number;
390
391
392
393
394 constructor(public sanitize: DomSanitizer ,public navCtrl: NavController, public navParams: NavParams,public state: AppStateProvider,private _ngZone: NgZone,public loading: LoadingController,public quoteService: QuoteService,private alertCtrl: AlertController,public state_retrivenonautoidscount: RetrivenonautodiscountProvider,public cdr: ChangeDetectorRef,private sanitizer: DomSanitizer,private nativePageTransitions: NativePageTransitions,private keyboard: Keyboard,public userData: UserData) {
395
396 //this.state.currentQuote.bidjustificationdata.comments = sanitize.bypassSecurityTrustHtml('<div style="font-size: 14pt">'+this.state.currentQuote.bidjustificationdata.comments+'</div>');
397 //this.state.currentQuote.bidjustificationdata.comments = '<div style="color: red; font-size: 14pt">'+this.state.currentQuote.bidjustificationdata.comments+'</div>';
398 this.discomment = sanitize.bypassSecurityTrustHtml('<div style="color: red; font-size: 14pt">'+this.state.currentQuote.bidjustificationdata.returnedfromdiscomments+'</div>');
399
400 if(state.currentQuote.pricingdata.rebalance == 'true' || state.currentQuote.pricingdata.rebalance == 'YES'){
401 this.rebalance = true;
402 }else if(state.currentQuote.pricingdata.rebalance == ''){
403 this.rebalance = true;
404 state.currentQuote.pricingdata.rebalance == 'YES';
405 }
406 else {
407 this.rebalance = false;
408 }
409
410 if(this.price_request_header_screen){
411 this.submit_pricing_request_footer = true;
412 }
413
414 //Hide Decision Maker Fields Initial
415
416 this.decision_maker_edited = false;
417
418
419 }
420
421
422 ionViewDidLoad() {
423 console.log('ionViewDidLoad PriceRequestPage');
424
425 let sbc_non_combine: String[] = [] ;
426
427 this.state.currentQuote.installAddress_val = [];
428
429 this.state.currentQuote.htmlflag="false";
430
431this.st_bck_decisionmaker = this.state.currentQuote.decisionmaker;
432
433if ("sbclist" in this.state.currentQuote && typeof this.state.currentQuote.sbclist!== "undefined") {
434
435
436 if(this.state.currentQuote.hasOwnProperty('sbclist'))
437 {
438
439 if(this.state.currentQuote.sbclist[0].hasOwnProperty('componentsbc'))
440 {
441
442 this.user = this.state.currentQuote.sbclist[0].componentsbc;
443
444
445 for (let key of this.user)
446 {
447 for(var i in key)
448 {
449
450
451for(var m = 1; m <= 6;m++)
452{
453
454if('specialbidcode'+m == i)
455{
456
457if(key[i])
458{
459
460this.count++;
461
462this.cart.push(key[i]);
463
464}
465
466else
467{}
468
469}
470else
471{}
472}
473}
474}
475
476
477
478//Removing Duplicate Special codes
479
480
481for (let k = 0; k < this.cart.length; k++) {
482 if (this.seenNames.hasOwnProperty(this.cart[k])) {
483 //already has it
484 this.cart.splice(k, 1);
485 k--;
486
487 } else {
488 this.seenNames[this.cart[k]] = true;
489
490
491 }
492
493
494
495}
496
497
498
499 //Add Quote Onload Data
500
501
502
503
504 this.add_sbcalreadyapplied = this.cart;
505
506
507 for (let key of this.user) {
508 for(let i in key)
509 {
510
511
512 if(i == 'specialbidcodelist'){
513
514
515 this.add_temp = key[i];
516
517
518 for (let j of this.add_temp) {
519
520
521 this.add_cart.push(j);
522
523
524 }
525
526 }
527 else{ }
528
529 }
530}
531
532this.add_tmp_cart = this.add_cart;
533
534for (let i = 0; i < this.add_cart.length; i++) {
535 if (this.add_seenNames.hasOwnProperty(this.add_cart[i].code)) {
536 //already has it
537 this.add_cart.splice(i, 1);
538 i--;
539 } else {
540 this.add_seenNames[this.add_cart[i].code] = true;
541
542 }
543
544
545}
546
547
548for(let k=0 ; k < this.add_cart.length ; k++){
549 for(let z=0 ; z < this.add_sbcalreadyapplied.length; z++){
550 if(this.add_cart[k].code == this.add_sbcalreadyapplied[z]){
551 for(let l=0; l < this.add_cart[k].noncombinablespecialbidcodelist.split(',').length;l++){
552 sbc_non_combine.push(this.add_cart[k].noncombinablespecialbidcodelist.split(',')[l]);
553 }
554 }
555}
556}
557sbc_non_combine = sbc_non_combine.filter((item,index)=>sbc_non_combine.indexOf(item)=== index);
558console.log("sbc_non_combine");
559 for(let p=0; p<sbc_non_combine.length; p++){
560 for(let q=0; q<this.add_cart.length; q++){
561 if(this.add_cart[q] !== undefined || this.add_cart[q] !== null){
562 if(sbc_non_combine[p] === this.add_cart[q].code){
563 this.add_cart.splice(q,1);
564 }
565 }
566 }
567 }
568
569
570
571for(let u = 0; u < this.add_sbcalreadyapplied.length; u++)
572{
573
574for (let v =0; v < this.add_cart.length;v++)
575{
576
577
578
579if(this.add_cart[v].code == this.add_sbcalreadyapplied[u])
580 {
581
582
583 this.selectedSbcList_val.push(this.add_cart[v]);
584 this.add_cart.splice(v, 1);
585 }
586 else
587 {}
588
589}
590
591
592}
593
594
595
596 }
597 else{}
598
599 }
600 else{
601 }
602
603 if(this.add_sbcalreadyapplied != []){
604
605 this.loader = this.loading.create({
606 content: 'Loading...',
607 });
608 this.loader.present();
609
610 for(let m=0; m < this.add_sbcalreadyapplied.length; m++){
611 this.quoteService.sbcapprovalinfo(this.state.currentQuote.ctrycode,this.add_sbcalreadyapplied[m],this.state.currentQuote.headerinfo.geocode,this.state.currentQuote.quoteid)
612 .then((data:any)=>{
613 if(data.items[0].selectedsbc[0].sbcapprprefix != ''){
614 this.sbcapprovalinfo_sbclist.push(data.items[0].selectedsbc[0]);
615 }
616 }).then(()=>{
617 for(let k=0 ; k < this.sbcapprovalinfo_sbclist.length; k++){
618 if(this.state.currentQuote.pricingdata.hasOwnProperty('sbcinfo')){
619 for(let l=0 ; l < this.state.currentQuote.pricingdata.sbcinfo.length ;l++){
620 if(this.state.currentQuote.pricingdata.sbcinfo[l].sbc.split('-')[0] == this.sbcapprovalinfo_sbclist[k].code){
621 this.sbcinfo.push({sbc : this.sbcapprovalinfo_sbclist[k].code+"-"+this.sbcapprovalinfo_sbclist[k].description, sbcapprnumber : this.state.currentQuote.pricingdata.sbcinfo[l].sbcapprnumber ,approvalnb: this.state.currentQuote.pricingdata.sbcinfo[l].sbcapprnumber ,...this.sbcapprovalinfo_sbclist[k]});
622 }
623 else{
624 this.sbcinfo.push({sbc : this.sbcapprovalinfo_sbclist[k].code+"-"+this.sbcapprovalinfo_sbclist[k].description, sbcapprnumber : '',...this.sbcapprovalinfo_sbclist[k]});
625 }
626 }
627 }
628 else{
629 this.sbcinfo.push({sbc : this.sbcapprovalinfo_sbclist[k].code+"-"+this.sbcapprovalinfo_sbclist[k].description, sbcapprnumber : '',...this.sbcapprovalinfo_sbclist[k]});
630 }
631 }
632 }).then(()=>{
633 // let temp_sbcinfo = this.sbcinfo;
634 // this.sbcinfo = [];
635 for(let i=0; i<this.sbcinfo.length; i++){
636 if(this.sbcinfo[i].sbcapprnumber != ""){
637 this.sbcinfo[i].approvalnb = this.sbcinfo[i].sbcapprnumber;
638 }
639 }
640 for(let k=0; k<this.sbcinfo.length; k++){
641 for(let l=k+1; l<this.sbcinfo.length; l++) {
642 if(this.sbcinfo[k].code == this.sbcinfo[l].code){
643 if(this.sbcinfo[k].sbcapprnumber == "" && this.sbcinfo[l].sbcapprnumber !== ""){
644 this.sbcinfo.splice(k,1);
645 }
646 }
647 }
648 }
649 this.sbcinfo = this.sbcinfo.map(item=>item.code).map((item,index,array)=>array.indexOf(item)).filter((item,index,array)=>array.indexOf(item)==index).map((item)=>this.sbcinfo[item]);
650 console.log(this.sbcinfo);
651
652 console.log(this.sbcinfo);
653 if(this.state.currentQuote.hasOwnProperty('sbcinfo')){
654 this.state.currentQuote.sbcinfo = this.sbcinfo.map(item=>item.code).map((item,index,array)=>array.indexOf(item)).filter((item,index,array)=>array.indexOf(item)==index).map((item)=>this.state.currentQuote.sbcinfo[item]);
655 this.sbcinfo = this.state.currentQuote.sbcinfo;
656 }
657 else{
658 this.state.currentQuote.sbcinfo = this.sbcinfo;
659 }
660 })
661 }
662 this.loader.dismiss();
663 }
664
665}
666//Approve Quote
667
668if(this.state.currentQuote.statuscode == this.state.BPQUOTESTATUS_SUBMITTED_TO_DISTRIBUTOR && this.state.currentQuote.issp2 != 'false'){
669 this.submit_pricing_request_footer = true;
670 this.removeForwardArrow = true;
671 }
672
673 if(this.state.currentQuote.statuscode == this.state.BPQUOTESTATUS_IBM_APPROVED || this.state.currentQuote.statuscode == this.state.BPQUOTESTATUS_VALUE_SELLER_APPROVED || this.state.currentQuote.statuscode == this.state.BPQUOTESTATUS_IBM_WITHDRAWN
674 || this.state.currentQuote.statuscode == this.state.BPQUOTESTATUS_REQUEST_PRICING || this.state.currentQuote.statuscode == this.state.BPQUOTESTATUS_ON_HOLD || this.state.currentQuote.statuscode == this.state.BPQUOTESTATUS_RETURNED_FROM_DISTRIBUTOR || this.state.currentQuote.statuscode == this.state.BPQUOTESTATUS_VALUE_SELLER_APPROVED || this.state.currentQuote.headerinfo.geocode != 'NA'){
675
676this.removeForwardArrow = true;
677
678this.submit_pricing_request_footer = false;
679
680if(this.state.currentQuote.statuscode == this.state.BPQUOTESTATUS_RETURNED_FROM_DISTRIBUTOR && this.state.currentQuote.issp2 != 'false'){
681 this.submit_pricing_request_footer = true;
682 this.removeForwardArrow = false;
683}
684
685 }
686 else{
687
688 this.submit_pricing_request_footer = true;
689
690 }
691
692
693
694//End
695
696
697
698 //Add Max Non Auto Discount
699
700 if(this.state.currentQuote.hasOwnProperty('pricingdata'))
701 {
702
703 if(this.state.currentQuote.pricingdata.hasOwnProperty('compinfo'))
704 {
705
706 for (let km = 0; km < this.state.currentQuote.pricingdata.compinfo.length; km++) {
707
708 this.max_update_val[km] = this.state.currentQuote.pricingdata.compinfo[km].maxnonaudeudiscount;
709
710 }
711 }
712 else{}
713
714
715
716 }
717 else{}
718
719
720
721 //End
722
723
724//Intialiaze to Null
725
726this.newItem.quotePriceRequest.selectedSbcList = [];
727
728this.newItem.quotePriceRequest.componentpriceslist.specialBidCodesList = [];
729
730
731
732
733//Product Level Sbc Code Functionality
734
735this.sbcDataToSpecialBidCodesList();
736
737//Decisionmaker Edit Page Onload Data
738
739 this.title = 'Submit Price Request';
740
741
742this.decisionmakername = this.state.currentQuote.decisionmaker.decisionmakername;
743
744this.decisionmakertitle = this.state.currentQuote.decisionmaker.decisionmakertitle;
745
746this.decisionmakeremail = this.state.currentQuote.decisionmaker.decisionmakeremail;
747
748this.custprojectname = this.state.currentQuote.decisionmaker.custprojectname;
749
750
751//End Decisionmaker Edit Page Onload Data
752
753
754
755//Channel Contact Edit Page OnLoad Data
756
757this.sp1bpcontactemail = this.state.currentQuote.channelinfo1.channelrepemailad;
758this.sp1bptypedescription = this.state.currentQuote.channelinfo1.ibmprodspecialist;
759this.sp1bpcontactname = this.state.currentQuote.channelinfo1.channelrepname;
760this.sp1requesterphone = this.state.currentQuote.channelinfo1.channelrepphone;
761
762//End Channel Contact Edit Page Onload Data
763
764
765//Start Pricing Information Onload Data
766
767this.todo_justification = this.htmlToPlaintext(this.state.currentQuote.bidjustificationdata.comments);
768this.todo_justification.replace(/ /g," ");
769
770//End Pricing Information Onload Data
771
772if(this.state.currentQuote.statuscode == this.state.BPQUOTESTATUS_INCOMPLETE){
773
774this.installAddressCount = 2;
775
776//this.installAddressid = 0;
777
778if(this.state.currentQuote.installaddress){
779
780 for (let kt = 0; kt < this.state.currentQuote.installaddress.length; kt++) {
781
782this.state.currentQuote.installAddress_val.push({'address1':this.state.currentQuote.installaddress[kt].streetaddress1,'address2':this.state.currentQuote.installaddress[kt].streetaddress2,'city':this.state.currentQuote.installaddress[kt].city,'state':this.state.currentQuote.installaddress[kt].regionid,"addressid":String(kt)});
783
784//this.installAddress_val.push({'address1':this.state.currentQuote.installaddress[kt].streetaddress1,'address2':this.state.currentQuote.installaddress[kt].streetaddress2,'city':this.state.currentQuote.installaddress[kt].city,'state':this.state.currentQuote.installaddress[kt].regionid,"addressid":String(this.installAddressid)});
785
786this.installAddressCount++;
787
788//this.installAddressid++;
789
790 }
791
792
793}
794else{}
795
796
797
798}
799
800 }
801
802
803 //Back Click event Call
804
805 st_bck()
806{
807
808if(this.decision_maker_edited || this.tagName == 'decisionMaker')
809{
810
811this._ngZone.run(() => {
812
813if(this.generic_modal_val)
814{
815
816
817 if(Object.keys(this.state.currentQuote.decisionmaker).length < 4){
818 //Only for these condition this.state.currentQuote.decisionmaker==={"custprojectname":" "} if decisionmaker has empty model value
819
820 //Check value if not present in model
821
822if(this.checkDecisionModelVal(this.generic_val[0].input_model_val) == -1)
823 {
824
825
826this.state.currentQuote.decisionmaker[this.generic_val[0].input_model_val] = this.generic_modal_val;
827
828 }
829 else{}
830
831 }
832
833 else{
834
835 let keyArr: any[] = Object.keys(this.state.currentQuote.decisionmaker);
836 keyArr.forEach((key: any) => {
837
838 if(key === this.generic_val[0].input_model_val)
839 {
840
841 this.state.currentQuote.decisionmaker[key] = this.generic_modal_val;
842
843 }
844
845 else {}
846
847
848 });
849
850 }
851
852
853
854}
855else{}
856
857});
858
859
860if(this.tagName == 'decisionMaker' && !this.decision_maker_edited)
861{
862
863this.tagName = '';
864
865this.decision_maker_edited = true;
866
867//Update all Values
868
869this.decisionmakername = this.state.currentQuote.decisionmaker.decisionmakername;
870
871this.decisionmakertitle = this.state.currentQuote.decisionmaker.decisionmakertitle;
872
873this.decisionmakeremail = this.state.currentQuote.decisionmaker.decisionmakeremail;
874
875this.custprojectname = this.state.currentQuote.decisionmaker.custprojectname;
876
877
878
879}
880
881else
882{
883
884this.isChanged = false;
885
886this.decision_maker_edited = false;
887
888this.channel_contact_edited = false;
889
890this.price_request_header_screen = true;
891
892if(this.removeForwardArrow){
893this.submit_pricing_request_footer = false;
894}
895else{
896this.submit_pricing_request_footer = true;
897}
898
899}
900
901
902this.generic_edited = false;
903
904this.generic_edited_drop = false;
905
906this.pricing_special_bid_edited = false;
907
908
909
910this.pricing_information_comment_edited = false;
911
912}
913else if(this.channel_contact_edited || this.tagName == 'channelContact')
914{
915
916
917this._ngZone.run(() => {
918
919if(this.generic_modal_val){
920
921let keyArr: any[] = Object.keys(this.state.currentQuote.channelinfo1);
922 keyArr.forEach((key: any) => {
923
924
925 if(key === this.generic_val[0].input_model_val)
926 {
927
928 this.state.currentQuote.channelinfo1[key] = this.generic_modal_val;
929
930
931 }
932});
933
934
935}else{}
936
937
938});
939
940
941if(this.tagName == 'channelContact' && !this.channel_contact_edited)
942{
943
944this.tagName = '';
945this.channel_contact_edited = true;
946
947this.sp1bpcontactemail = this.state.currentQuote.channelinfo1.channelrepemailad;
948this.sp1bptypedescription = this.state.currentQuote.channelinfo1.ibmprodspecialist;
949this.sp1bpcontactname = this.state.currentQuote.channelinfo1.channelrepname;
950this.sp1requesterphone = this.state.currentQuote.channelinfo1.channelrepphone;
951
952
953}
954else{
955
956this.decision_maker_edited = false;
957
958this.channel_contact_edited = false;
959
960this.price_request_header_screen = true;
961
962this.isChanged = false;
963
964if(this.removeForwardArrow){
965this.submit_pricing_request_footer = false;
966}
967else{
968this.submit_pricing_request_footer = true;
969}
970
971}
972
973this.generic_edited = false;
974
975this.generic_edited_drop = false;
976
977//Hide Special Bid Component module for ionic
978
979this.pricing_special_bid_edited = false;
980
981this.submit_pricing_productlevelspecialcode = false;
982
983this.pricing_information_comment_edited = false;
984
985
986
987}
988
989else if(this.pricing_information_comment_edited)
990{
991
992//this.state.currentQuote.bidjustificationdata.comments = this.todo_justification;
993
994
995this.decision_maker_edited = false;
996
997this.channel_contact_edited = false;
998
999this.price_request_header_screen = true;
1000
1001this.pricing_information_comment_edited = false;
1002
1003this.pricing_special_bid_edited = false;
1004
1005if(this.removeForwardArrow){
1006this.submit_pricing_request_footer = false;
1007}
1008else{
1009this.submit_pricing_request_footer = true;
1010}
1011
1012this.submit_pricing_productlevelspecialcode = false;
1013
1014this.generic_edited = false;
1015
1016this.generic_edited_drop = false;
1017
1018}
1019
1020else if(this.tagName == 'quickDiscountApply'){
1021
1022this.pricing_special_bid_edited = false;
1023
1024this.decision_maker_edited = false;
1025
1026this.channel_contact_edited = false;
1027
1028this.price_request_header_screen = true;
1029
1030this.pricing_information_comment_edited = false;
1031
1032if(this.removeForwardArrow){
1033this.submit_pricing_request_footer = false;
1034}
1035else{
1036this.submit_pricing_request_footer = true;
1037}
1038
1039this.submit_pricing_productlevelspecialcode = false;
1040
1041this.price_request_done_button = false;
1042
1043this.generic_edited = false;
1044
1045this.generic_edited_drop = false;
1046
1047this.pricing_information_comment_edited = false;
1048
1049this.tagName = '';
1050
1051this.discount_apply_edited = false;
1052
1053this.cdr.detectChanges();
1054
1055}
1056
1057else if(this.pricing_special_bid_edited)
1058{
1059
1060this.pricing_special_bid_edited = false;
1061
1062this.decision_maker_edited = false;
1063
1064this.channel_contact_edited = false;
1065
1066this.price_request_header_screen = true;
1067
1068this.pricing_information_comment_edited = false;
1069
1070if(this.removeForwardArrow){
1071this.submit_pricing_request_footer = false;
1072}
1073else{
1074this.submit_pricing_request_footer = true;
1075}
1076
1077this.submit_pricing_productlevelspecialcode = false;
1078
1079this.price_request_done_button = false;
1080
1081this.generic_edited = false;
1082
1083this.generic_edited_drop = false;
1084
1085this.pricing_information_comment_edited = false;
1086
1087this.cdr.detectChanges();
1088
1089}
1090
1091
1092else if(this.submitpricingeditquotelevelspecialcode || this.submit_pricing_addquotelevelspecialcode){
1093
1094this.submitpricingeditquotelevelspecialcode = false;
1095
1096this.submit_pricing_addquotelevelspecialcode = false;
1097
1098this.decision_maker_edited = false;
1099
1100this.channel_contact_edited = false;
1101
1102this.price_request_header_screen = false;
1103
1104this.pricing_information_comment_edited = false;
1105
1106if(this.removeForwardArrow){
1107this.submit_pricing_request_footer = false;
1108}
1109else{
1110this.submit_pricing_request_footer = true;
1111}
1112
1113this.isChanged = false;
1114
1115this.pricing_special_bid_edited = false;
1116
1117this.price_request_header_screen = true;
1118
1119this.submit_pricing_productlevelspecialcode = false;
1120//shivam
1121//Hide Done Button
1122
1123this.price_request_done_button = false;
1124
1125//Check
1126
1127this.add_specialbid_head_item = false;
1128
1129this.add_specialbid_sub_item = false;
1130
1131this.generic_edited = false;
1132
1133this.generic_edited_drop = false;
1134
1135this.pricing_information_comment_edited = false;
1136
1137this.cdr.detectChanges();
1138}
1139
1140else if(this.install_address_edited)
1141{
1142
1143this.install_address_edited = false;
1144
1145this.price_request_header_screen = true;
1146
1147this.isChanged = false;
1148
1149
1150}
1151
1152else if(this.generic_edited_drop){
1153
1154this.submitpricingeditquotelevelspecialcode = false;
1155
1156this.submit_pricing_addquotelevelspecialcode = false;
1157
1158this.decision_maker_edited = false;
1159
1160this.channel_contact_edited = false;
1161
1162this.price_request_header_screen = false;
1163
1164this.pricing_information_comment_edited = false;
1165
1166if(this.removeForwardArrow){
1167this.submit_pricing_request_footer = false;
1168}
1169else{
1170this.submit_pricing_request_footer = true;
1171}
1172
1173this.isChanged = false;
1174
1175this.pricing_special_bid_edited = false;
1176
1177this.submit_pricing_productlevelspecialcode = true;
1178
1179//Hide Done Button
1180
1181this.price_request_done_button = false;
1182
1183//Check
1184
1185this.add_specialbid_head_item = false;
1186
1187this.add_specialbid_sub_item = false;
1188
1189this.generic_edited = false;
1190
1191this.generic_edited_drop = false;
1192
1193this.pricing_information_comment_edited = false;
1194
1195this.cdr.detectChanges();
1196
1197}
1198
1199else if(this.submit_pricing_productlevelspecialcode || this.tagName == 'submitPricingSubProductLevelSpecialCode'){
1200
1201
1202
1203if(!this.submit_pricing_productlevelspecialcode && this.tagName == 'submitPricingSubProductLevelSpecialCode')
1204{
1205
1206this.tagName = '';
1207
1208if(this.generic_modal_val){
1209
1210if(this.generic_val[0].input_model_val == 'extended_end_user_price'){
1211
1212// End User Discount Calculation Formula
1213
1214//((extented list price - entended end user price)/extented list price)*100
1215
1216this.end_user_discount = (((this.pro_usersJson.listprice - this.generic_modal_val)/this.pro_usersJson.listprice)*100).toFixed(2);
1217
1218this.extended_end_user_price = this.generic_modal_val;
1219
1220this.state.currentQuote.pricingdata.compinfo[this.pro_index].enduserdiscount = this.end_user_discount;
1221
1222this.pro_usersJson.enduserdiscount = this.end_user_discount;
1223
1224
1225}
1226else{
1227
1228//Extended End Price Calculation Formula
1229
1230//extented list price( 1 - end user discount/100) = entended end user price
1231
1232this.end_user_discount = this.generic_modal_val;
1233
1234this.extended_end_user_price = (this.pro_usersJson.listprice * ( 1 - this.generic_modal_val/100)).toFixed(2);
1235
1236this.state.currentQuote.pricingdata.compinfo[this.pro_index].enduserprice = this.extended_end_user_price;
1237
1238this.pro_usersJson.enduserdiscount = this.generic_modal_val;
1239
1240}
1241
1242}
1243else{}
1244
1245this.submit_pricing_productlevelspecialcode = true;
1246this.pricing_special_bid_edited = false;
1247}
1248else
1249{
1250this.submit_pricing_productlevelspecialcode = false;
1251this.pricing_special_bid_edited = false;
1252this.price_request_header_screen = true;
1253this.cdr.detectChanges();
1254//shivam
1255}
1256
1257this.submitpricingeditquotelevelspecialcode = false;
1258
1259this.submit_pricing_addquotelevelspecialcode = false;
1260
1261
1262this.decision_maker_edited = false;
1263
1264this.channel_contact_edited = false;
1265
1266// this.price_request_header_screen = false;
1267
1268this.pricing_information_comment_edited = false;
1269
1270if(this.removeForwardArrow){
1271this.submit_pricing_request_footer = false;
1272}
1273else{
1274this.submit_pricing_request_footer = true;
1275}
1276
1277this.isChanged = false;
1278
1279this.generic_edited = false;
1280
1281this.generic_edited_drop = false;
1282
1283this.pricing_information_comment_edited = false;
1284
1285}
1286else{
1287
1288this.isChanged = false;
1289
1290if(this.removeForwardArrow){
1291this.submit_pricing_request_footer = false;
1292}
1293else{
1294this.submit_pricing_request_footer = true;
1295}
1296
1297this.pricing_information_comment_edited = false;
1298
1299this.submitpricingeditquotelevelspecialcode = false;
1300
1301this.submit_pricing_addquotelevelspecialcode = false;
1302
1303this.generic_edited = false;
1304
1305this.generic_edited_drop = false;
1306
1307this.cdr.detectChanges();
1308
1309this.slideOptions();
1310
1311this.navCtrl.push(DetailPage);
1312
1313//this.navCtrl.pop();
1314
1315}
1316
1317}
1318
1319
1320
1321
1322
1323
1324// st_bck()
1325// {
1326
1327// if(this.decision_maker_edited || this.tagName == 'decisionMaker')
1328// {
1329
1330// this._ngZone.run(() => {
1331
1332// if(this.generic_modal_val)
1333// {
1334
1335
1336// if(Object.keys(this.state.currentQuote.decisionmaker).length < 4){
1337// //Only for these condition this.state.currentQuote.decisionmaker==={"custprojectname":" "} if decisionmaker has empty model value
1338
1339// //Check value if not present in model
1340
1341// if(this.checkDecisionModelVal(this.generic_val[0].input_model_val) == -1)
1342// {
1343
1344
1345// this.state.currentQuote.decisionmaker[this.generic_val[0].input_model_val] = this.generic_modal_val;
1346
1347// }
1348// else{}
1349
1350// }
1351
1352// else{
1353
1354// let keyArr: any[] = Object.keys(this.state.currentQuote.decisionmaker);
1355// keyArr.forEach((key: any) => {
1356
1357// if(key === this.generic_val[0].input_model_val)
1358// {
1359
1360// this.state.currentQuote.decisionmaker[key] = this.generic_modal_val;
1361
1362// }
1363
1364// else {}
1365
1366
1367// });
1368
1369// }
1370
1371
1372
1373// }
1374// else{}
1375
1376// });
1377
1378
1379// if(this.tagName == 'decisionMaker' && !this.decision_maker_edited)
1380// {
1381
1382// this.tagName = '';
1383
1384// this.decision_maker_edited = true;
1385
1386// //Update all Values
1387
1388// this.decisionmakername = this.state.currentQuote.decisionmaker.decisionmakername;
1389
1390// this.decisionmakertitle = this.state.currentQuote.decisionmaker.decisionmakertitle;
1391
1392// this.decisionmakeremail = this.state.currentQuote.decisionmaker.decisionmakeremail;
1393
1394// this.custprojectname = this.state.currentQuote.decisionmaker.custprojectname;
1395
1396
1397
1398// }
1399
1400// else
1401// {
1402
1403// this.isChanged = false;
1404
1405// this.decision_maker_edited = false;
1406
1407// this.channel_contact_edited = false;
1408
1409// this.price_request_header_screen = true;
1410
1411// if(this.removeForwardArrow){
1412// this.submit_pricing_request_footer = false;
1413// }
1414// else{
1415// this.submit_pricing_request_footer = true;
1416// }
1417
1418// }
1419
1420
1421// this.generic_edited = false;
1422
1423// this.generic_edited_drop = false;
1424
1425// this.pricing_special_bid_edited = false;
1426
1427
1428
1429// this.pricing_information_comment_edited = false;
1430
1431// }
1432// else if(this.channel_contact_edited || this.tagName == 'channelContact')
1433// {
1434
1435
1436// this._ngZone.run(() => {
1437
1438// if(this.generic_modal_val){
1439
1440// let keyArr: any[] = Object.keys(this.state.currentQuote.channelinfo1);
1441// keyArr.forEach((key: any) => {
1442
1443
1444// if(key === this.generic_val[0].input_model_val)
1445// {
1446
1447// this.state.currentQuote.channelinfo1[key] = this.generic_modal_val;
1448
1449
1450// }
1451// });
1452
1453
1454// }else{}
1455
1456
1457// });
1458
1459
1460// if(this.tagName == 'channelContact' && !this.channel_contact_edited)
1461// {
1462
1463// this.tagName = '';
1464// this.channel_contact_edited = true;
1465
1466// this.sp1bpcontactemail = this.state.currentQuote.channelinfo1.channelrepemailad;
1467// this.sp1bptypedescription = this.state.currentQuote.channelinfo1.ibmprodspecialist;
1468// this.sp1bpcontactname = this.state.currentQuote.channelinfo1.channelrepname;
1469// this.sp1requesterphone = this.state.currentQuote.channelinfo1.channelrepphone;
1470
1471
1472// }
1473// else{
1474
1475// this.decision_maker_edited = false;
1476
1477// this.channel_contact_edited = false;
1478
1479// this.price_request_header_screen = true;
1480
1481// this.isChanged = false;
1482
1483// if(this.removeForwardArrow){
1484// this.submit_pricing_request_footer = false;
1485// }
1486// else{
1487// this.submit_pricing_request_footer = true;
1488// }
1489
1490// }
1491
1492// this.generic_edited = false;
1493
1494// this.generic_edited_drop = false;
1495
1496// //Hide Special Bid Component module for ionic
1497
1498// this.pricing_special_bid_edited = false;
1499
1500// this.submit_pricing_productlevelspecialcode = false;
1501
1502// this.pricing_information_comment_edited = false;
1503
1504
1505
1506// }
1507
1508// else if(this.pricing_information_comment_edited)
1509// {
1510
1511// this.state.currentQuote.bidjustificationdata.comments = this.todo_justification;
1512
1513
1514// this.decision_maker_edited = false;
1515
1516// this.channel_contact_edited = false;
1517
1518// this.price_request_header_screen = true;
1519
1520// this.pricing_information_comment_edited = false;
1521
1522// this.pricing_special_bid_edited = false;
1523
1524// if(this.removeForwardArrow){
1525// this.submit_pricing_request_footer = false;
1526// }
1527// else{
1528// this.submit_pricing_request_footer = true;
1529// }
1530
1531// this.submit_pricing_productlevelspecialcode = false;
1532
1533// this.generic_edited = false;
1534
1535// this.generic_edited_drop = false;
1536
1537// }
1538
1539// else if(this.tagName == 'quickDiscountApply'){
1540
1541// this.pricing_special_bid_edited = true;
1542
1543
1544// this.decision_maker_edited = false;
1545
1546// this.channel_contact_edited = false;
1547
1548// this.price_request_header_screen = false;
1549
1550// this.pricing_information_comment_edited = false;
1551
1552// if(this.removeForwardArrow){
1553// this.submit_pricing_request_footer = false;
1554// }
1555// else{
1556// this.submit_pricing_request_footer = true;
1557// }
1558
1559// this.submit_pricing_productlevelspecialcode = false;
1560
1561// this.price_request_done_button = false;
1562
1563// this.generic_edited = false;
1564
1565// this.generic_edited_drop = false;
1566
1567// this.pricing_information_comment_edited = false;
1568
1569// this.tagName = '';
1570
1571// this.cdr.detectChanges();
1572
1573// }
1574
1575// else if(this.pricing_special_bid_edited)
1576// {
1577
1578// this.pricing_special_bid_edited = false;
1579
1580// this.decision_maker_edited = false;
1581
1582// this.channel_contact_edited = false;
1583
1584// this.price_request_header_screen = true;
1585
1586// this.pricing_information_comment_edited = false;
1587
1588// if(this.removeForwardArrow){
1589// this.submit_pricing_request_footer = false;
1590// }
1591// else{
1592// this.submit_pricing_request_footer = true;
1593// }
1594
1595// this.submit_pricing_productlevelspecialcode = false;
1596
1597// this.price_request_done_button = false;
1598
1599// this.generic_edited = false;
1600
1601// this.generic_edited_drop = false;
1602
1603// this.pricing_information_comment_edited = false;
1604
1605// this.cdr.detectChanges();
1606
1607// }
1608
1609
1610// else if(this.submitpricingeditquotelevelspecialcode || this.submit_pricing_addquotelevelspecialcode){
1611
1612// this.submitpricingeditquotelevelspecialcode = false;
1613
1614// this.submit_pricing_addquotelevelspecialcode = false;
1615
1616// this.decision_maker_edited = false;
1617
1618// this.channel_contact_edited = false;
1619
1620// this.price_request_header_screen = false;
1621
1622// this.pricing_information_comment_edited = false;
1623
1624// if(this.removeForwardArrow){
1625// this.submit_pricing_request_footer = false;
1626// }
1627// else{
1628// this.submit_pricing_request_footer = true;
1629// }
1630
1631// this.isChanged = false;
1632
1633// this.pricing_special_bid_edited = true;
1634
1635// this.submit_pricing_productlevelspecialcode = false;
1636
1637// //Hide Done Button
1638
1639// this.price_request_done_button = false;
1640
1641// //Check
1642
1643// this.add_specialbid_head_item = false;
1644
1645// this.add_specialbid_sub_item = false;
1646
1647// this.generic_edited = false;
1648
1649// this.generic_edited_drop = false;
1650
1651// this.pricing_information_comment_edited = false;
1652
1653// this.cdr.detectChanges();
1654// }
1655
1656// else if(this.install_address_edited)
1657// {
1658
1659// this.install_address_edited = false;
1660
1661// this.price_request_header_screen = true;
1662
1663// this.isChanged = false;
1664
1665
1666// }
1667
1668// else if(this.generic_edited_drop){
1669
1670// this.submitpricingeditquotelevelspecialcode = false;
1671
1672// this.submit_pricing_addquotelevelspecialcode = false;
1673
1674// this.decision_maker_edited = false;
1675
1676// this.channel_contact_edited = false;
1677
1678// this.price_request_header_screen = false;
1679
1680// this.pricing_information_comment_edited = false;
1681
1682// if(this.removeForwardArrow){
1683// this.submit_pricing_request_footer = false;
1684// }
1685// else{
1686// this.submit_pricing_request_footer = true;
1687// }
1688
1689// this.isChanged = false;
1690
1691// this.pricing_special_bid_edited = false;
1692
1693// this.submit_pricing_productlevelspecialcode = true;
1694
1695// //Hide Done Button
1696
1697// this.price_request_done_button = false;
1698
1699// //Check
1700
1701// this.add_specialbid_head_item = false;
1702
1703// this.add_specialbid_sub_item = false;
1704
1705// this.generic_edited = false;
1706
1707// this.generic_edited_drop = false;
1708
1709// this.pricing_information_comment_edited = false;
1710
1711// this.cdr.detectChanges();
1712
1713// }
1714
1715// else if(this.submit_pricing_productlevelspecialcode || this.tagName == 'submitPricingSubProductLevelSpecialCode'){
1716
1717
1718
1719// if(!this.submit_pricing_productlevelspecialcode && this.tagName == 'submitPricingSubProductLevelSpecialCode')
1720// {
1721
1722// this.tagName = '';
1723
1724// if(this.generic_modal_val){
1725
1726// if(this.generic_val[0].input_model_val == 'extended_end_user_price'){
1727
1728// // End User Discount Calculation Formula
1729
1730// //((extented list price - entended end user price)/extented list price)*100
1731
1732// this.end_user_discount = (((this.pro_usersJson.listprice - this.generic_modal_val)/this.pro_usersJson.listprice)*100).toFixed(2);
1733
1734// this.extended_end_user_price = this.generic_modal_val;
1735
1736// this.state.currentQuote.pricingdata.compinfo[this.pro_index].enduserdiscount = this.end_user_discount;
1737
1738// this.pro_usersJson.enduserdiscount = this.end_user_discount;
1739
1740
1741// }
1742// else{
1743
1744// //Extended End Price Calculation Formula
1745
1746// //extented list price( 1 - end user discount/100) = entended end user price
1747
1748// this.end_user_discount = this.generic_modal_val;
1749
1750// this.extended_end_user_price = (this.pro_usersJson.listprice * ( 1 - this.generic_modal_val/100)).toFixed(2);
1751
1752// this.state.currentQuote.pricingdata.compinfo[this.pro_index].enduserprice = this.extended_end_user_price;
1753
1754// this.pro_usersJson.enduserdiscount = this.generic_modal_val;
1755
1756// }
1757
1758// }
1759// else{}
1760
1761// this.submit_pricing_productlevelspecialcode = true;
1762// this.pricing_special_bid_edited = false;
1763// }
1764// else
1765// {
1766// this.submit_pricing_productlevelspecialcode = false;
1767// this.pricing_special_bid_edited = true;
1768// this.cdr.detectChanges();
1769// }
1770
1771// this.submitpricingeditquotelevelspecialcode = false;
1772
1773// this.submit_pricing_addquotelevelspecialcode = false;
1774
1775
1776// this.decision_maker_edited = false;
1777
1778// this.channel_contact_edited = false;
1779
1780// this.price_request_header_screen = false;
1781
1782// this.pricing_information_comment_edited = false;
1783
1784// if(this.removeForwardArrow){
1785// this.submit_pricing_request_footer = false;
1786// }
1787// else{
1788// this.submit_pricing_request_footer = true;
1789// }
1790
1791// this.isChanged = false;
1792
1793// this.generic_edited = false;
1794
1795// this.generic_edited_drop = false;
1796
1797// this.pricing_information_comment_edited = false;
1798
1799// }
1800// else{
1801
1802// this.isChanged = false;
1803
1804// if(this.removeForwardArrow){
1805// this.submit_pricing_request_footer = false;
1806// }
1807// else{
1808// this.submit_pricing_request_footer = true;
1809// }
1810
1811// this.pricing_information_comment_edited = false;
1812
1813// this.submitpricingeditquotelevelspecialcode = false;
1814
1815// this.submit_pricing_addquotelevelspecialcode = false;
1816
1817// this.generic_edited = false;
1818
1819// this.generic_edited_drop = false;
1820
1821// this.cdr.detectChanges();
1822
1823// this.slideOptions();
1824
1825// this.navCtrl.push(DetailPage);
1826
1827// //this.navCtrl.pop();
1828
1829// }
1830
1831// }
1832
1833
1834//Slide option
1835
1836slideOptions(){
1837
1838let options: NativeTransitionOptions = {
1839 direction: 'right',
1840 duration: 400,
1841 iosdelay: 50,
1842 androiddelay: 50
1843 };
1844
1845this.nativePageTransitions.slide(options);
1846
1847
1848
1849}
1850
1851editContacts(){
1852 console.log("Price Request: Contacts");
1853
1854
1855 this.price_request_header_screen = false;
1856
1857 this.submit_pricing_request_footer = true;
1858
1859 this.decision_maker_edited = true;
1860
1861 this.channel_contact_edited = true;
1862
1863 this.decisionmakername = this.state.currentQuote.decisionmaker.decisionmakername;
1864
1865 this.decisionmakertitle = this.state.currentQuote.decisionmaker.decisionmakertitle;
1866
1867 this.decisionmakeremail = this.state.currentQuote.decisionmaker.decisionmakeremail;
1868
1869 this.custprojectname = this.state.currentQuote.decisionmaker.custprojectname;
1870
1871 this.sp1bpcontactemail = this.state.currentQuote.channelinfo1.channelrepemailad;
1872 this.sp1bptypedescription = this.state.currentQuote.channelinfo1.ibmprodspecialist;
1873 this.sp1bpcontactname = this.state.currentQuote.channelinfo1.channelrepname;
1874 this.sp1requesterphone = this.state.currentQuote.channelinfo1.channelrepphone;
1875
1876 this.isChanged = true;
1877
1878}
1879 editDecisionMaker()
1880 {
1881 console.log("Price Request: editDecisionMaker");
1882
1883
1884 this.price_request_header_screen = false;
1885
1886 this.submit_pricing_request_footer = false;
1887
1888 this.decision_maker_edited = true;
1889
1890 this.channel_contact_edited = false;
1891
1892 this.decisionmakername = this.state.currentQuote.decisionmaker.decisionmakername;
1893
1894 this.decisionmakertitle = this.state.currentQuote.decisionmaker.decisionmakertitle;
1895
1896 this.decisionmakeremail = this.state.currentQuote.decisionmaker.decisionmakeremail;
1897
1898 this.custprojectname = this.state.currentQuote.decisionmaker.custprojectname;
1899
1900 this.isChanged = true;
1901
1902
1903 }
1904
1905 // --------------------------------------------------------------------------
1906 editIBMChannelContact(){
1907 console.log("Price Request: editIBMChannelContact");
1908
1909 // this.navCtrl.setRoot(PriceRequestChannelcontactPage);
1910
1911this.price_request_header_screen = false;
1912
1913this.submit_pricing_request_footer = false;
1914
1915 this.channel_contact_edited = true;
1916
1917 this.decision_maker_edited = false;
1918
1919 //Channel Contact Edit Page OnLoad Data
1920this.sp1bpcontactemail = this.state.currentQuote.channelinfo1.channelrepemailad;
1921this.sp1bptypedescription = this.state.currentQuote.channelinfo1.ibmprodspecialist;
1922this.sp1bpcontactname = this.state.currentQuote.channelinfo1.channelrepname;
1923this.sp1requesterphone = this.state.currentQuote.channelinfo1.channelrepphone;
1924
1925 this.isChanged = true;
1926
1927 }
1928
1929 // --------------------------------------------------------------------------
1930 editSpecialBidCode(){
1931 console.log("Price Request: editSpecialBidCode");
1932 //TODO: popover text editor?
1933
1934if(this.state.currentQuote.hasOwnProperty('sbclist'))
1935{
1936this.sbcalreadyapplied = this.cart;
1937
1938}
1939else
1940{
1941
1942}
1943
1944
1945this.pricing_special_bid_edited = true;
1946
1947this.price_request_header_screen = false;
1948
1949 this.channel_contact_edited = false;
1950
1951 this.decision_maker_edited = false;
1952
1953 this.isChanged = false;
1954
1955 if(this.removeForwardArrow){
1956
1957 this.submit_pricing_request_footer = false;
1958
1959 }
1960 else{
1961
1962this.submit_pricing_request_footer = true;
1963
1964 }
1965
1966 this.cdr.detectChanges();
1967
1968 }
1969
1970 // --------------------------------------------------------------------------
1971 editRequestedPrice(){
1972 console.log("Price Request: editRequestedPrice");
1973 //TODO: popover text editor?
1974 }
1975
1976 // --------------------------------------------------------------------------
1977 editBidJustfication(){
1978 console.log("Price Request: editBidJustfication");
1979 //this.navCtrl.setRoot(PriceRequestBidjustificationPage);
1980
1981 this.decision_maker_edited = false;
1982
1983 this.channel_contact_edited = false;
1984
1985 this.price_request_header_screen = false;
1986
1987 this.pricing_information_comment_edited = true;
1988
1989 if(this.removeForwardArrow){
1990 this.submit_pricing_request_footer = false;
1991 }
1992 else{
1993 this.submit_pricing_request_footer = true;
1994 }
1995
1996 this.isChanged = false;
1997
1998 //this.keyboard.disableScroll(true);
1999
2000 this.keyboard.show();
2001
2002 }
2003
2004 // --------------------------------------------------------------------------
2005 changeRebalance(){
2006
2007 if(this.rebalance == true){
2008 this.state.currentQuote.pricingdata.rebalance = 'true';
2009 }
2010 else{
2011
2012 this.rebalance = false;
2013
2014 this.state.currentQuote.pricingdata.rebalance = 'false';
2015
2016 }
2017
2018 }
2019
2020
2021
2022 //Function Called for Generic Input Text Box
2023 showGenericEditor(label:string,input_model:any,$event:any,tagname:any){
2024
2025 //Clear tag Value
2026this.tagName = '';
2027
2028//Set tag Value
2029this.tagName = tagname;
2030
2031 if(this.removeForwardArrow){
2032
2033 //Disable ion-input
2034
2035 }
2036 else{
2037
2038this.generic_val = [];
2039
2040this.generic_modal_val = '';
2041
2042this.generic_edited = true;
2043
2044this.generic_edited_drop = false;
2045
2046
2047 if(this.decision_maker_edited){
2048
2049 //Main Input Hide and Show
2050
2051 this.decision_maker_edited = false;
2052
2053this.generic_val.push({'label':label,'input_model_val':input_model,'input_val':$event,'input_type':'text'});
2054
2055 }
2056
2057 else if(this.submit_pricing_productlevelspecialcode){
2058
2059 this.isChanged = true;
2060
2061this.submit_pricing_productlevelspecialcode = false;
2062 this.generic_val.push({'label':label,'input_model_val':input_model,'input_val':$event,'input_type':'number'
2063});
2064
2065 }
2066
2067 else if(this.pricing_special_bid_edited){
2068
2069 this.isChanged = true;
2070
2071this.pricing_special_bid_edited = false;
2072
2073this.price_request_done_button = true;
2074
2075this.generic_val.push({'label':label,'input_model_val':input_model,'input_val':$event,'input_type':'number'
2076});
2077
2078
2079 }
2080 else if(this.price_request_header_screen){
2081
2082 this.isChanged = true;
2083
2084 this.price_request_header_screen = false;
2085
2086 this.price_request_done_button = true;
2087
2088 this.discount_apply_edited = true;
2089
2090 this.generic_val.push({'label':label,'input_model_val':input_model,'input_val':$event,'input_type':'number'});
2091 }
2092
2093 else
2094 {
2095
2096//Main Input Channel Maker Hide and Show
2097
2098this.channel_contact_edited = false;
2099this.generic_val.push({'label':label,'input_model_val':input_model,'input_val':$event,'input_type':'text'
2100
2101});
2102
2103 }
2104
2105 }
2106
2107 }
2108 //End Function Calling Generic
2109
2110
2111 inputChanges(label:string,input_model:any,$event:any,tagname:any){
2112
2113 let input_val : any = '';
2114
2115 input_val = $event;
2116
2117 //Clear tag Value
2118 this.tagName = '';
2119
2120//Set tag Value
2121 this.tagName = tagname;
2122
2123 if(this.tagName == 'submitPricingSubProductLevelSpecialCode')
2124 {
2125
2126 if(input_model == 'extended_end_user_price'){
2127
2128 // End User Discount Calculation Formula
2129
2130 //((extented list price - entended end user price)/extented list price)*100
2131
2132 this.end_user_discount = (((this.pro_usersJson.listprice - input_val)/this.pro_usersJson.listprice)*100).toFixed(2);
2133
2134 this.extended_end_user_price = input_val;
2135
2136 this.state.currentQuote.pricingdata.compinfo[this.pro_index].enduserdiscount = this.end_user_discount;
2137
2138 this.state.currentQuote.pricingdata.compinfo[this.pro_index].enduserprice = this.extended_end_user_price;
2139
2140 this.pro_usersJson.enduserdiscount = this.end_user_discount;
2141
2142 }
2143 else{
2144
2145 //Extended End Price Calculation Formula
2146
2147 //extented list price( 1 - end user discount/100) = entended end user price
2148
2149 this.end_user_discount = input_val;
2150
2151 this.extended_end_user_price = (this.pro_usersJson.listprice * ( 1 - input_val/100)).toFixed(2);
2152
2153 this.state.currentQuote.pricingdata.compinfo[this.pro_index].enduserprice = this.extended_end_user_price;
2154
2155 this.state.currentQuote.pricingdata.compinfo[this.pro_index].enduserdiscount = input_val;
2156
2157 this.pro_usersJson.enduserdiscount = input_val;
2158
2159 }
2160
2161 }
2162
2163 }
2164
2165
2166//End Function Channel Contact Edit Page
2167
2168
2169//Function Calling Special Bid Code Page
2170
2171
2172approvalnbChange(sbccode,approvalnb){
2173 this.state.currentQuote.add_bks = [];
2174 for(let i=0; i< this.sbcinfo.length; i++){
2175 if(this.sbcinfo[i].sbc == sbccode){
2176 this.sbcinfo[i].approvalnb = approvalnb;
2177 }
2178 this.state.currentQuote.sbcinfo = this.sbcinfo;
2179 this.add_bks.push(...this.sbcinfo);
2180 this.add_bks = this.add_bks.map(item=>item.code).map((item,index,array)=>array.indexOf(item)).filter((item,index,array)=>array.indexOf(item)==index).map((item)=>this.add_bks[item]);
2181 this.state.currentQuote.add_bks = this.add_bks;
2182 }
2183
2184 console.log(approvalnb);
2185}
2186
2187// approvalnb_Done(){
2188// this.add_bks.push(...this.sbcinfo);
2189// this.add_bks = this.add_bks.map(item=>item.code).map((item,index,array)=>array.indexOf(item)).filter((item,index,array)=>array.indexOf(item)==index).map((item)=>this.add_bks[item]);
2190// this.state.currentQuote.add_bks = this.add_bks;
2191// // let alert = this.alertCtrl.create({
2192// // title: 'Submit Price Request',
2193// // subTitle: 'Approval Number Added',
2194// // buttons: ['Ok']
2195// // });
2196// this.state.currentQuote.add_bks.forEach((element)=>{
2197// if(element.sbcapprprefix !== null && element.sbcapprprefix !== ""){
2198// if(element.sbcapprnumber === null && element.sbcapprnumber === ""){
2199// // let alert = this.alertCtrl.create({
2200// // title: 'Submit Price Request',
2201// // subTitle: 'Missing Approval Number, please provide a valid approval number',
2202// // buttons: ['Ok']
2203// // });
2204// // alert.present();
2205// //'Missing Approval Number, please provide a valid approval number'
2206// this.state.validateMessageSbcCheck = 'Missing Approval Number, please provide a valid approval number'
2207// return true;
2208// }
2209// else if(element.sbcapprnumber.startsWith(element.sbcapprprefix)){
2210// console.log("approval number is correct")
2211// }
2212// else{
2213// // let alert = this.alertCtrl.create({
2214// // title: 'Submit Price Request',
2215// // subTitle: 'Invalid Approval Number, please provide a valid approval number',
2216// // buttons: ['Ok']
2217// // });
2218// // alert.present();
2219// //'Invalid Approval Number, please provide a valid approval number'
2220// this.state.validateMessageSbcCheck = 'Invalid Approval Number, please provide a valid approval number'
2221// return true;
2222// }
2223// }
2224// });
2225// this.loader = this.loading.create({
2226// content: 'Loading...',
2227// });
2228// this.loader.present();
2229
2230// this.quoteService.ValidateandSaveHeaderInfo(this.state.currentQuote.ctrycode,this.state.currentQuote.headerinfo.geocode,this.state.currentQuote.quoteid,this.add_bks)
2231// .then((data: any) => {
2232// this._ngZone.run(() => {
2233// this.quoteService.load(this.state.currentQuote.quoteid)
2234// .then((data: any) => {
2235
2236// this.state.currentQuote = data;
2237
2238// // for (let i = 0; i < this.add_cart.length; i++) {
2239// // if(this.add_tre){
2240
2241// // if (this.add_tre.selectedsbc[0].code == this.add_cart[i].code) {
2242// // //already has it
2243// // this.add_cart.splice(i, 1);
2244
2245// // } else {}
2246
2247
2248// // }
2249// // }
2250// this.loader.dismiss();
2251// return false;
2252// // alert.present();
2253// });
2254// //remove the spinner
2255
2256
2257// });
2258// });
2259// }
2260
2261approvalnb_Done(){
2262 this.add_bks.push(...this.sbcinfo);
2263 this.add_bks = this.add_bks.map(item=>item.code).map((item,index,array)=>array.indexOf(item)).filter((item,index,array)=>array.indexOf(item)==index).map((item)=>this.add_bks[item]);
2264 this.state.currentQuote.add_bks = this.add_bks;
2265 let alert = this.alertCtrl.create({
2266 title: 'Submit Price Request',
2267 subTitle: 'Approval Number Added',
2268 buttons: ['Ok']
2269 });
2270 this.loader = this.loading.create({
2271 content: 'Loading...',
2272 });
2273 this.loader.present();
2274
2275 this.quoteService.ValidateandSaveHeaderInfo(this.state.currentQuote.ctrycode,this.state.currentQuote.headerinfo.geocode,this.state.currentQuote.quoteid,this.add_bks)
2276 .then((data: any) => {
2277 this._ngZone.run(() => {
2278 this.quoteService.load(this.state.currentQuote.quoteid)
2279 .then((data: any) => {
2280
2281 this.state.currentQuote = data;
2282
2283 for (let i = 0; i < this.add_cart.length; i++) {
2284 if(this.add_tre){
2285
2286 if (this.add_tre.selectedsbc[0].code == this.add_cart[i].code) {
2287 //already has it
2288 this.add_cart.splice(i, 1);
2289
2290 } else {}
2291
2292
2293 }
2294 }
2295 this.loader.dismiss();
2296 alert.present();
2297 });
2298 //remove the spinner
2299
2300
2301 });
2302});
2303}
2304
2305pricing_comments(event){
2306 this.state.currentQuote.bidjustificationdata.comments = event.target.innerText;
2307 // event.preventDefault();
2308 event.stopPropagation();
2309 // this.state.currentQuote.htmlflag="false";
2310 // event.preventDefault();
2311}
2312
2313unApplySbcCodes()
2314 {
2315 let alert = this.alertCtrl.create({
2316 title: 'Submit Price Request',
2317 message: 'Do you want to unapply all Special Codes',
2318 buttons: [
2319 {
2320 text: 'Dismiss',
2321 role: 'cancel',
2322 handler: () => {
2323 console.log('Dismiss clicked');
2324 }
2325 },
2326 {
2327 text: 'Ok',
2328 handler: () => {
2329
2330 this.loader = this.loading.create({
2331 content: 'Loading...',
2332 });
2333 this.loader.present();
2334 this.quoteService.deleteSbcApprovalInfo(this.state.currentQuote.quoteid)
2335 .then((data: any) => {
2336
2337 this.tmp = data;
2338
2339 if(this.tmp.status == "1"){
2340
2341 this.quoteService.load(this.state.currentQuote.quoteid)
2342 .then((data: any) => {
2343
2344 this.compsbclist = [];
2345
2346 //Clear All Sbc Level to Null
2347
2348 for (let k = 0; k < this.state.currentQuote.sbclist[0].componentsbc.length; k++) {
2349
2350this.compsbclist.push({"id":this.state.currentQuote.sbclist[0].componentsbc[k].componentid,"specialBidcode1":"","specialBidcode2":"","specialBidcode3":"","specialBidcode4":"","specialBidcode5":"","specialBidcode6":""});
2351
2352
2353 }
2354
2355 this.quoteService.applyAndSaveHeaderSBC(this.state.currentQuote.quoteid,'false',this.compsbclist)
2356 .then((data: any) => {
2357 if(data.status == "1"){
2358 this.quoteService.load(this.state.currentQuote.quoteid)
2359 .then((data: any) => {
2360 this.cart = [];
2361 this.pro_cart = [];
2362 this.newItem.quotePriceRequest.selectedSbcList = [];
2363 this.newItem.quotePriceRequest.componentpriceslist.specialBidCodesList = [];
2364 //Already Applied Selected SBC
2365 this.newItem.quotePriceRequest.componentpriceslist.selectBox = [];
2366 this.state.currentQuote = {};
2367 this.state.currentQuote = data;
2368 //Load Quote Level SBC
2369 // for (let j of this.add_tmp_cart) {
2370 // this.add_cart.push(j);
2371 // }
2372 this.add_tmp_cart.forEach(element=>{
2373 return this.add_cart.push(element);
2374 })
2375
2376 this.selectedSbcList_val.forEach((element)=>{
2377 return this.add_cart.splice(0,0,element);
2378 })
2379 let clone_cart = this.add_cart;
2380 this.add_cart = [];
2381 this.add_cart = clone_cart.map(item=>item.code).map((item,index,array)=>array.indexOf(item)).filter((item,index,array)=>array.indexOf(item)==index).map((item)=>clone_cart[item]);
2382 this.add_sbcalreadyapplied = [];
2383 this.selSBC = null;
2384 this.sbcinfo = [];
2385 this.cdr.detectChanges();
2386 this.loader.dismiss();
2387 // this.cdr.detectChanges();
2388 //this.selsbc.setValue('');
2389
2390 });
2391 }
2392 })
2393 .catch((error:any)=>{
2394 this.loader.dismiss();
2395 });
2396 });
2397 }
2398 else
2399 {
2400
2401 let alert_pop = this.alertCtrl.create({
2402 title: 'Submit Price Request',
2403 subTitle: 'Error Occured When Unapply a Special Codes',
2404 buttons: ['Ok']
2405 });
2406 alert_pop.present();
2407
2408 this.loader.dismiss();
2409 this.cdr.detectChanges();
2410
2411 }
2412
2413 });
2414
2415
2416 }
2417 }
2418 ]
2419 });
2420 alert.present();
2421 this.cdr.detectChanges();
2422
2423 }
2424
2425
2426 edtproductquotesbc(val,index)
2427 {
2428
2429 this.newItem.quotePriceRequest.selectedSbcList = [];
2430
2431this.pro_usersJson = {};
2432
2433this.pro_usersJson = val;
2434
2435this.pro_index = index;
2436
2437this.proComponentId = val.id;
2438
2439this.product_title = val.identifier;
2440
2441
2442this.extended_end_user_price = this.pro_usersJson.enduserprice;
2443
2444this.end_user_discount = this.pro_usersJson.enduserdiscount;
2445
2446
2447//Hide and Show
2448
2449this.submitpricingeditquotelevelspecialcode = false;
2450
2451this.submit_pricing_addquotelevelspecialcode = false;
2452
2453this.submit_pricing_productlevelspecialcode = true;
2454
2455this.decision_maker_edited = false;
2456
2457this.channel_contact_edited = false;
2458
2459this.price_request_header_screen = false;
2460
2461this.pricing_information_comment_edited = false;
2462
2463if(this.removeForwardArrow){
2464this.submit_pricing_request_footer = false;
2465this.isChanged = false;
2466}
2467else{
2468this.submit_pricing_request_footer = true;
2469this.isChanged = true;
2470}
2471
2472
2473this.pricing_special_bid_edited = false;
2474
2475
2476//Already Applied Selected SBC
2477
2478 this.newItem.quotePriceRequest.componentpriceslist.selectBox = [];
2479
2480this.sbcToSpecialBidCodesList();
2481
2482//End
2483
2484
2485
2486
2487 }
2488
2489
2490 add_quote_sbc()
2491 {
2492
2493//Hide and Show of Add Special Code Component
2494
2495this.submitpricingeditquotelevelspecialcode = false;
2496
2497this.submit_pricing_addquotelevelspecialcode = true;
2498
2499this.decision_maker_edited = false;
2500
2501this.channel_contact_edited = false;
2502
2503this.price_request_header_screen = false;
2504
2505this.pricing_information_comment_edited = false;
2506
2507this.submit_pricing_request_footer = false;
2508
2509this.isChanged = true;
2510
2511this.pricing_special_bid_edited = false;
2512
2513this.price_request_done_button = true;
2514
2515this.add_specialbid_head_item = true;
2516
2517this.add_specialbid_sub_item = false;
2518
2519this.add_approval_sub_item = false;
2520
2521this.submit_pricing_productlevelspecialcode = false;
2522
2523 }
2524
2525 quote_ps(val)
2526 {
2527
2528 this.usersJson = val;
2529
2530 this.sb_special_code = this.usersJson.sbc;
2531
2532 this.sb_approval_name = this.usersJson.approvalnb;
2533
2534 this.pricing_special_bid_edited = false;
2535
2536 this.submitpricingeditquotelevelspecialcode = true;
2537
2538 this.decision_maker_edited = false;
2539
2540 this.channel_contact_edited = false;
2541
2542 this.price_request_header_screen = false;
2543
2544 this.pricing_information_comment_edited = false;
2545
2546 this.submit_pricing_request_footer = true;
2547
2548 this.isChanged = true;
2549
2550 this.cdr.detectChanges();
2551
2552 }
2553
2554
2555 retri_max(){
2556
2557 this.state_retrivenonautoidscount.id = this.state.currentQuote.quoteid;
2558
2559 this.state_retrivenonautoidscount.legacyquoteid = this.state.currentQuote.quoteid;
2560
2561 this.state_retrivenonautoidscount.partnerId = this.state.currentQuote.headerinfo.endusername;
2562
2563 this.state_retrivenonautoidscount.currency = this.state.currentQuote.headerinfo.currency;
2564
2565 this.state_retrivenonautoidscount.status = this.state.currentQuote.headerinfo.quotestatus;
2566
2567 this.state_retrivenonautoidscount.isreadonly = this.state.currentQuote.readonly;
2568
2569 this.state_retrivenonautoidscount.ctrycode = this.state.currentQuote.headerinfo.ctrycode;
2570
2571 this.state_retrivenonautoidscount.parent = this.state.currentQuote.headerinfo.ctrycode;
2572
2573 this.state_retrivenonautoidscount.geoCode = this.state.currentQuote.headerinfo.geocode;
2574
2575 this.state_retrivenonautoidscount.reasoncode = this.state.currentQuote.bpreasoncode;
2576
2577 this.state_retrivenonautoidscount.reasondesc = this.state.currentQuote.headerinfo.quotestatusdesc;
2578
2579 this.state_retrivenonautoidscount.onshorectrycode = this.state.currentQuote.headerinfo.ctrycode;
2580
2581 this.state_retrivenonautoidscount.onshoreflag = '';
2582
2583 this.state_retrivenonautoidscount.sp2Name = this.state.currentQuote.headerinfo.sp2name;
2584
2585 this.state_retrivenonautoidscount.bpType = this.state.currentQuote.headerinfo.bptype;
2586
2587 this.state_retrivenonautoidscount.endUserName = this.state.currentQuote.headerinfo.endusername;
2588
2589 this.state_retrivenonautoidscount.specialbidvaluesellerbid = this.state.currentQuote.headerinfo.specialbidvaluesellerbid;
2590
2591 this.state_retrivenonautoidscount.isHandleRequestPricingCallRequired = false;
2592
2593 this.state_retrivenonautoidscount.goecustomer = '';
2594
2595 this.state_retrivenonautoidscount.statusCode = this.state.currentQuote.headerinfo.quotestatus;
2596
2597 this.state_retrivenonautoidscount.showreplacedquotecode = this.state.currentQuote.headerinfo.showreplacedquotecode;
2598
2599 this.modelArray.push(this.state_retrivenonautoidscount);
2600
2601//Api Call Retrive Non Auto Discount
2602
2603 let loading_rt = this.loading.create({
2604 content: 'Loading...',
2605 });
2606
2607 loading_rt.present();
2608
2609
2610 this.quoteService.retrivenonautodiscountinfo(this.modelArray[0])
2611 .then((data: any) => {
2612
2613 this.tmp_retrive = data;
2614
2615 //remove the spinner
2616 loading_rt.dismiss();
2617
2618 if(this.tmp_retrive.hasOwnProperty('items')){
2619
2620
2621 this.dt_retri = this.tmp_retrive.items[0].bppcoutputs;
2622
2623 for(let v = 0; v < this.dt_retri.length; v++)
2624 {
2625
2626 this.max_update_val[v] = this.dt_retri[v].max_eu_disct_ongrid;
2627
2628 this.state.currentQuote.pricingdata.compinfo[v].maxnonaudeudiscount = this.max_update_val[v];
2629
2630
2631 }
2632
2633 }
2634 else{}
2635
2636 });
2637
2638 }
2639
2640
2641
2642
2643//End Function Calling Special Bid Code Page
2644
2645//Add Special Bid Code Function Call
2646
2647
2648fs_add_sp()
2649{
2650
2651 if(this.selSBC != null){
2652let val:any = this.selSBC;
2653this.add_approval_sub_item = false;
2654
2655this.add_loader = this.loading.create({
2656 content: 'Loading...',
2657 });
2658 this.add_loader.present();
2659 this.quoteService.sbcapprovalinfo(this.state.currentQuote.ctrycode,val,this.state.currentQuote.headerinfo.geocode,this.state.currentQuote.quoteid)
2660 .then((data: any) => {
2661
2662
2663this.add_tmp_re = [];
2664
2665 this.add_tmp_re = data.items;
2666
2667
2668 if(this.add_tmp_re[0].isapprovalsectionrequired == 'false')
2669 {
2670
2671 this.add_approval_sub_item = false;
2672 this.add_loader.dismiss();
2673 //this.baz(this.add_tmp_re);
2674 }
2675 else
2676 {
2677 this.add_loader.dismiss();
2678
2679 this.add_approval_sub_item = true;
2680
2681
2682 }
2683
2684
2685
2686 });
2687
2688
2689
2690
2691 }
2692
2693}
2694
2695add_spclick(){
2696
2697
2698this.add_specialbid_head_item = false;
2699
2700this.add_specialbid_sub_item = true;
2701
2702this.cdr.detectChanges();
2703
2704
2705}
2706
2707//Done click event Call
2708
2709baz(add_val = this.add_tmp_re)
2710{
2711 let sbc_non_combine: String[] = []; // to remove sbcs from add_cart (when we apply a sbc some sbcs doesnot combine with the selcted sbc
2712
2713 if(this.selSBC == null && this.tagName !== 'quickDiscountApply')
2714 {
2715 let alert = this.alertCtrl.create({
2716 title: 'Submit Price Request',
2717 subTitle: 'Please select a special bid value',
2718 buttons: ['Ok']
2719 });
2720 alert.present();
2721 }
2722 else {
2723
2724if(this.tagName == 'quickDiscountApply'){
2725
2726 this.add_loader = this.loading.create({
2727 content: 'Loading...',
2728 });
2729
2730 this.add_loader.present();
2731 if(this.generic_modal_val == '')
2732 {
2733 let alert = this.alertCtrl.create({
2734 title: 'Submit Price Request',
2735 subTitle: 'Please enter discount value',
2736 buttons: ['Ok']
2737 });
2738 this.add_loader.dismiss();
2739 alert.present();
2740 }
2741
2742else if(this.generic_modal_val){
2743for(let v = 0; v < this.state.currentQuote.pricingdata.compinfo.length; v++)
2744 {
2745
2746this.state.currentQuote.pricingdata.compinfo[v].enduserdiscount = this.generic_modal_val;
2747 this.state.currentQuote.pricingdata.compinfo[v].enduserprice = (this.state.currentQuote.pricingdata.compinfo[v].listprice * ( 1 - this.generic_modal_val/100)).toFixed(2);
2748
2749 }
2750 this.generic_modal_val = '';
2751 let alert = this.alertCtrl.create({
2752 title: 'Submit Price Request',
2753 subTitle: 'Discount added successfully',
2754 buttons: ['Ok']
2755 });
2756 this.add_loader.dismiss();
2757 alert.present();
2758
2759 }
2760else{}
2761
2762}
2763
2764else if(this.generic_edited_drop){
2765
2766this._ngZone.run(() => {
2767
2768this.applyHeaderService();
2769
2770 });
2771
2772
2773this.cdr.detectChanges();
2774
2775
2776
2777
2778}
2779
2780else{
2781
2782this.add_loader = this.loading.create({
2783 content: 'Loading...',
2784 });
2785
2786this.add_loader.present();
2787
2788add_val[0].selectedsbc[0].approvalnb = this.add_approval_name;
2789
2790// if(add_val[0].selectedsbc[0].approvalnb!==null){
2791// let alert = this.alertCtrl.create({
2792// title:this.title,
2793// subTitle: 'Please provide Approval Number',
2794// buttons: ['Ok']
2795// });
2796// alert.present();
2797
2798// this.add_loader.dismiss();
2799
2800// }
2801
2802// else
2803//if(add_val[0].selectedsbc[0].approvalnb.startsWith(add_val[0].selectedsbc[0].sbcapprprefix)){
2804
2805if(this.add_approval_name == this.add_tmp_re[0].selectedsbc[0].approvalnb && this.add_tmp_re[0].selectedsbc[0].sbverifflag == 'Y' || this.add_tmp_re[0].selectedsbc[0].sbverifflag == 'N'){
2806
2807this.add_tre = add_val[0];
2808
2809this.add_bks.push({code: this.add_tre.selectedsbc[0].code, approvalnb:this.add_tre.selectedsbc[0].approvalnb, sbaddedverifflag:this.add_tre.selectedsbc[0].sbaddedverifflag, description: this.add_tre.selectedsbc[0].description, sbverifflag: this.add_tre.selectedsbc[0].sbverifflag,sbcapprprefix:this.add_tre.selectedsbc[0].sbcapprprefix});
2810
2811this.state.currentQuote.add_bks = this.add_bks;
2812
2813this.quoteService.ValidateandSaveHeaderInfo(this.state.currentQuote.ctrycode,this.state.currentQuote.headerinfo.geocode,this.state.currentQuote.quoteid,this.add_bks)
2814 .then((data: any) => {
2815 this._ngZone.run(() => {
2816 this.quoteService.load(this.state.currentQuote.quoteid)
2817 .then((data: any) => {
2818
2819 this.state.currentQuote = data;
2820
2821 for (let i = 0; i < this.add_cart.length; i++) {
2822 if(this.add_tre){
2823
2824 if (this.add_tre.selectedsbc[0].code == this.add_cart[i].code) {
2825 //already has it
2826 this.add_cart.splice(i, 1);
2827
2828 } else {}
2829
2830
2831 }
2832 }
2833 });
2834 //remove the spinner
2835
2836
2837 });
2838 });
2839
2840for(let k=0; k<this.add_bks.length; k++){
2841 if(this.add_bks[k].sbcapprprefix != "" && this.add_bks[k].approvalnb == undefined){
2842 this.add_bks[k].approvalnb = "";
2843 }
2844 if(this.sbcinfo.length == 0){
2845 let add_data = {sbc :this.add_bks[k].code+"-"+this.add_bks[k].description,sbcapprnumber : this.add_bks[k].approvalnb,...this.add_bks[k]}
2846 this.sbcinfo.push(add_data);
2847 }
2848 else{
2849 for(let l=0 ;l< this.sbcinfo.length; l++){
2850 if(this.add_bks[k].code != this.sbcinfo[l].code){
2851 let add_data = {sbc :this.add_bks[k].code+"-"+this.add_bks[k].description,sbcapprnumber : this.add_bks[k].approvalnb,...this.add_bks[k]}
2852 this.sbcinfo.push(add_data);
2853 }
2854}
2855}
2856}
2857this.sbcinfo = this.sbcinfo.map(item=>item.code).map((item,index,array)=>array.indexOf(item)).filter((item,index,array)=>array.indexOf(item)==index).map((item)=>this.sbcinfo[item]);
2858this.state.currentQuote.sbcinfo = this.sbcinfo;
2859let temp;
2860temp = this.state.currentQuote.sbcinfo;
2861 //Clear All Sbc Level to Null
2862 this.compsbclist = [];
2863
2864
2865for (let k = 0; k < this.state.currentQuote.sbclist[0].componentsbc.length; k++) {
2866
2867if(this.state.currentQuote.sbclist[0].componentsbc[k].sbcexception.split(',').indexOf(this.add_tre.selectedsbc[0].code) != '-1'){
2868
2869for(let l = 0; l < this.state.currentQuote.sbclist[0].componentsbc[k].sbcexception.split(',').length; l++)
2870{
2871if(this.state.currentQuote.sbclist[0].componentsbc[k].sbcexception.split(',')[l] == this.add_tre.selectedsbc[0].code){
2872
2873 if(this.state.currentQuote.sbclist[0].componentsbc[k].specialbidcode5
2874 && this.state.currentQuote.sbclist[0].componentsbc[k].specialbidcode4
2875 && this.state.currentQuote.sbclist[0].componentsbc[k].specialbidcode3
2876 && this.state.currentQuote.sbclist[0].componentsbc[k].specialbidcode2
2877 && this.state.currentQuote.sbclist[0].componentsbc[k].specialbidcode1){
2878 this.compsbclist.unshift({"id":this.state.currentQuote.sbclist[0].componentsbc[k].componentid,"specialBidcode1":"","specialBidcode2":"","specialBidcode3":"","specialBidcode4":"","specialBidcode5":"","specialBidcode6":this.add_tre.selectedsbc[0].code});
2879
2880 }else if(this.state.currentQuote.sbclist[0].componentsbc[k].specialbidcode4
2881 && this.state.currentQuote.sbclist[0].componentsbc[k].specialbidcode3
2882 && this.state.currentQuote.sbclist[0].componentsbc[k].specialbidcode2
2883 && this.state.currentQuote.sbclist[0].componentsbc[k].specialbidcode1){
2884 this.compsbclist.unshift({"id":this.state.currentQuote.sbclist[0].componentsbc[k].componentid,"specialBidcode1":"","specialBidcode2":"","specialBidcode3":"","specialBidcode4":"","specialBidcode5":this.add_tre.selectedsbc[0].code,"specialBidcode6":""});
2885
2886 }else if(this.state.currentQuote.sbclist[0].componentsbc[k].specialbidcode3
2887 && this.state.currentQuote.sbclist[0].componentsbc[k].specialbidcode2
2888 && this.state.currentQuote.sbclist[0].componentsbc[k].specialbidcode1){
2889 this.compsbclist.unshift({"id":this.state.currentQuote.sbclist[0].componentsbc[k].componentid,"specialBidcode1":"","specialBidcode2":"","specialBidcode3":"","specialBidcode4":this.add_tre.selectedsbc[0].code,"specialBidcode5":"","specialBidcode6":""});
2890
2891 }
2892 else if(this.state.currentQuote.sbclist[0].componentsbc[k].specialbidcode2
2893 && this.state.currentQuote.sbclist[0].componentsbc[k].specialbidcode1){
2894 this.compsbclist.unshift({"id":this.state.currentQuote.sbclist[0].componentsbc[k].componentid,"specialBidcode1":"","specialBidcode2":"","specialBidcode3":this.add_tre.selectedsbc[0].code,"specialBidcode4":"","specialBidcode5":"","specialBidcode6":""});
2895
2896 }else if(this.state.currentQuote.sbclist[0].componentsbc[k].specialbidcode1){
2897 this.compsbclist.unshift({"id":this.state.currentQuote.sbclist[0].componentsbc[k].componentid,"specialBidcode1":"","specialBidcode2":this.add_tre.selectedsbc[0].code,"specialBidcode3":"","specialBidcode4":"","specialBidcode5":"","specialBidcode6":""});
2898
2899 }
2900 else {
2901
2902 this.compsbclist.unshift({"id":this.state.currentQuote.sbclist[0].componentsbc[k].componentid,"specialBidcode1":this.add_tre.selectedsbc[0].code,"specialBidcode2":"","specialBidcode3":"","specialBidcode4":"","specialBidcode5":"","specialBidcode6":""});
2903
2904 }
2905
2906}
2907else{}
2908
2909}
2910
2911
2912}
2913else{
2914
2915 this.compsbclist.push({"id":this.state.currentQuote.sbclist[0].componentsbc[k].componentid,"specialBidcode1":"","specialBidcode2":"","specialBidcode3":"","specialBidcode4":"","specialBidcode5":"","specialBidcode6":""});
2916
2917}
2918
2919
2920
2921}
2922
2923
2924
2925this.quoteService.applyAndSaveHeaderSBC(this.state.currentQuote.quoteid,'true',this.compsbclist)
2926 .then((data: any) => {
2927
2928 if(data.status == "1"){
2929
2930
2931
2932 let alert = this.alertCtrl.create({
2933 title:this.title,
2934 subTitle: 'Special Bid Code Added',
2935 buttons: ['Ok']
2936 });
2937
2938
2939 //Update Load Data
2940
2941 this.quoteService.load(this.state.currentQuote.quoteid)
2942 .then((data: any) => {
2943
2944 this.cart = [];
2945
2946 this.add_cart = [];
2947
2948 this.pro_cart = [];
2949
2950 this.seenNames = {};
2951 this.selectedSbcList_val = [];
2952 this.add_cart = [];
2953this.add_seenNames = {};
2954
2955 this.state.currentQuote = data;
2956
2957
2958if(this.state.currentQuote.hasOwnProperty('sbclist'))
2959 {
2960
2961 if(this.state.currentQuote.sbclist[0].hasOwnProperty('componentsbc'))
2962 {
2963
2964 this.user = this.state.currentQuote.sbclist[0].componentsbc;
2965
2966
2967 for (let key of this.user)
2968 {
2969 for(var i in key)
2970 {
2971
2972
2973for(var m = 1; m <= 6;m++)
2974{
2975
2976if('specialbidcode'+m == i)
2977{
2978
2979if(key[i])
2980{
2981
2982this.count++;
2983
2984this.cart.push(key[i]);
2985
2986}
2987
2988else
2989{}
2990
2991}
2992else
2993{}
2994}
2995}
2996}
2997
2998
2999
3000//Removing Duplicate Special codes
3001
3002
3003for (let k = 0; k < this.cart.length; k++) {
3004 if (this.seenNames.hasOwnProperty(this.cart[k])) {
3005 //already has it
3006 this.cart.splice(k, 1);
3007 k--;
3008
3009 } else {
3010 this.seenNames[this.cart[k]] = true;
3011
3012 }
3013
3014}
3015
3016 }
3017 else{}
3018
3019 }
3020
3021 this.add_sbcalreadyapplied = this.cart;
3022
3023
3024 for (let key of this.user) {
3025 for(let i in key)
3026 {
3027
3028
3029 if(i == 'specialbidcodelist'){
3030
3031
3032 this.add_temp = key[i];
3033
3034
3035 for (let j of this.add_temp) {
3036
3037
3038 this.add_cart.push(j);
3039
3040
3041 }
3042
3043 }
3044 else{ }
3045
3046 }
3047}
3048
3049
3050
3051for (let i = 0; i < this.add_cart.length; i++) {
3052 if (this.add_seenNames.hasOwnProperty(this.add_cart[i].code)) {
3053 //already has it
3054 this.add_cart.splice(i, 1);
3055 i--;
3056 } else {
3057 this.add_seenNames[this.add_cart[i].code] = true;
3058
3059 }
3060
3061
3062}
3063
3064//remove non-combinable sbc codes from add_cart
3065
3066for(let k=0 ; k < this.add_cart.length ; k++){
3067 for(let z=0 ; z < this.add_sbcalreadyapplied.length; z++){
3068 if(this.add_cart[k].code == this.add_sbcalreadyapplied[z]){
3069 for(let l=0; l < this.add_cart[k].noncombinablespecialbidcodelist.split(',').length;l++){
3070 sbc_non_combine.push(this.add_cart[k].noncombinablespecialbidcodelist.split(',')[l]);
3071 }
3072 }
3073}
3074}
3075
3076sbc_non_combine = sbc_non_combine.filter((item,index)=>sbc_non_combine.indexOf(item)=== index);
3077console.log("sbc_non_combine");
3078 for(let p=0; p<sbc_non_combine.length; p++){
3079 for(let q=0; q<this.add_cart.length; q++){
3080 if(this.add_cart[q] !== undefined || this.add_cart[q] !== null){
3081 if(sbc_non_combine[p] === this.add_cart[q].code){
3082 this.add_cart.splice(q,1);
3083 }
3084 }
3085 }
3086 }
3087
3088
3089for(let u = 0; u < this.add_sbcalreadyapplied.length; u++)
3090{
3091
3092for (let v =0; v < this.add_cart.length;v++)
3093{
3094
3095
3096
3097if(this.add_cart[v].code == this.add_sbcalreadyapplied[u])
3098 {
3099
3100 this.selectedSbcList_val.push(this.add_cart[v]);
3101 this.add_cart.splice(v, 1);
3102 }
3103 else
3104 {}
3105
3106}
3107
3108
3109}
3110
3111this.state.currentQuote.sbcinfo = temp;
3112this.add_specialbid_head_item = true;
3113this.add_specialbid_sub_item = false;
3114
3115 this.selSBC = null;
3116 this.add_loader.dismiss();
3117 alert.present();
3118 if(this.add_tmp_re[0].selectedsbc[0].sbcapprprefix != ""){
3119// alert_save.present();
3120}
3121
3122 })
3123 // .then(()=>{
3124 // // this.sbcDataToSpecialBidCodesList();
3125 // // this.sbcToSpecialBidCodesList();
3126 // // this.add_loader.dismiss();
3127 // });
3128
3129 }
3130
3131 else{
3132
3133 let alert = this.alertCtrl.create({
3134 title:this.title,
3135 subTitle: 'Error Occured',
3136 buttons: ['Ok']
3137 });
3138 alert.present();
3139
3140 }
3141
3142
3143 });
3144
3145
3146
3147
3148}
3149//}
3150else{
3151
3152let alert = this.alertCtrl.create({
3153 title:this.title,
3154 subTitle: 'Invalid Approval Number',
3155 buttons: ['Ok']
3156 });
3157 alert.present();
3158
3159this.add_loader.dismiss();
3160
3161
3162}
3163
3164}
3165
3166}
3167
3168//this.selSBC = null;
3169
3170}
3171
3172//End Add Special Bid Code
3173
3174
3175//Save and Submit Price function Calling
3176
3177 retrivesubmitdata(){
3178
3179this.dealReglist_val = [];
3180
3181// submit data
3182
3183 if(this.state.currentQuote.hasOwnProperty('reginfolist'))
3184 {
3185this.deal_reg = this.state.currentQuote.reginfolist;
3186for (let l = 0; l < this.deal_reg.length; l++) {
3187
3188
3189if(this.deal_reg[l].regdescription == 'Storage registration number'){
3190
3191this.deal_id_val = 'S';
3192
3193}
3194else if(this.deal_reg[l].regdescription == 'Power registration number'){
3195
3196this.deal_id_val = 'P';
3197
3198}
3199else if(this.deal_reg[l].regdescription == 'Pureflex'){
3200
3201this.deal_id_val = 'XF';
3202
3203}
3204
3205else{
3206
3207this.deal_id_val = '';
3208
3209}
3210
3211this.dealReglist_val.push({
3212'dealregdes':this.deal_reg[l].regdescription,
3213'dealregid':this.deal_id_val,
3214'regnumber':this.deal_reg[l].registrationnumber
3215});
3216
3217}
3218}
3219else{}
3220
3221if(this.state.currentQuote.hasOwnProperty('channelinfo1')){
3222
3223//Channel Contact Edit Page OnLoad Data
3224
3225this.sp1bpcontactemail = this.state.currentQuote.channelinfo1.channelrepemailad;
3226this.sp1bptypedescription = this.state.currentQuote.channelinfo1.ibmprodspecialist;
3227this.sp1bpcontactname = this.state.currentQuote.channelinfo1.channelrepname;
3228this.sp1requesterphone = this.state.currentQuote.channelinfo1.channelrepphone;
3229}
3230
3231
3232if(this.state.currentQuote.hasOwnProperty('channelinfo')){
3233
3234//Channel Contact Edit Page OnLoad Data
3235
3236this.channelInformationItem.channelinfo.pcs.sp2bptype = this.state.currentQuote.channelinfo.pcs.sp2bptype;
3237
3238this.channelInformationItem.channelinfo.pcs.sp1customernumber = this.state.currentQuote.channelinfo.pcs.sp1customernumber;
3239
3240this.channelInformationItem.channelinfo.pcs.sp1bptypedescription = this.state.currentQuote.channelinfo.pcs.sp1bptypedescription;
3241
3242this.channelInformationItem.channelinfo.pcs.sp1bptype = this.state.currentQuote.channelinfo.pcs.sp1bptype;
3243
3244this.channelInformationItem.channelinfo.pcs.sp1requesterphone = this.state.currentQuote.channelinfo.pcs.sp1requesterphone;
3245
3246this.channelInformationItem.channelinfo.pcs.sp2companyname = this.state.currentQuote.channelinfo.pcs.sp2companyname;
3247
3248this.channelInformationItem.channelinfo.pcs.sp1contactemail = this.state.currentQuote.channelinfo.pcs.sp1bpcontactemail;
3249
3250this.channelInformationItem.channelinfo.pcs.sp2contactemail = this.state.currentQuote.channelinfo.pcs.sp2contactemail;
3251
3252this.channelInformationItem.channelinfo.pcs.sp1companyname = this.state.currentQuote.channelinfo.pcs.sp1bpcompanyname;
3253
3254this.channelInformationItem.channelinfo.pcs.sp2bptypedescription = this.state.currentQuote.channelinfo.pcs.sp2bptypedescription;
3255
3256this.channelInformationItem.channelinfo.pcs.sp1contactname = this.state.currentQuote.channelinfo.pcs.sp1bpcontactname;
3257
3258this.channelInformationItem.channelinfo.typecode = this.state.currentQuote.channelinfo.pcs.sp1bptype;
3259
3260}
3261
3262
3263
3264 if(this.state.currentQuote.hasOwnProperty('enduserinfo'))
3265 {
3266
3267 this.ccmsnb = this.state.currentQuote.enduserinfo.ccmsnb;
3268 this.customertypecode = 'C';
3269 //Check
3270 this.addresstype = 'ZI01';
3271 this.custCode = 'C';
3272
3273 if(this.state.currentQuote.statuscode != this.state.BPQUOTESTATUS_INCOMPLETE){
3274
3275 //Clear Install Address Array
3276this.state.currentQuote.installAddress_val = [];
3277
3278this.state.currentQuote.installAddress_val.push({
3279'id':'installaddress1',
3280'addressid':'0',
3281'address1':this.state.currentQuote.enduserinfo.streetaddress1,
3282'address2':this.state.currentQuote.enduserinfo.streetaddress2,
3283'city':this.state.currentQuote.enduserinfo.city,
3284'state':this.regionState(this.state.currentQuote.enduserinfo.regionstate)
3285});
3286
3287 }
3288
3289 }
3290
3291 else
3292 {}
3293
3294 if(this.state.currentQuote.hasOwnProperty('decisionmaker')){
3295
3296 this.decMakersEmail = this.state.currentQuote.decisionmaker.decisionmakeremail;
3297 this.decMakersName = this.state.currentQuote.decisionmaker.decisionmakername;
3298 this.decMakersProjName = this.state.currentQuote.decisionmaker.custprojectname;
3299 this.decMakersTitle = this.state.currentQuote.decisionmaker.decisionmakertitle;
3300 }
3301
3302 if(this.state.currentQuote.hasOwnProperty('headerinfo')){
3303
3304 //Header Array Parameter
3305
3306 this.quotestatusdesc = this.state.currentQuote.headerinfo.quotestatusdesc;
3307
3308 this.quotemanager = this.state.currentQuote.headerinfo.quotemanager;
3309
3310 this.tier1companyname = this.state.currentQuote.headerinfo.tier1companyname;
3311
3312 this.creatortype = this.state.currentQuote.headerinfo.creatortype;
3313
3314 this.bpreasoncode = this.state.currentQuote.headerinfo.bpreasoncode;
3315
3316 this.isquotevalid = this.state.currentQuote.headerinfo.isquotevalid;
3317
3318 this.quotestatus = this.state.currentQuote.headerinfo.quotestatus;
3319
3320 this.currencycode = this.state.currentQuote.headerinfo.currency;
3321
3322this.geocode = this.state.currentQuote.headerinfo.geocode;
3323
3324 this.ctrycode = this.state.currentQuote.headerinfo.ctrycode;
3325
3326 this.parent_val = this.state.currentQuote.headerinfo.parentcode;
3327
3328 }
3329
3330 if(this.state.currentQuote.hasOwnProperty('overviewdata')){
3331
3332 this.country = this.state.currentQuote.overviewdata.country;
3333
3334 this.quoteTitle = this.state.currentQuote.overviewdata.quotetitle;
3335
3336 }
3337
3338
3339 if(this.state.currentQuote.hasOwnProperty('pricingdata')){
3340
3341 this.autoRebalancecheckFlag = this.state.currentQuote.pricingdata.rebalance;
3342 }
3343
3344if(this.state.currentQuote.hasOwnProperty('bidjustificationdata')){
3345
3346 this.bpcomments = this.state.currentQuote.bidjustificationdata.comments;
3347
3348}
3349
3350
3351 this.bidType = this.state.currentQuote.bidtype;
3352
3353 this.quoteid = this.state.currentQuote.quoteid;
3354
3355 this.id = this.state.currentQuote.quoteid;
3356
3357//Clear Header Array
3358this.header_val = [];
3359
3360this.header_val.push({'geocode':this.geocode,
3361 'quotestatusdesc':this.quotestatusdesc,
3362 'quotemanager':this.quotemanager,
3363 'tier1companyname':this.tier1companyname,
3364 'creatortype':this.creatortype,
3365 'bpreasoncode':this.bpreasoncode,
3366 'isquotevalid':this.isquotevalid,
3367 'quotestatus':this.quotestatus,
3368 'currencycode':this.currencycode,
3369 'currency':this.currencycode,
3370 'parent':this.parent_val,
3371 'id':this.id,
3372 'ctrycode':this.ctrycode
3373});
3374
3375let componentpriceslist_arr :any[]= [];
3376this.state.currentQuote.pricingdata.compinfo.forEach(element => {
3377 componentpriceslist_arr.push({
3378 'eudiscount': element.enduserdiscount,
3379 'id': element.id,
3380 'enduserprice': element.enduserprice,
3381 'quantity': element.quantity
3382})
3383});
3384
3385this.componentpriceslist = JSON.stringify(componentpriceslist_arr);
3386//this.componentpriceslist = this.componentpriceslist.replace(/"/g,"\\\"");
3387
3388this.rt_val = {
3389'ccmsnb':this.ccmsnb,
3390'customertypecode':this.customertypecode,
3391'decMakersEmail':this.decMakersEmail,
3392'decMakersName':this.decMakersName,
3393'decMakersProjName':this.decMakersProjName,
3394'decMakersTitle':this.decMakersTitle,
3395'bidType':this.bidType,
3396'country':this.country,
3397'countrycode':this.countrycode,
3398'addresstype':this.addresstype,
3399'custCode':this.custCode,
3400'ctrycode':this.ctrycode,
3401'quoteid':this.quoteid,
3402'bpcomments':this.bpcomments,
3403'autoRebalancecheckFlag':this.autoRebalancecheckFlag,
3404'installAddress':JSON.stringify(this.state.currentQuote.installAddress_val),
3405'dealReglist':this.dealReglist_val,
3406'header':this.header_val,
3407'selectedSbcList':this.selectedSbcList_val,
3408'quoteTitle':this.quoteTitle,
3409'geocode':this.geocode,
3410'sp1bpcontactemail':this.sp1bpcontactemail,
3411'sp1bptypedescription':this.sp1bptypedescription,
3412'sp1bpcontactname':this.sp1bpcontactname,
3413'sp1requesterphone':this.sp1requesterphone,
3414'channelinfo':this.channelInformationItem.channelinfo,
3415'isVnsp':this.channelInformationItem.isVnsp,
3416'pricelevel': "Component",
3417'componentpriceslist': this.componentpriceslist
3418};
3419
3420//End
3421
3422return this.rt_val;
3423
3424}
3425
3426save()
3427{
3428
3429 let temp;
3430 temp = this.state.currentQuote.sbcinfo;
3431
3432if(this.valCheckForSave() === '1'){
3433
3434
3435this.submit_data = this.retrivesubmitdata();
3436
3437let loading_op = this.loading.create({
3438 content: 'Loading...',
3439 });
3440 loading_op.present();
3441
3442this.quoteService.saverequestpriceinfo(this.submit_data)
3443 .then((data_header: any[]) => {
3444 //set results to be displayed
3445
3446 this.save_status = data_header;
3447
3448 if(this.save_status.hasOwnProperty('_body')){
3449
3450 let alert = this.alertCtrl.create({
3451 title:this.title,
3452 subTitle: 'Technical Exception Occured !! Try Again',
3453 buttons: ['Ok']
3454 });
3455 alert.present();
3456
3457 //remove the spinner
3458 loading_op.dismiss();
3459
3460 }
3461 else{
3462
3463 if(this.save_status.status == '1' && this.save_status.items[0].degregsave[0].status == '1')
3464 {
3465
3466 this.quoteService.ValidateandSaveHeaderInfo(this.state.currentQuote.ctrycode,this.state.currentQuote.headerinfo.geocode,this.state.currentQuote.quoteid,this.add_bks)
3467 .then((data: any) => {
3468
3469 if(data.validationfail === "true")
3470 {
3471
3472 let alert = this.alertCtrl.create({
3473 title: 'Submit Price Request',
3474 subTitle: 'Invalid Add Special Bid Request',
3475 buttons: ['Ok']
3476 });
3477 alert.present();
3478 loading_op.dismiss();
3479
3480}
3481 else
3482 {
3483
3484 this._ngZone.run(() => {
3485
3486 if(this.save_status.items[0].degregsave[0].items[0].dealregnumlist[0].errordescription == 'FAILURE'){
3487
3488 let alert = this.alertCtrl.create({
3489 title:this.title,
3490 subTitle: 'Invalid Deal Reg Id Found !!',
3491 buttons: ['Ok']
3492 });
3493 alert.present();
3494
3495//remove the spinner
3496loading_op.dismiss();
3497
3498 }
3499 else{
3500
3501 this.quoteService.load(this.state.currentQuote.quoteid)
3502 .then((data: any) => {
3503
3504 this.state.currentQuote = data;
3505
3506 this.state.currentQuote.sbcinfo = temp;
3507
3508 for (let i = 0; i < this.add_cart.length; i++) {
3509 if(this.add_tre){
3510
3511 if (this.add_tre.selectedsbc[0].code == this.add_cart[i].code) {
3512 //already has it
3513 this.add_cart.splice(i, 1);
3514
3515 } else {}
3516
3517
3518 }
3519
3520}
3521
3522 this.installAddressCount = 2;
3523 this.state.currentQuote.installAddress_val = [];//shivam
3524
3525 if(this.state.currentQuote.installaddress){
3526
3527 for (let kt = 0; kt < this.state.currentQuote.installaddress.length; kt++) {
3528
3529 this.state.currentQuote.installAddress_val.push({'address1':this.state.currentQuote.installaddress[kt].streetaddress1,'address2':this.state.currentQuote.installaddress[kt].streetaddress2,'city':this.state.currentQuote.installaddress[kt].city,'state':this.state.currentQuote.installaddress[kt].regionid,"addressid":String(kt)});
3530
3531 //this.installAddress_val.push({'address1':this.state.currentQuote.installaddress[kt].streetaddress1,'address2':this.state.currentQuote.installaddress[kt].streetaddress2,'city':this.state.currentQuote.installaddress[kt].city,'state':this.state.currentQuote.installaddress[kt].regionid,"addressid":String(this.installAddressid)});
3532
3533 this.installAddressCount++;
3534
3535 //this.installAddressid++;
3536
3537 }
3538
3539 this.cdr.detectChanges();
3540
3541 }
3542 let alert = this.alertCtrl.create({
3543 title:this.title,
3544 subTitle: 'Quote Saved',
3545 buttons: ['Ok']
3546 });
3547 alert.present();
3548
3549 //remove the spinner
3550loading_op.dismiss();
3551
3552 });
3553
3554
3555// let alert = this.alertCtrl.create({
3556// title:this.title,
3557// subTitle: 'Quote Saved',
3558// buttons: ['Ok']
3559// });
3560// alert.present();
3561
3562// //remove the spinner
3563// loading_op.dismiss();
3564
3565 }
3566
3567
3568
3569
3570 });
3571
3572
3573
3574
3575 }
3576
3577
3578
3579 });
3580
3581 }
3582 else{
3583
3584
3585
3586let alert = this.alertCtrl.create({
3587 title: this.title,
3588 subTitle: 'Error Found : Quote not Saved Successfully',
3589 buttons: ['Ok']
3590 });
3591 alert.present();
3592
3593
3594 //remove the spinner
3595loading_op.dismiss();
3596
3597 }
3598
3599
3600 }
3601
3602 }).catch((err) => {
3603 console.log("TODO:: save quote error, inform user.");
3604 console.log(err);
3605 //remove the spinner
3606 loading_op.dismiss();
3607 });
3608
3609
3610}else{
3611 let alert = this.alertCtrl.create({
3612 title:this.title,
3613 subTitle: String(this.valCheckForSave()),
3614 buttons: ['Ok']
3615 });
3616 alert.present();
3617}
3618
3619}
3620
3621submit()
3622{
3623
3624
3625 if(this.valcheck() == '1'){
3626
3627this.submit_data = this.retrivesubmitdata();
3628
3629
3630let loading_op = this.loading.create({
3631 content: 'Loading...',
3632 });
3633 loading_op.present();
3634
3635this.quoteService.submitrequestpriceinfo(this.submit_data)
3636 .then((data: any[]) => {
3637 //set results to be displayed
3638
3639 //remove the spinner
3640 loading_op.dismiss();
3641
3642 this.save_status = data;
3643
3644 if(this.save_status.status == '1'){
3645
3646 let alert = this.alertCtrl.create({
3647 title:this.title,
3648 subTitle: 'Quote Submited',
3649 buttons: ['Ok']
3650 });
3651 alert.present();
3652
3653this.quoteService.load(this.state.currentQuote.quoteid)
3654 .then((data: any) => {
3655
3656 //Update View Data
3657
3658 this._ngZone.run(() => {
3659 this.state.currentQuote = {};
3660 this.state.currentQuote = data;
3661
3662 if(this.userData.receivePushNotificationStatus){
3663
3664
3665this.quoteService.pushNotificationStatus(this.state.currentQuote.quoteid,this.state.uniqueid,this.userData.email,'S',this.userData.userid,this.state.currentQuote.quotestatus,'Y')
3666 .then((data: any) =>
3667{
3668
3669this.state.pushSubmitMessage = "Quote Submitted "+this.state.currentQuote.quoteid+"-"+this.state.currentQuote.headerinfo.quotestatusdesc;
3670
3671this.quoteService.pushNotificationSent(this.state.uniqueid,this.state.appguid,this.state.appsecret,this.state.pushSubmitMessage)
3672 .then((data: any) => {
3673
3674 // this.navCtrl.push(ViewquotesPage,{});
3675 this.navCtrl.popToRoot();
3676
3677 });
3678
3679});
3680
3681 }
3682
3683 else{
3684
3685 // this.navCtrl.push(ViewquotesPage,{});
3686 this.navCtrl.popToRoot();
3687
3688 }
3689
3690 });
3691
3692
3693 });
3694
3695 }
3696 else{
3697
3698 let alert = this.alertCtrl.create({
3699 title: this.title,
3700 subTitle: 'Error Found : Quote has not Submited Successfully',
3701 buttons: ['Ok']
3702 });
3703 alert.present();
3704
3705
3706 }
3707
3708
3709 }).catch((err) => {
3710 console.log("TODO:: submit quote error, inform user.");
3711 console.log(err);
3712 //remove the spinner
3713 loading_op.dismiss();
3714 });
3715
3716
3717
3718}
3719else{
3720
3721 let alert = this.alertCtrl.create({
3722 title: 'Submit Price Request',
3723 subTitle: String(this.valcheck()),
3724 buttons: ['Ok']
3725 });
3726 alert.present();
3727
3728}
3729
3730
3731}
3732
3733
3734returnToT2(){
3735
3736this.submit_data = this.retrivesubmitdata();
3737
3738let alert = this.alertCtrl.create({
3739 title: 'Comments to requester',
3740 inputs: [
3741 {
3742 name: 'comments',
3743 placeholder: 'Enter comments',
3744 type : 'textarea'
3745 },
3746 ],
3747 buttons: [
3748 {
3749 text: 'Cancel',
3750 role: 'cancel',
3751 handler: data => {
3752 console.log('Cancel clicked');
3753 }
3754 },
3755 {
3756 text: 'Ok',
3757 handler: data => {
3758 this.submit_data.content = "<p>"+data.comments+"</p>";
3759 return true;
3760 }
3761 }
3762 ]
3763});
3764alert.present();
3765
3766let loading_op = this.loading.create({
3767 content: 'Loading...',
3768 });
3769 loading_op.present();
3770
3771this.quoteService.returntotwoinfo(this.submit_data)
3772 .then((data: any[]) => {
3773 //set results to be displayed
3774
3775 //remove the spinner
3776 loading_op.dismiss();
3777 this.save_status = data;
3778 if(this.save_status.status == '1'){
3779
3780 let alert = this.alertCtrl.create({
3781 title:this.title,
3782 subTitle: 'Return to Distributor',
3783 buttons: ['Ok']
3784 });
3785 alert.present();
3786
3787 this.navCtrl.setRoot(HomePage);
3788
3789
3790 }
3791 else{
3792
3793 let alert = this.alertCtrl.create({
3794 title: this.title,
3795 subTitle: 'Error Found : Does not Return to Distributor',
3796 buttons: ['Ok']
3797 });
3798 alert.present();
3799
3800
3801 }
3802
3803
3804 }).catch((err) => {
3805 console.log("TODO:: returntoT2 error, inform user.");
3806 console.log(err);
3807 //remove the spinner
3808 loading_op.dismiss();
3809 });
3810
3811}
3812
3813
3814
3815//End
3816
3817//Round of Value into two digit after decimal
3818
3819Round(number):number
3820{
3821 return parseFloat(Number((number/1000) / 60).toFixed(2));
3822}
3823
3824
3825itemSelected(item){
3826
3827this.generic_modal_val = '';
3828
3829this.generic_modal_val = item;
3830
3831}
3832
3833
3834
3835//End
3836
3837
3838
3839
3840
3841//Collect Sub Product Special Bid Value
3842
3843sbcproval(val){
3844
3845this.generic_val_drop = [];
3846
3847this.generic_edited_drop = true;
3848
3849this.generic_edited = false;
3850
3851this.submit_pricing_productlevelspecialcode = false;
3852
3853this.price_request_done_button = true;
3854
3855this.generic_val_drop.push(val);
3856
3857this.cdr.detectChanges();
3858
3859}
3860
3861
3862sbcDataToSpecialBidCodesList(){
3863
3864this.pro_cart = [];
3865
3866
3867if ("sbclist" in this.state.currentQuote) {
3868
3869for(let m=0; m<this.state.currentQuote.productswithcfr.length;m++)
3870 {
3871
3872for(let j=0; j<this.state.currentQuote.productswithcfr[m].products.length;j++)
3873 {
3874 for(let i=0;i<this.state.currentQuote.sbclist[0].componentsbc.length;i++)
3875 {
3876 if(this.state.currentQuote.sbclist[0].componentsbc[i].componentid == this.state.currentQuote.productswithcfr[m].products[j].id)
3877 {
3878
3879 this.Value ={};
3880
3881 this.Value.options = this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcodelist;
3882 this.Value.optionsWithoutPrerequisite = [];
3883 this.Value.prerequisite = [];
3884 for(var k=0; k < this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcodelist.length;k++)
3885 {
3886 if(this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcodelist[k].prerequisitesbcodelist == "")
3887 {
3888
3889 this.Value.optionsWithoutPrerequisite.push(this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcodelist[k]);
3890
3891 this.pro_cart.push(this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcodelist[k]);
3892 }
3893 else
3894 {
3895 this.Value.prerequisite.push(this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcodelist[k]);
3896 }
3897 }
3898
3899
3900
3901
3902 this.newItem.quotePriceRequest.componentpriceslist.specialBidCodesList.push(this.Value);
3903
3904 this.newItem.quotePriceRequest.componentpriceslist.selectedOptionOfSelectedBox1="";
3905
3906 break;
3907 }
3908 }
3909 }
3910
3911 }
3912
3913}
3914
3915
3916
3917
3918 }
3919
3920
3921//Already Applied Sbc
3922
3923sbcToSpecialBidCodesList(){
3924
3925if(!this.removeForwardArrow && "sbclist" in this.state.currentQuote && typeof this.state.currentQuote.sbclist!== "undefined"){
3926
3927for(let m=0; m<this.state.currentQuote.productswithcfr.length;m++){
3928
3929for(let j=0; j<this.state.currentQuote.productswithcfr[m].products.length;j++)
3930 {
3931 for(let i=0;i<this.state.currentQuote.sbclist[0].componentsbc.length;i++)
3932 {
3933
3934if(this.compareComponentId(this.state.currentQuote.sbclist[0].componentsbc[i].componentid,this.state.currentQuote.productswithcfr[m].products[j].id))
3935 {
3936
3937
3938 //Exception Filter of Sbc array
3939
3940
3941 this.filterSbcByException(this.state.currentQuote.sbclist[0].componentsbc[i].sbcexception,this.newItem.quotePriceRequest.componentpriceslist.specialBidCodesList[0].options);
3942
3943 //Applied SBC Array
3944
3945
3946if(this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode1 && this.state.currentQuote.sbclist[0].componentsbc[i].componentid == this.proComponentId)
3947{
3948
3949this.alreadyAppliedSbc('1',this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode1,this.state.currentQuote.sbclist[0].componentsbc[i].componentid,this.newItem.quotePriceRequest.headerSbcList,'');
3950
3951this.newItem.quotePriceRequest.componentpriceslist.selectBox.push({'level':'1','sbccode':this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode1,'componentid':this.state.currentQuote.sbclist[0].componentsbc[i].componentid});
3952
3953
3954if(this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode1 && this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode2 && this.state.currentQuote.sbclist[0].componentsbc[i].componentid == this.proComponentId){
3955
3956this.alreadyAppliedSbc('2',this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode2,this.state.currentQuote.sbclist[0].componentsbc[i].componentid,this.newItem.quotePriceRequest.headerSbcList,this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode1);
3957
3958this.newItem.quotePriceRequest.componentpriceslist.selectBox.push({'level':'2','sbccode':this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode2,'componentid':this.state.currentQuote.sbclist[0].componentsbc[i].componentid});
3959
3960if(this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode1 && this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode2 && this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode3 && this.state.currentQuote.sbclist[0].componentsbc[i].componentid == this.proComponentId){
3961
3962this.alreadyAppliedSbc('3',this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode3,this.state.currentQuote.sbclist[0].componentsbc[i].componentid,this.newItem.quotePriceRequest.headerSbcList,this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode2);
3963
3964this.newItem.quotePriceRequest.componentpriceslist.selectBox.push({'level':'3','sbccode':this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode3,'componentid':this.state.currentQuote.sbclist[0].componentsbc[i].componentid});
3965
3966
3967if(this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode1 && this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode2 && this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode3 && this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode4 && this.state.currentQuote.sbclist[0].componentsbc[i].componentid == this.proComponentId){
3968
3969this.alreadyAppliedSbc('4',this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode4,this.state.currentQuote.sbclist[0].componentsbc[i].componentid,this.newItem.quotePriceRequest.headerSbcList,this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode3);
3970
3971this.newItem.quotePriceRequest.componentpriceslist.selectBox.push({'level':'4','sbccode':this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode4,'componentid':this.state.currentQuote.sbclist[0].componentsbc[i].componentid});
3972
3973if(this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode1 && this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode2 && this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode3 && this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode4 && this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode5 && this.state.currentQuote.sbclist[0].componentsbc[i].componentid == this.proComponentId){
3974
3975this.alreadyAppliedSbc('5',this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode5,this.state.currentQuote.sbclist[0].componentsbc[i].componentid,this.newItem.quotePriceRequest.headerSbcList,this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode4);
3976
3977this.newItem.quotePriceRequest.componentpriceslist.selectBox.push({'level':'5','sbccode':this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode5,'componentid':this.state.currentQuote.sbclist[0].componentsbc[i].componentid});
3978
3979if(this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode1 && this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode2 && this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode3 && this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode4 && this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode5 && this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode6 && this.state.currentQuote.sbclist[0].componentsbc[i].componentid == this.proComponentId){
3980
3981this.alreadyAppliedSbc('6',this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode6,this.state.currentQuote.sbclist[0].componentsbc[i].componentid,this.newItem.quotePriceRequest.headerSbcList,this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode5);
3982
3983this.newItem.quotePriceRequest.componentpriceslist.selectBox.push({'level':'6','sbccode':this.state.currentQuote.sbclist[0].componentsbc[i].specialbidcode6,'componentid':this.state.currentQuote.sbclist[0].componentsbc[i].componentid});
3984
3985}}}}}
3986
3987this.addExtraSpecialBidCodesList(this.newItem.quotePriceRequest.headerSbcList);
3988
3989}
3990else{
3991
3992this.alreadyAppliedSbc('1','',this.state.currentQuote.sbclist[0].componentsbc[i].componentid,this.newItem.quotePriceRequest.headerSbcList,'');
3993
3994}
3995
3996
3997
3998
3999 }
4000 }
4001 }
4002
4003
4004}
4005
4006}
4007
4008
4009
4010}
4011
4012//End
4013
4014
4015//Compare Component Id
4016
4017compareComponentId(productcomponentId:any,sbccomponentid:any){
4018
4019if(productcomponentId == sbccomponentid){
4020
4021
4022return true;
4023}
4024else{
4025
4026return false;
4027
4028}
4029
4030
4031}
4032
4033
4034//Filter Data Through SBC Exception
4035
4036filterSbcByException(sbcexceptionvalue:any,sbcproductarray:any){
4037
4038
4039this.newItem.quotePriceRequest.headerSbcList = [];
4040
4041//Allow Only sbc array
4042
4043for(let l = 0; l < sbcexceptionvalue.split(',').length; l++)
4044{
4045
4046for(let m = 0; m < sbcproductarray.length; m++)
4047{
4048
4049if(sbcexceptionvalue.split(',')[l] == sbcproductarray[m].code)
4050{
4051
4052this.newItem.quotePriceRequest.headerSbcList.push(sbcproductarray[m]);
4053
4054}
4055
4056}
4057
4058}
4059
4060return this.newItem.quotePriceRequest.headerSbcList;
4061
4062
4063}
4064
4065
4066
4067
4068
4069//Already Applied SBC
4070
4071alreadyAppliedSbc(level:any,sbcdescription:any,componentid:any,headersbcarrray:any,previoussbc:any){
4072
4073
4074if(sbcdescription)
4075{
4076
4077this.newItem.quotePriceRequest.headerSbcList = [];
4078
4079let filterdArray: any[] = headersbcarrray.filter(f => f !== undefined && f !== null) as any;
4080
4081this.newItem.quotePriceRequest.headerSbcList = filterdArray;
4082
4083if(previoussbc == ''){
4084
4085this.newItem.quotePriceRequest.previousLastSbc = '';
4086
4087this.newItem.quotePriceRequest.previousLastSbc = sbcdescription;
4088
4089this.newItem.quotePriceRequest.selectedSbcList.push({'level':level,'componentid':componentid,'selectedsbc':sbcdescription,'selecteddescription':this.selDescriptionFind(sbcdescription),'item':headersbcarrray.filter(f => f !== undefined && f !== null)});
4090
4091}
4092else{
4093
4094for(let l = 0; l < headersbcarrray.filter(f => f !== undefined && f !== null).length; l++)
4095{
4096
4097if(headersbcarrray.filter(f => f !== undefined && f !== null)[l].code == previoussbc)
4098{
4099
4100//Noncombinational
4101
4102this.splicedArr(l,headersbcarrray.filter(f => f !== undefined && f !== null),previoussbc,sbcdescription,headersbcarrray.filter(f => f !== undefined && f !== null)[l].noncombinablespecialbidcodelist);
4103
4104this.newItem.quotePriceRequest.selectedSbcList.push({'level':level,'componentid':componentid,'selectedsbc':sbcdescription,'selecteddescription':this.selDescriptionFind(sbcdescription),'item':this.newItem.quotePriceRequest.headerSbcList});
4105
4106//End
4107
4108if(headersbcarrray.filter(f => f !== undefined && f !== null)[l] == 'undefined' || headersbcarrray.filter(f => f !== undefined && f !== null)[l] === undefined || headersbcarrray.filter(f => f !== undefined && f !== null)[l] === null || headersbcarrray.filter(f => f !== undefined && f !== null)[l] == ''){
4109
4110}
4111else{
4112//DependencyonSBC Logic
4113
4114if(headersbcarrray.filter(f => f !== undefined && f !== null)[l].dependencyonsbc && headersbcarrray.filter(f => f !== undefined && f !== null)[l].dependencyonsbc.split(',').length > 0){
4115
4116if(this.dependencyOnSbc(headersbcarrray.filter(f => f !== undefined && f !== null)[l].dependencyonsbc,level,componentid)){
4117if(this.spliceSelectSbcList(level,componentid) != -1){
4118this.newItem.quotePriceRequest.selectedSbcList.splice(this.spliceSelectSbcList(level,componentid),1);
4119}}
4120
4121}
4122
4123//End
4124
4125//Prequistic Logic
4126
4127if(headersbcarrray.filter(f => f !== undefined && f !== null)[l].prerequisitesbcodelist && headersbcarrray.filter(f => f !== undefined && f !== null)[l].prerequisitesbcodelist.split(',').length > 0){
4128
4129if(this.prequisticSbcList(headersbcarrray.filter(f => f !== undefined && f !== null)[l].prerequisitesbcodelist,level,componentid) == -1){
4130this.newItem.quotePriceRequest.selectedSbcList.splice(this.spliceSelectSbcList(level,componentid),1);
4131}}
4132
4133//End
4134
4135//MutualExclusiveList Logic
4136
4137if(headersbcarrray.filter(f => f !== undefined && f !== null)[l].mutualexclusivelist && headersbcarrray.filter(f => f !== undefined && f !== null)[l].mutualexclusivelist.split(',').length > 0){
4138
4139if(this.mutualexclusivelistSbcList(headersbcarrray.filter(f => f !== undefined && f !== null)[l].mutualexclusivelist,level) == -1){
4140this.newItem.quotePriceRequest.selectedSbcList.splice(this.spliceSelectSbcList(level,componentid),1);
4141}}
4142
4143//End
4144
4145}
4146
4147
4148}
4149
4150else{
4151
4152
4153}
4154
4155}
4156
4157}
4158
4159
4160
4161
4162}
4163else{
4164
4165//When SBC has not applied
4166
4167this.newItem.quotePriceRequest.selectedSbcList.push({'level':level,'componentid':componentid,'selectedsbc':'','selecteddescription':'','item':headersbcarrray});
4168
4169}
4170
4171}
4172
4173
4174
4175selDescriptionFind(sbccode:any){
4176
4177for(let l = 0; l < this.newItem.quotePriceRequest.componentpriceslist.specialBidCodesList.length; l++)
4178{
4179
4180for(let m = 0; m < this.newItem.quotePriceRequest.componentpriceslist.specialBidCodesList[l].options.length; m++)
4181{
4182
4183if(sbccode == this.newItem.quotePriceRequest.componentpriceslist.specialBidCodesList[l].options[m].code)
4184{
4185
4186return this.newItem.quotePriceRequest.componentpriceslist.specialBidCodesList[l].options[m].description;
4187
4188}}}
4189
4190
4191}
4192
4193
4194splicedArr(dt_new:any,filterdArray:any,previoussbc:any,currentsbc:any,noncombinational:any){
4195
4196this.newItem.quotePriceRequest.optionsOfSelectBox2 = [];
4197
4198this.newItem.quotePriceRequest.optionsOfSelectBox2 = filterdArray;
4199
4200for(let m = 0; m < noncombinational.split(',').length; m++)
4201{
4202
4203for(let l= 0; l < filterdArray.length; l++)
4204{
4205
4206if(filterdArray[l] == 'undefined' || filterdArray[l] === undefined || filterdArray[l] === null || filterdArray[l] == ''){
4207
4208
4209}
4210else{
4211
4212if(parseInt(noncombinational.split(',')[m]) == parseInt(filterdArray[l].code) && parseInt(noncombinational.split(',')[m]) != currentsbc)
4213{
4214
4215filterdArray.splice(l,1);
4216
4217}
4218
4219}
4220
4221}
4222
4223}
4224
4225this.preSbc(filterdArray,previoussbc,currentsbc);
4226
4227}
4228
4229//Select One DropDown
4230
4231
4232addExtraSpecialBidCodesList(headerSbcList:any[])
4233{
4234
4235//Intialise MasterSbclist to Null
4236
4237this.newItem.quotePriceRequest.masterSbcList = [];
4238
4239this.newItem.quotePriceRequest.addExtraSbcBox = [];
4240
4241//this.newItem.quotePriceRequest.addExtraSbcBox.push(headerSbcList);
4242
4243
4244//Retrive Product Level component only in Master SbcList
4245
4246
4247for(let m = 0; m <this.newItem.quotePriceRequest.selectedSbcList.length;m++){
4248
4249if(this.newItem.quotePriceRequest.selectedSbcList[m].componentid == this.proComponentId){
4250
4251this.newItem.quotePriceRequest.masterSbcList.push(this.newItem.quotePriceRequest.selectedSbcList[m]);
4252
4253}
4254
4255
4256}
4257
4258
4259
4260headerSbcList.forEach((v, i) => {
4261 const val = (typeof v === 'object') ? Object.assign({}, v) : v;
4262 this.newItem.quotePriceRequest.addExtraSbcBox.push(val);
4263});
4264
4265//Add Additional Select DropDown
4266
4267for(let i = 0; i <this.newItem.quotePriceRequest.addExtraSbcBox.length;i++)
4268{
4269
4270if(this.newItem.quotePriceRequest.previousLastSbc == this.newItem.quotePriceRequest.addExtraSbcBox[i].code){
4271
4272this.newItem.quotePriceRequest.addExtraSbcBox.splice(i,1);
4273
4274}
4275
4276}
4277
4278
4279this.newItem.quotePriceRequest.selectedSbcList.push({'level':parseInt(this.newItem.quotePriceRequest.masterSbcList[this.newItem.quotePriceRequest.masterSbcList.length - 1].level) + 1,'componentid':this.newItem.quotePriceRequest.masterSbcList[this.newItem.quotePriceRequest.masterSbcList.length - 1].componentid,'selectedsbc':'','selecteddescription':'','item':this.newItem.quotePriceRequest.addExtraSbcBox});
4280
4281}
4282
4283
4284//Remove Previous SBC
4285
4286preSbc(filterdArray:any,previoussbc:any,currentsbc:any)
4287{
4288
4289this.newItem.quotePriceRequest.previousLastSbc = '';
4290
4291this.newItem.quotePriceRequest.previousLastSbc = currentsbc;
4292
4293
4294
4295if(previoussbc && filterdArray.length > 0)
4296{
4297
4298for(let l= 0; l < filterdArray.length; l++)
4299{
4300
4301if(filterdArray[l] == 'undefined' || filterdArray[l] === undefined || filterdArray[l] === null || filterdArray[l] == '' || filterdArray[l] == null){
4302
4303
4304}
4305else{
4306
4307
4308
4309if(filterdArray[l].code){
4310
4311if(parseInt(currentsbc) !== parseInt(filterdArray[l].code))
4312{
4313
4314if(parseInt(previoussbc) === parseInt(filterdArray[l].code)){
4315
4316
4317filterdArray.splice(l,1);
4318
4319}
4320
4321
4322}
4323
4324
4325}
4326
4327}
4328
4329}
4330
4331this.newItem.quotePriceRequest.headerSbcList = [];
4332
4333filterdArray.forEach((v, i) => {
4334 const val = (typeof v === 'object') ? Object.assign({}, v) : v;
4335 this.newItem.quotePriceRequest.headerSbcList.push(val);
4336});
4337
4338}
4339
4340else{}
4341
4342
4343}
4344
4345
4346
4347dependencyOnSbc(dependsbc:any,leval:any,componentid:any){
4348
4349if(dependsbc.length > 0){
4350
4351for(let m = 0; m < dependsbc.split(',').length; m++)
4352{
4353
4354for(let n = 0; n < this.newItem.quotePriceRequest.componentpriceslist.specialBidCodesList[this.pro_index].options.length; n++)
4355{
4356if(componentid != this.newItem.quotePriceRequest.componentpriceslist.specialBidCodesList[this.pro_index].options[n].id)
4357{
4358
4359if(dependsbc.split(',')[m] == this.newItem.quotePriceRequest.componentpriceslist.specialBidCodesList[this.pro_index].options[n].code)
4360{
4361
4362return true;
4363
4364}}}}
4365
4366return false;
4367
4368}
4369}
4370
4371//Index of Splice Sbc List
4372spliceSelectSbcList(level:any,componentid:any){
4373
4374for(let n = 0; n < this.newItem.quotePriceRequest.selectedSbcList.length; n++)
4375{
4376
4377if(this.newItem.quotePriceRequest.selectedSbcList[n].level == level && this.newItem.quotePriceRequest.selectedSbcList[n].componentid == componentid){
4378
4379return n;
4380
4381}}
4382
4383return -1;
4384
4385}
4386
4387prequisticSbcList(prequisticsbc:any,leval:any,componentid:any){
4388
4389if(prequisticsbc.length > 0){
4390
4391for(let m = 0; m < prequisticsbc.split(',').length; m++)
4392{
4393
4394for(let n = 0; n < this.newItem.quotePriceRequest.componentpriceslist.selectBox.length; n++)
4395{
4396
4397if(this.newItem.quotePriceRequest.componentpriceslist.selectBox[n].sbccode == prequisticsbc.split(',')[m] && this.newItem.quotePriceRequest.componentpriceslist.selectBox[n].componentid != componentid)
4398{
4399
4400return true;
4401
4402}}
4403
4404}
4405
4406return -1;
4407}
4408}
4409
4410getSbcInfo(item:any,level:any){
4411
4412if(this.updateSelectedSbc(item,level) != -1){}
4413
4414else{
4415
4416if(this.newItem.quotePriceRequest.componentpriceslist.selectBox.length == 0){
4417
4418this.newItem.quotePriceRequest.componentpriceslist.selectBox.push({'level':'1','sbccode':item,'componentid':parseInt(this.pro_index) + 1});
4419
4420}
4421else{
4422
4423this.newItem.quotePriceRequest.componentpriceslist.selectBox.push({'level':parseInt(this.newItem.quotePriceRequest.componentpriceslist.selectBox[this.newItem.quotePriceRequest.componentpriceslist.selectBox.length - 1].level) + 1,'sbccode':item,'componentid':parseInt(this.pro_index) + 1});
4424
4425}
4426
4427
4428
4429}
4430
4431this.applyHeaderArray(this.newItem.quotePriceRequest.componentpriceslist.selectBox.length);
4432
4433}
4434
4435updateSelectedSbc(sbccode:any,level:any){
4436
4437for (var i = 0; i < this.newItem.quotePriceRequest.componentpriceslist.selectBox.length; i++) {
4438 if (this.newItem.quotePriceRequest.componentpriceslist.selectBox[i].level === level && this.newItem.quotePriceRequest.componentpriceslist.selectBox[i].componentid == parseInt(this.pro_index) + 1) {
4439 this.newItem.quotePriceRequest.componentpriceslist.selectBox[i].sbccode = sbccode;
4440 return i;
4441 }
4442 }
4443
4444 return -1;
4445}
4446
4447applyHeaderArray(len:any){
4448
4449//Initialize to null for Compound Array List
4450
4451this.compsbclist = [];
4452
4453if(len > 0){
4454
4455if(len == 1){
4456 this.compsbclist.unshift({"id":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len - 1].componentid,"specialBidcode1":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len - 1].sbccode,"specialBidcode2":"","specialBidcode3":"","specialBidcode4":"","specialBidcode5":"","specialBidcode6":""});
4457
4458 }
4459 else if(len == '2'){
4460 this.compsbclist.unshift({"id":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len - 2].componentid,"specialBidcode1":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len - 2].sbccode,"specialBidcode2":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len -1].sbccode,"specialBidcode3":"","specialBidcode4":"","specialBidcode5":"","specialBidcode6":""});
4461 }
4462
4463 else if(len == '3'){
4464 this.compsbclist.unshift({"id":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len - 3].componentid,"specialBidcode1":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len - 3].sbccode,"specialBidcode2":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len -2].sbccode,"specialBidcode3":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len - 1].sbccode,"specialBidcode4":"","specialBidcode5":"","specialBidcode6":""});
4465
4466 }
4467
4468 else if(len == '4'){
4469
4470 this.compsbclist.unshift({"id":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len - 4].componentid,"specialBidcode1":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len - 4].sbccode,"specialBidcode2":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len -3].sbccode,"specialBidcode3":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len - 2].sbccode,"specialBidcode4":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len - 1].sbccode,"specialBidcode5":"","specialBidcode6":""});
4471
4472
4473 }
4474
4475 else if(len == '5'){
4476
4477 this.compsbclist.unshift({"id":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len - 5].componentid,"specialBidcode1":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len - 5].sbccode,"specialBidcode2":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len -4].sbccode,"specialBidcode3":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len - 3].sbccode,"specialBidcode4":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len - 2].sbccode,"specialBidcode5":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len - 1].sbccode,"specialBidcode6":""});
4478
4479
4480 }
4481
4482 else{
4483
4484this.compsbclist.unshift({"id":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len - 6].componentid,"specialBidcode1":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len - 6].sbccode,"specialBidcode2":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len -5].sbccode,"specialBidcode3":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len - 4].sbccode,"specialBidcode4":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len - 3].sbccode,"specialBidcode5":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len - 2].sbccode,"specialBidcode6":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len - 1].sbccode});
4485
4486 }
4487
4488
4489}
4490else{
4491
4492this.compsbclist.unshift({"id":this.newItem.quotePriceRequest.componentpriceslist.selectBox[len].componentid,"specialBidcode1":"","specialBidcode2":"","specialBidcode3":"","specialBidcode4":"","specialBidcode5":"","specialBidcode6":""});
4493
4494}
4495
4496}
4497
4498
4499applyHeaderService(){
4500
4501 this.loader = this.loading.create({
4502 content: 'Loading...',
4503 });
4504 this.loader.present();
4505
4506this.quoteService.applyAndSaveHeaderSBC(this.state.currentQuote.quoteid,'false',this.compsbclist)
4507 .then((data: any) => {
4508 this.loader.dismiss();
4509
4510 if(data.status == "1"){
4511 this.quoteService.load(this.state.currentQuote.quoteid)
4512 .then((data: any) => {
4513
4514 //Update View Data
4515
4516 this._ngZone.run(() => {
4517 this.state.currentQuote = {};
4518 this.state.currentQuote = data;
4519
4520 this.price_request_done_button = false;
4521
4522this.edtproductquotesbc(data.pricingdata.compinfo[this.pro_index],this.pro_index);
4523
4524 });
4525
4526 });
4527
4528 }
4529 else{}
4530 });
4531
4532}
4533
4534
4535mutualexclusivelistSbcList(mutualexclusivelist:any,level:any){
4536
4537if(mutualexclusivelist.length > 0){
4538
4539for(let m = 0; m < mutualexclusivelist.split(',').length; m++)
4540{
4541
4542for(let n = 0; n < this.newItem.quotePriceRequest.componentpriceslist.selectBox.length; n++)
4543{
4544
4545if(this.newItem.quotePriceRequest.componentpriceslist.selectBox[n].sbccode == mutualexclusivelist.split(',')[m])
4546{
4547
4548return true;
4549
4550}}
4551
4552}
4553
4554return -1;
4555}
4556
4557
4558}
4559
4560
4561selectedSbcLevel(sbccode:any){
4562
4563for (var i = 0; i < this.newItem.quotePriceRequest.componentpriceslist.specialBidCodesList.length; i++) {
4564
4565for (var j = 0; j < this.newItem.quotePriceRequest.componentpriceslist.specialBidCodesList[i].options.length; j++)
4566{
4567
4568if (this.newItem.quotePriceRequest.componentpriceslist.specialBidCodesList[i].options[j].code === sbccode) {
4569
4570 return this.newItem.quotePriceRequest.componentpriceslist.specialBidCodesList[i].options[j].id;
4571 }
4572
4573
4574}
4575
4576
4577 }
4578
4579return -1;
4580
4581}
4582
4583
4584//Check array or object
4585
4586isArray(ob) {
4587 return (!!ob) && (ob.constructor === Array);
4588}
4589
4590//Check Validation
4591
4592valcheck(){
4593
4594 if(this.state.currentQuote.reginfolist.length < 1){
4595 return this.state.validateMessageDealRegNumber;
4596 }
4597
4598 else if(typeof this.state.currentQuote.reginfolist[0].registrationnumber == 'undefined'){
4599 return this.state.validateMessageDealRegNumber ;
4600 }
4601
4602 else if(!this.state.currentQuote.channelinfo.pcs.sp1bpcontactname){
4603 return this.state.validateMessageSP1ContactName;
4604 }
4605
4606 else if(!this.state.currentQuote.channelinfo.pcs.sp1bpcontactemail) {
4607 return this.state.validateMessageSP1ContactEmail;
4608 }
4609
4610 else if(this.state.currentQuote.issp2 === "false"
4611 && !this.state.currentQuote.channelinfo.pcs.sp2companyname){
4612 return this.state.validateMessageSP2CompanyName;
4613 }
4614
4615 else if(this.state.currentQuote.channelinfo.pcs.sp2companyname == " "){
4616 return this.state.validateMessageSP2CompanyName;
4617 }
4618
4619 else if(!this.state.currentQuote.hasOwnProperty('enduserinfo')){
4620 return this.state.validateMessageEndUserInfo;
4621 }
4622
4623else if(!this.state.currentQuote.decisionmaker.decisionmakername){
4624
4625return this.state.validateMessageDecisionMakerName;
4626
4627}
4628
4629else if(this.state.currentQuote.decisionmaker.decisionmakername && !this.state.currentQuote.decisionmaker.decisionmakertitle){
4630
4631return this.state.validateMessageDecisionMakerTitle;
4632
4633}
4634else if(this.state.currentQuote.decisionmaker.decisionmakername && this.state.currentQuote.decisionmaker.decisionmakertitle && !this.state.currentQuote.decisionmaker.decisionmakeremail){
4635
4636return this.state.validateMessageDecisionMakerEmailAddress;
4637
4638}
4639
4640
4641
4642else if(!this.state.currentQuote.channelinfo1.channelrepname && this.state.currentQuote.channelinfo1.ibmprodspecialist && this.state.currentQuote.decisionmaker.decisionmakername && this.state.currentQuote.decisionmaker.decisionmakertitle && this.state.currentQuote.decisionmaker.decisionmakeremail){
4643
4644return this.state.validateMessageChannelContactName;
4645
4646}
4647
4648else if(!this.state.currentQuote.channelinfo1.channelrepphone && this.state.currentQuote.channelinfo1.channelrepname && this.state.currentQuote.channelinfo1.ibmprodspecialist && this.state.currentQuote.decisionmaker.decisionmakername && this.state.currentQuote.decisionmaker.decisionmakertitle && this.state.currentQuote.decisionmaker.decisionmakeremail){
4649
4650return this.state.validateMessageChannelContactPhoneNo;
4651
4652}
4653
4654else if(!this.state.currentQuote.channelinfo1.channelrepemailad && this.state.currentQuote.channelinfo1.channelrepphone && this.state.currentQuote.channelinfo1.channelrepname && this.state.currentQuote.channelinfo1.ibmprodspecialist && this.state.currentQuote.decisionmaker.decisionmakername && this.state.currentQuote.decisionmaker.decisionmakertitle && this.state.currentQuote.decisionmaker.decisionmakeremail){
4655
4656return this.state.validateMessageChannelContactEmailAddress;
4657
4658}
4659
4660else if(!this.state.currentQuote.bidjustificationdata.comments && this.state.currentQuote.channelinfo1.channelrepemailad && this.state.currentQuote.channelinfo1.channelrepphone && this.state.currentQuote.channelinfo1.channelrepname && this.state.currentQuote.channelinfo1.ibmprodspecialist && this.state.currentQuote.decisionmaker.decisionmakername && this.state.currentQuote.decisionmaker.decisionmakertitle && this.state.currentQuote.decisionmaker.decisionmakeremail){
4661
4662return this.state.validateMessageBidJustification;
4663
4664}
4665
4666else if(!this.ibmContactEmailValidOnSubmit() && !this.state.currentQuote.bidjustificationdata.comments && this.state.currentQuote.channelinfo1.channelrepemailad && this.state.currentQuote.channelinfo1.channelrepphone && this.state.currentQuote.channelinfo1.channelrepname && this.state.currentQuote.channelinfo1.ibmprodspecialist && this.state.currentQuote.decisionmaker.decisionmakername && this.state.currentQuote.decisionmaker.decisionmakertitle && this.state.currentQuote.decisionmaker.decisionmakeremail){
4667
4668return this.state.validateMessageChannelContactEmailCheckAddress;
4669
4670}
4671
4672else if(!this.decisionMakerEmailValidOnSubmit() && !this.ibmContactEmailValidOnSubmit() && !this.state.currentQuote.bidjustificationdata.comments && this.state.currentQuote.channelinfo1.channelrepemailad && this.state.currentQuote.channelinfo1.channelrepphone && this.state.currentQuote.channelinfo1.channelrepname && this.state.currentQuote.channelinfo1.ibmprodspecialist && this.state.currentQuote.decisionmaker.decisionmakername && this.state.currentQuote.decisionmaker.decisionmakertitle && this.state.currentQuote.decisionmaker.decisionmakeremail){
4673
4674return this.state.validateMessageDecisionMakerEmailCheckAddress;
4675
4676}
4677
4678else if(!this.sponeContactEmailValidOnSubmit() && !this.decisionMakerEmailValidOnSubmit() && !this.ibmContactEmailValidOnSubmit() && !this.state.currentQuote.bidjustificationdata.comments && this.state.currentQuote.channelinfo1.channelrepemailad && this.state.currentQuote.channelinfo1.channelrepphone && this.state.currentQuote.channelinfo1.channelrepname && this.state.currentQuote.channelinfo1.ibmprodspecialist && this.state.currentQuote.decisionmaker.decisionmakername && this.state.currentQuote.decisionmaker.decisionmakertitle && this.state.currentQuote.decisionmaker.decisionmakeremail){
4679
4680return this.state.validateMessageSP1ContactEmailCheckAddress;
4681
4682}
4683
4684else if(this.sbcCheck()){
4685
4686return this.state.validateMessageSbcCheck;
4687
4688}
4689
4690else{
4691
4692return '1';
4693
4694}
4695
4696}
4697
4698sbcCheck(){
4699 let sbc_check:any[] = [];
4700 let result = false;
4701 for(let k=0; k<this.state.currentQuote.pricingdata.compinfo.length; k++){
4702 if(this.state.currentQuote.pricingdata.compinfo[k].specialbidcode1 != ""){
4703 sbc_check.push({code : this.state.currentQuote.pricingdata.compinfo[k].specialbidcode1});
4704 }
4705 if(this.state.currentQuote.pricingdata.compinfo[k].specialbidcode2 != ""){
4706 sbc_check.push({code : this.state.currentQuote.pricingdata.compinfo[k].specialbidcode2});
4707 }
4708 if(this.state.currentQuote.pricingdata.compinfo[k].specialbidcode3 != ""){
4709 sbc_check.push({code : this.state.currentQuote.pricingdata.compinfo[k].specialbidcode3});
4710 }
4711 if(this.state.currentQuote.pricingdata.compinfo[k].specialbidcode4 != ""){
4712 sbc_check.push({code : this.state.currentQuote.pricingdata.compinfo[k].specialbidcode4});
4713 }
4714 if(this.state.currentQuote.pricingdata.compinfo[k].specialbidcode5 != ""){
4715 sbc_check.push({code : this.state.currentQuote.pricingdata.compinfo[k].specialbidcode5});
4716 }
4717 if(this.state.currentQuote.pricingdata.compinfo[k].specialbidcode6 != ""){
4718 sbc_check.push({code : this.state.currentQuote.pricingdata.compinfo[k].specialbidcode6});
4719 }
4720 }
4721 sbc_check = sbc_check.map(item=>item.code).map((item,index,array)=>array.indexOf(item)).filter((item,index,array)=>array.indexOf(item)==index).map((item)=>sbc_check[item]);
4722
4723 for(let x=0; x<this.state.currentQuote.sbclist[0].componentsbc.length; x++){
4724 for(let y=0; y<this.state.currentQuote.sbclist[0].componentsbc[x].specialbidcodelist.length; y++){
4725 for(let z=0; z<sbc_check.length;z++){
4726 if(this.state.currentQuote.sbclist[0].componentsbc[x].specialbidcodelist[y].description == sbc_check[z].code){
4727 if(this.state.currentQuote.sbclist[0].componentsbc[x].specialbidcodelist[y].sbcapprprefix != ""){
4728 sbc_check[z] = {sbcapprprefix : this.state.currentQuote.sbclist[0].componentsbc[x].specialbidcodelist[y].sbcapprprefix,...sbc_check[z]}
4729 }
4730 }
4731 }
4732
4733 }
4734 }
4735if(this.state.currentQuote.hasOwnProperty('add_bks')){
4736 for(let element=0; element< this.state.currentQuote.add_bks.length; element++){
4737 // this.state.currentQuote.add_bks.forEach((element)=>{
4738 let apprprefix = this.state.currentQuote.add_bks[element].sbcapprprefix.toLowerCase();
4739 let apprno = this.state.currentQuote.add_bks[element].approvalnb.substr(0,apprprefix.length).toLowerCase();
4740 if(this.state.currentQuote.add_bks[element].sbcapprprefix !== null && this.state.currentQuote.add_bks[element].sbcapprprefix !== ""){
4741 if(this.state.currentQuote.add_bks[element].approvalnb === ""){
4742 //'Missing Approval Number, please provide a valid approval number'
4743 this.state.validateMessageSbcCheck = 'Missing Approval Number, please provide a valid approval number'
4744 return true;
4745 }
4746 else if(apprno.startsWith(apprprefix)){
4747 console.log("approval number is correct")
4748 }
4749 else{
4750 //'Invalid Approval Number, please provide a valid approval number'
4751 this.state.validateMessageSbcCheck = 'Invalid Approval Number, please provide a valid approval number'
4752 return true;
4753 }
4754 }
4755 // });
4756 }
4757}
4758 for(let k=0; k < sbc_check.length; k++){
4759 if(sbc_check[k].hasOwnProperty('sbcapprprefix')){
4760 if(this.state.currentQuote.pricingdata.hasOwnProperty('sbcinfo')){
4761 for(let l=0; l<this.state.currentQuote.pricingdata.sbcinfo.length; l++){
4762 let apprprefix = sbc_check[k].sbcapprprefix.toLowerCase();
4763 let apprno = this.state.currentQuote.pricingdata.sbcinfo[l].sbcapprnumber.substr(0,apprprefix.length).toLowerCase();
4764 if(this.state.currentQuote.pricingdata.sbcinfo[l].sbc != sbc_check[k].code){
4765 result = true;
4766 return result;
4767 }
4768 else if(this.state.currentQuote.pricingdata.sbcinfo[l].sbc === sbc_check[k].code && !(apprno.startsWith(apprprefix))){
4769 result = true;
4770 return result;
4771 }
4772 }
4773 }
4774 else {
4775 if(this.add_bks == null || this.add_bks == [] || this.state.currentQuote.add_bks == null || this.state.currentQuote.add_bks == []){
4776 result = true;
4777 return result;
4778 }
4779 }
4780 }
4781 }
4782
4783 this.quoteService.ValidateandSaveHeaderInfo(this.state.currentQuote.ctrycode,this.state.currentQuote.headerinfo.geocode,this.state.currentQuote.quoteid,this.add_bks)
4784 .then((data: any) => {
4785 this._ngZone.run(() => {
4786 this.quoteService.load(this.state.currentQuote.quoteid)
4787 .then((data: any) => {
4788
4789 this.state.currentQuote = data;
4790
4791 for (let i = 0; i < this.add_cart.length; i++) {
4792 if(this.add_tre){
4793
4794 if (this.add_tre.selectedsbc[0].code == this.add_cart[i].code) {
4795 //already has it
4796 this.add_cart.splice(i, 1);
4797
4798 } else {}
4799
4800
4801 }
4802 }
4803 return result;
4804 });
4805 //remove the spinner
4806
4807
4808 });
4809 });
4810 //return result;
4811}
4812
4813installAddress(){
4814
4815this.price_request_header_screen = false;
4816
4817this.install_address_edited = true;
4818
4819this.isChanged = true;
4820
4821this.cdr.detectChanges();
4822
4823}
4824
4825
4826addInstallAddress(){
4827
4828this.state.currentQuote.installAddress_val.push({'address1':'','address2':'','city':'','state':'','id':'installaddress'+Number.parseInt(this.installAddressCount.toString())});
4829
4830this.installAddressCount++;
4831//this.installAddressid++;
4832this.cdr.detectChanges();
4833
4834}
4835
4836delInstallAddress(index:any){
4837
4838 if(this.state.currentQuote.installAddress_val[index].hasOwnProperty('addressid')){
4839 this.loader = this.loading.create({
4840 content: 'Loading...',
4841 });
4842 this.loader.present();
4843 this.quoteService.removeInstallAddress(this.state.currentQuote.installAddress_val[index].addressid).then(()=>{
4844
4845 this.installAddressCount--;
4846 this.state.currentQuote.installAddress_val.splice(index, 1);
4847
4848 this.cdr.detectChanges();
4849 this.loader.dismiss();
4850 });
4851 }
4852
4853 else{
4854this.installAddressCount--;
4855
4856this.state.currentQuote.installAddress_val.splice(index, 1);
4857
4858this.cdr.detectChanges();
4859
4860}
4861
4862}
4863
4864
4865checkDecisionModelVal(val:any){
4866
4867let keyArr: any[] = Object.keys(this.state.currentQuote.decisionmaker);
4868 keyArr.forEach((key: any) => {
4869
4870 if(key === val)
4871 {
4872
4873 return key;
4874
4875 }
4876
4877 else {}
4878
4879
4880 });
4881
4882return -1;
4883
4884}
4885
4886regionState(val:any){
4887
4888if ("regionlist" in this.state.currentQuote && typeof this.state.currentQuote.regionlist!== "undefined") {
4889 for(let v =0; v < this.state.currentQuote.regionlist[0].state.length;v++)
4890 {
4891
4892 if(this.state.currentQuote.regionlist[0].state[v].statecode === val){
4893
4894 return this.state.currentQuote.regionlist[0].state[v];
4895
4896 }
4897
4898 }
4899
4900}
4901
4902}
4903
4904
4905htmlToPlaintext(text:any) {
4906 return text ? String(text).replace(/<[^>]+>/gm, '') : '';
4907}
4908
4909ibmContactEmailValidOnSave(){
4910 //On Save IBM Channel Contact Check
4911 if(this.sp1bpcontactemail){
4912 let lastatrateindex = this.sp1bpcontactemail.lastIndexOf('@');
4913 let result = this.sp1bpcontactemail.substring(lastatrateindex + 1);
4914 if(result.search('ibm.com') >= 0){
4915 return true;
4916 }else{
4917 return false;
4918 }
4919 }else{
4920 return true;
4921 }
4922}
4923
4924ibmContactEmailValidOnSubmit(){
4925 //On Save IBM Channel Contact Check
4926 if(this.sp1bpcontactemail){
4927 let lastatrateindex = this.sp1bpcontactemail.lastIndexOf('@');
4928 let result = this.sp1bpcontactemail.substring(lastatrateindex + 1);
4929 if(result.search('ibm.com') >= 0){
4930 return true;
4931 }else{
4932 return false;
4933 }
4934 }else{
4935 return false;
4936 }
4937}
4938
4939decisionMakerEmailValidOnSave(){
4940
4941if(this.decisionmakeremail){
4942
4943let regExp = this.state.emailValidaionRegx;
4944
4945 if (!regExp.test(this.decisionmakeremail)) {
4946 return false;
4947 }
4948 else{
4949 return true;
4950 }
4951}
4952else{
4953
4954//If decision maker email id is null
4955
4956return true;
4957
4958}
4959
4960
4961}
4962
4963//----
4964
4965decisionMakerEmailValidOnSubmit(){
4966
4967if(this.decisionmakeremail){
4968
4969let regExp = this.state.emailValidaionRegx;
4970
4971 if (!regExp.test(this.decisionmakeremail)) {
4972 return false;
4973 }
4974 else{
4975 return true;
4976 }
4977}
4978else{
4979
4980//If decision maker email id is null
4981
4982return false;
4983
4984}
4985
4986
4987}
4988
4989
4990//-----
4991
4992
4993sponeContactEmailValidOnSave(){
4994
4995if(this.state.currentQuote.channelinfo.pcs.sp1bpcontactemail){
4996
4997let regExp = this.state.emailValidaionRegx;
4998
4999if (!regExp.test(this.state.currentQuote.channelinfo.pcs.sp1bpcontactemail)) {
5000 return false;
5001 }
5002 else{
5003 return true;
5004 }
5005
5006}
5007else{
5008
5009//If channel contact spone email id is null
5010
5011return true;
5012}
5013}
5014
5015//----
5016
5017sponeContactEmailValidOnSubmit(){
5018
5019if(this.state.currentQuote.channelinfo.pcs.sp1bpcontactemail){
5020
5021let regExp = this.state.emailValidaionRegx;
5022
5023if (!regExp.test(this.state.currentQuote.channelinfo.pcs.sp1bpcontactemail)) {
5024 return false;
5025 }
5026 else{
5027 return true;
5028 }
5029
5030}
5031else{
5032
5033//If channel contact spone email id is null
5034
5035return false;
5036}
5037}
5038
5039
5040//---
5041
5042
5043
5044sbcCode(item_k:any){
5045
5046 if(this.state.currentQuote.hasOwnProperty('sbclist'))
5047 {
5048
5049 if(this.state.currentQuote.sbclist[0].hasOwnProperty('componentsbc'))
5050 {
5051
5052for (let k = 0; k < this.state.currentQuote.sbclist[0].componentsbc.length; k++) {
5053
5054for(let l = 0; l < this.state.currentQuote.sbclist[0].componentsbc[k].specialbidcodelist.length; l++){
5055
5056if(this.state.currentQuote.sbclist[0].componentsbc[k].specialbidcodelist[l].description == item_k){
5057
5058return this.state.currentQuote.sbclist[0].componentsbc[k].specialbidcodelist[l].code;
5059
5060}
5061
5062}
5063}
5064
5065 }
5066
5067 }
5068
5069}
5070valCheckForSave(){
5071 if(this.state.currentQuote.channelinfo.pcs.sp1bpcontactemail && !this.sponeContactEmailValidOnSubmit()){
5072 return this.state.validateMessageSP1ContactEmailCheckAddress;
5073
5074 }else if(this.state.currentQuote.decisionmaker.decisionmakeremail && !this.decisionMakerEmailValidOnSubmit()){
5075 return this.state.validateMessageDecisionMakerEmailCheckAddress;
5076
5077 }else if(this.state.currentQuote.channelinfo1.channelrepemailad && !this.ibmContactEmailValidOnSubmit()){
5078 return this.state.validateMessageChannelContactEmailCheckAddress;
5079
5080 }
5081
5082 else{
5083 return '1';
5084
5085 }
5086}
5087
5088
5089
5090}