diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/add-pd.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/add-pd.component.html index 8caf043ba..76c6c2a7a 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/add-pd.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/add-pd.component.html @@ -14,7 +14,7 @@ - + Select diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/add-pd.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/add-pd.component.ts index 8957234b5..15bb2fb61 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/add-pd.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/add-pd.component.ts @@ -852,8 +852,10 @@ export class AddPdComponent implements OnInit, OnDestroy { } }); } - getContactPerson(){ - + getContactPerson(flag?){ + if(flag == 1){ //FOR IDENTIFY THE LENDER NAME CHANGE TO RESET THE BRANCH + this._PDtriggerForm.controls['pd_branch_id'].setValue(null); + } if(this._PDtriggerForm.value.fk_lender_id !=null ){ let lender_filter= this.checkLender(this._PDtriggerForm.value.fk_lender_id) @@ -884,14 +886,23 @@ export class AddPdComponent implements OnInit, OnDestroy { } -// if( this._PDtriggerForm.value.pd_branch_id !=null){ - let param={fk_lender_id:this._PDtriggerForm.value.fk_lender_id} + + let param={fk_lender_id:this._PDtriggerForm.value.fk_lender_id,pd_branch_id:null} + if( this._PDtriggerForm.value.pd_branch_id !=null){ + param.pd_branch_id=this._PDtriggerForm.value.pd_branch_id + } this._pd.getLenderContactPersons(param).subscribe(result=>{ if(result['dataStatus']){ let records=result['records'] if(records.length >0){ this.sales_and_credit_person.sales_person=records.filter(val=>val.role_type == "SALES") this.sales_and_credit_person.credit_person=records.filter(val=>val.role_type == "CREDIT") + if(this.sales_and_credit_person.credit_person.length > 0){ + this._PDtriggerForm.controls['lender_credit_person'].setValue(this.sales_and_credit_person.credit_person[0].userid) + } + else{ + this._PDtriggerForm.controls['lender_credit_person'].setValue(null) + } } } else{ diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/edit-pd-master/edit-pd-master.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/edit-pd-master/edit-pd-master.component.html index f05f6b854..56b5ac190 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/edit-pd-master/edit-pd-master.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/edit-pd-master/edit-pd-master.component.html @@ -21,7 +21,7 @@ --> - + Select diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/edit-pd-master/edit-pd-master.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/edit-pd-master/edit-pd-master.component.ts index b7191ea5b..23982b0f8 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/edit-pd-master/edit-pd-master.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/edit-pd-master/edit-pd-master.component.ts @@ -769,8 +769,10 @@ validateAllFormFields(formGroup: any) { } -getContactPerson(){ - +getContactPerson(flag?){ + if(flag == 1){ //FOR IDENTIFY THE LENDER NAME CHANGE TO RESET THE BRANCH + this._EditPDtriggerForm.controls['pd_branch_id'].setValue(null); + } if(this._EditPDtriggerForm.value.fk_lender_id !=null ){ let lender_filter= this.checkLender(this._EditPDtriggerForm.value.fk_lender_id) @@ -803,13 +805,22 @@ getContactPerson(){ } // if(this._EditPDtriggerForm.value.pd_branch_id !=null ){ - let param={fk_lender_id:this._EditPDtriggerForm.value.fk_lender_id} + let param={fk_lender_id:this._EditPDtriggerForm.value.fk_lender_id,pd_branch_id:null} + if( this._EditPDtriggerForm.value.pd_branch_id !=null){ + param.pd_branch_id=this._EditPDtriggerForm.value.pd_branch_id + } this._pd.getLenderContactPersons(param).subscribe(result=>{ if(result['dataStatus']){ let records=result['records'] if(records.length >0){ this.sales_and_credit_person.sales_person=records.filter(val=>val.role_type == "SALES") this.sales_and_credit_person.credit_person=records.filter(val=>val.role_type == "CREDIT") + // if(this.sales_and_credit_person.credit_person.length > 0){ + // this._EditPDtriggerForm.controls['lender_credit_person'].setValue(this.sales_and_credit_person.credit_person[0].userid) + // } + // else{ + // this._EditPDtriggerForm.controls['lender_credit_person'].setValue(null) + // } } } else{ diff --git a/ng6-seed/src/app/settings/service/user.service.ts b/ng6-seed/src/app/settings/service/user.service.ts index b379516d1..7615285e7 100755 --- a/ng6-seed/src/app/settings/service/user.service.ts +++ b/ng6-seed/src/app/settings/service/user.service.ts @@ -184,6 +184,7 @@ export class UserService { "fk_updatedby":updateby, "createdon":createdon, "updatedon":updateon, + "fk_lender_branch_id":users.fk_lender_branch_id }; //console.log(roles); formData.append('records',JSON.stringify(records)); @@ -230,5 +231,11 @@ export class UserService { getprofilepic(users){ return this.http.post(apiurl+'getSingedProfilePicURL',users); } + // get lenders list + getLenderDetails(): Observable { + return this.http.get(apiurl + 'getListOfLenders'); + + } + } diff --git a/ng6-seed/src/app/settings/users/register/register.component.html b/ng6-seed/src/app/settings/users/register/register.component.html index e857fc0b5..2c6df0de0 100755 --- a/ng6-seed/src/app/settings/users/register/register.component.html +++ b/ng6-seed/src/app/settings/users/register/register.component.html @@ -110,7 +110,7 @@ - + -- {{ent.full_name}} @@ -130,7 +130,7 @@ - + {{role.role_name}} @@ -140,6 +140,15 @@ User Role Required User Role Required + + + + {{branch.branch_name}} + + + Branch is Required + + -- diff --git a/ng6-seed/src/app/settings/users/register/register.component.ts b/ng6-seed/src/app/settings/users/register/register.component.ts index 96d0ce804..edbaa2c22 100755 --- a/ng6-seed/src/app/settings/users/register/register.component.ts +++ b/ng6-seed/src/app/settings/users/register/register.component.ts @@ -60,6 +60,9 @@ export class RegisterComponent implements OnInit { entitiesDetails:any; entities:any; notifier:NotifierService; + entity_for_branch: any; + branchList: any; + enableBranch: boolean=false; constructor( private router: Router, public fb: FormBuilder, public AWS: AwsService, private cd: ChangeDetectorRef ,private elementRef: ElementRef,public users:UserService,notifier:NotifierService) { @@ -90,7 +93,7 @@ export class RegisterComponent implements OnInit { isactive: [true], pdteam:[null], pdtype:[null], - + fk_lender_branch_id:[null] }); this.userupdate(); @@ -154,6 +157,12 @@ export class RegisterComponent implements OnInit { this.entitiesDetails = this.entitiesDetails.records; } }) + this.users.getLenderDetails().subscribe(res=>{ + this.entity_for_branch=res + if(this.entity_for_branch.dataStatus == true){ + this.entity_for_branch = this.entity_for_branch.records; + } + }) } @@ -246,8 +255,8 @@ console.log("cog",userData,this.usersData) } } - toggleAllSelection(e,enitiyid) { - // console.log(enitiyid); + toggleAllSelection(e,enitiyid,flag?) { + console.log(enitiyid,e); // if(e.value){ // if(e.value.role_name == pdoff && enitiyid.entity_type_id == 1){ @@ -257,23 +266,48 @@ console.log("cog",userData,this.usersData) // this.roleAccess = false; // } // } - if (this.usersData != '' && this.usersData !==undefined || e.value.role_name == pdoff && enitiyid.entity_type_id == 1 || e.value.role_name == pdexu && enitiyid.entity_type_id == 1) { + if (this.usersData != '' && this.usersData !==undefined || e.role_name == pdoff && enitiyid.entity_type_id == 1 || e.role_name == pdexu && enitiyid.entity_type_id == 1) { - if(e.role_name == pdoff && enitiyid.entity_type_id == 1 ||e.role_name == pdexu && enitiyid.entity_type_id == 1 || e.value.role_name == pdoff && enitiyid.entity_type_id == 1 || e.value.role_name == pdexu && enitiyid.entity_type_id == 1){ + if(e.role_name == pdoff && enitiyid.entity_type_id == 1 ||e.role_name == pdexu && enitiyid.entity_type_id == 1 || e.role_name == pdoff && enitiyid.entity_type_id == 1 || e.role_name == pdexu && enitiyid.entity_type_id == 1){ this.roleAccess = true; }else{ this.roleAccess = false; } - - - - - }else{ + }else{ this.roleAccess = false; } - + this.getBranch(flag); } +getBranch(flag?){ + if(this.regForm.value.role != null && (this.regForm.value.role.role_name == "Branch Credit" || this.regForm.value.role.role_name == "Branch Sales") && this.regForm.value.lenVenName != null){ + console.log(this.regForm.value.role,this.entity_for_branch,this.regForm.value.lenVenName); + if(this.entity_for_branch.length > 0){ + this.enableBranch=true + // this.branchList=this.entity_for_branch + this.branchList=this.entity_for_branch.filter(val=>val.short_name == this.regForm.value.lenVenName.short_name).map(b=>b.branches) + console.log("dgg",this.branchList) + if(this.branchList.length > 0){ + this.branchList=this.branchList[0] + if(flag == 1){ // for edit purpose + console.log(this.usersData.fk_lender_branch_id) + this.regForm.controls['fk_lender_branch_id'].setValue(this.usersData.fk_lender_branch_id) + } + else{ + this.regForm.controls['fk_lender_branch_id'].setValue(null); + } + this.regForm.controls['fk_lender_branch_id'].setValidators(Validators.required) + } + } + } + else{ + this.regForm.controls['fk_lender_branch_id'].clearValidators() + this.enableBranch=false + this.branchList=[] + this.regForm.controls['fk_lender_branch_id'].setValue(null); + } + +} getcity(e){ // console.log(e); // console.log(this.Cities); @@ -355,6 +389,14 @@ console.log("cog",userData,this.usersData) this.regForm.controls['pdtype'].setValue(pdtype); } }); + this.users.getLenderDetails().subscribe(res=>{ + this.entity_for_branch=res + if(this.entity_for_branch.dataStatus == true){ + this.entity_for_branch = this.entity_for_branch.records; + // this.getBranch(1); //for edit functionality + + } + }) let users= { 'userid':this.usersData.userid, @@ -399,6 +441,7 @@ console.log("cog",userData,this.usersData) * params are flag are if 1 - add and 2 - edit **/ callrole(flag,type,usersData){ + console.log(this.usersData) this.users.roles().subscribe(res=>{ this.roleload = false; @@ -413,7 +456,7 @@ callrole(flag,type,usersData){ let role = this.role.filter(role=>role.role_type == usersData.fk_entity_type_id && role.role_id == usersData.user_role)[0]; this.regForm.controls['role'].setValue(role); - this.toggleAllSelection(role,type); + this.toggleAllSelection(role,type,1); // this.regForm.controls['role'].setValue(role); }