diff --git a/ng8-seed/src/app/components/contribute/contribute.component.ts b/ng8-seed/src/app/components/contribute/contribute.component.ts index 693346c..e910367 100644 --- a/ng8-seed/src/app/components/contribute/contribute.component.ts +++ b/ng8-seed/src/app/components/contribute/contribute.component.ts @@ -27,7 +27,7 @@ export class ContributeComponent implements OnInit { school: any = []; category: any = []; Total: any = []; - grandTotal: any = []; + grandTotal: number ; finalData: any = []; schRquId:any ; sponsor_qty:any=[] @@ -141,7 +141,11 @@ export class ContributeComponent implements OnInit { getSchoolReqList() { - + this.finalData=[] + this.whole_contribute_list=[] + this.Total=[] + this.grandTotal=0 + this.sponsor_qty=[] let url = `${environment.apiUrl}${'getSchoolReqList'}`; let data = this.Contribute.value; @@ -197,7 +201,14 @@ export class ContributeComponent implements OnInit { let bal_qty=curr_data.qty-curr_data.received_qty if(e > bal_qty){ alert("Given value is greater than Balance Qty") + if(this.finalData.length > 0){ + let curr_final_data=this.finalData.filter(val=>val.req_id==curr_data.school_req_id) + if(curr_final_data.length >0){ + if(curr_final_data.amount != ''){ + this.grandTotal-=parseInt(curr_final_data[0].amount) + } + } this.finalData=this.finalData.filter(val=>{ return val.req_id!=curr_data.school_req_id }) @@ -205,13 +216,19 @@ export class ContributeComponent implements OnInit { // console.log(this.finalData); } this.sponsor_qty[i]='' - this.Total[i]='' + this.Total[i]=0 // console.log(this.finalData) return } else if(e <= 0){ alert("Given value is Invalid") - if(this.finalData.length > 0){ + if(this.finalData.length > 0){ + let curr_final_data=this.finalData.filter(val=>val.req_id==curr_data.school_req_id) + if(curr_final_data.length >0){ + if(curr_final_data.amount != ''){ + this.grandTotal-=parseInt(curr_final_data[0].amount) + } + } this.finalData=this.finalData.filter(val=>{ return val.req_id!=curr_data.school_req_id }) @@ -219,7 +236,7 @@ export class ContributeComponent implements OnInit { // console.log(this.finalData); } this.sponsor_qty[i]='' - this.Total[i]='' + this.Total[i]=0 // console.log(this.finalData) return } @@ -267,7 +284,11 @@ export class ContributeComponent implements OnInit { getSchoolReqList2() { - + this.finalData=[] + this.whole_contribute_list=[] + this.Total=[] + this.grandTotal=0 + this.sponsor_qty=[] let url = `${environment.apiUrl}${'getSchoolReqList'}`; let data = this.Contribute.value; this.restApi.post(url,data).subscribe(schDet=> @@ -311,6 +332,11 @@ export class ContributeComponent implements OnInit { } reset(){ + this.finalData=[] + this.whole_contribute_list=[] + this.Total=[] + this.grandTotal=0 + this.sponsor_qty=[] this.Contribute.reset(); this.school=[] this.material_category=this.all_material_category @@ -342,7 +368,7 @@ export class ContributeComponent implements OnInit { this.router.navigate(['payment']) return } - if(this.grandTotal ==''){ + if(!this.grandTotal ){ alert("Please tell us the number of items you would like to contribute"); return } @@ -372,7 +398,7 @@ export class ContributeComponent implements OnInit { // if(flag == 1){ sessionStorage.setItem('contribute-selected-list',JSON.stringify(this.whole_contribute_list)) sessionStorage.setItem('contribute-params',JSON.stringify(data)) - sessionStorage.setItem('contribute_final_total',this.grandTotal) + sessionStorage.setItem('contribute_final_total',String(this.grandTotal)) this.router.navigate(['payment'],{replaceUrl:true}) // } diff --git a/ng8-seed/src/app/components/login/login.component.ts b/ng8-seed/src/app/components/login/login.component.ts index d55143c..c5eca1d 100644 --- a/ng8-seed/src/app/components/login/login.component.ts +++ b/ng8-seed/src/app/components/login/login.component.ts @@ -105,7 +105,7 @@ this.previousUrl = this.restApi.getPreviousUrl(); this.matDialog.closeAll(); } registerDialog(){ - this.closeDialog() + this.dialogRef.close(); this.matDialog.open(RegisterComponent,{ "height":"600px", "width":"550px", diff --git a/ng8-seed/src/app/components/project-detail/project-detail.component.ts b/ng8-seed/src/app/components/project-detail/project-detail.component.ts index 6ad7314..5b1cda5 100644 --- a/ng8-seed/src/app/components/project-detail/project-detail.component.ts +++ b/ng8-seed/src/app/components/project-detail/project-detail.component.ts @@ -26,7 +26,7 @@ export class ProjectDetailComponent implements OnInit { finalData: any = []; Total: any=[]; whole_contribute_list: any; - grandTotal: any=[]; + grandTotal: number; general_devlop_amt: string; gen_dev_fund_remarks: any; dataStatus :boolean = true; @@ -68,6 +68,12 @@ somethingChanged(e,i,item,mat_id,curr_data){ if(e > bal_qty){ alert("Given value is greater than Balance Qty") if(this.finalData.length > 0){ + let curr_final_data=this.finalData.filter(val=>val.req_id==curr_data.school_req_id) + if(curr_final_data.length >0){ + if(curr_final_data.amount != ''){ + this.grandTotal-=parseInt(curr_final_data[0].amount) + } + } this.finalData=this.finalData.filter(val=>{ return val.req_id!=curr_data.school_req_id }) @@ -75,13 +81,19 @@ somethingChanged(e,i,item,mat_id,curr_data){ // console.log(this.finalData); } this.sponsor_qty[i]='' - this.Total[i]='' + this.Total[i]=0 // console.log(this.finalData) return } else if(e <= 0){ alert("Given value is Invalid") if(this.finalData.length > 0){ + let curr_final_data=this.finalData.filter(val=>val.req_id==curr_data.school_req_id) + if(curr_final_data.length >0){ + if(curr_final_data.amount != ''){ + this.grandTotal-=parseInt(curr_final_data[0].amount) + } + } this.finalData=this.finalData.filter(val=>{ return val.req_id!=curr_data.school_req_id }) @@ -89,7 +101,7 @@ somethingChanged(e,i,item,mat_id,curr_data){ // console.log(this.finalData); } this.sponsor_qty[i]='' - this.Total[i]='' + this.Total[i]=0 // console.log(this.finalData) return } @@ -133,8 +145,8 @@ finalSave(flag) this.router.navigate(['payment']) return } - if(this.grandTotal ==''){ - alert("Please Fill the amount"); + if(!this.grandTotal){ + alert("Please tell us the number of items you would like to contribute"); return } if(this.contribute_type == '' ){ @@ -163,7 +175,7 @@ finalSave(flag) // if(flag == 1){ sessionStorage.setItem('contribute-selected-list',JSON.stringify(this.whole_contribute_list)) sessionStorage.setItem('contribute-params',JSON.stringify(data)) - sessionStorage.setItem('contribute_final_total',this.grandTotal) + sessionStorage.setItem('contribute_final_total',String(this.grandTotal)) this.router.navigate(['payment'],{replaceUrl:true}) // } diff --git a/ng8-seed/src/app/components/user-profile/user-profile.component.html b/ng8-seed/src/app/components/user-profile/user-profile.component.html index 352e594..f52f29a 100644 --- a/ng8-seed/src/app/components/user-profile/user-profile.component.html +++ b/ng8-seed/src/app/components/user-profile/user-profile.component.html @@ -311,7 +311,7 @@

Yours faithfully

- +

Secretary

Tamil Nadu State Parent Teacher Association