diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 89600a72..979ff4f7 100755 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -9,6 +9,10 @@ import { StatusBar } from '@ionic-native/status-bar'; import { SplashScreen } from '@ionic-native/splash-screen'; import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; +import { SQLite } from '@ionic-native/sqlite'; +import { DatabaseProvider } from '../providers/database/database'; +import { AndroidPermissions } from '@ionic-native/android-permissions'; + import { MatAutocompleteModule, MatButtonModule, @@ -81,11 +85,11 @@ import { PdQuestionFamilyPage } from '../pages/pd-question/pd-question-family/pd import { PdQuestionLoansPage } from '../pages/pd-question/pd-question-loans/pd-question-loans'; import { PdQuestionFinancialInfoPage } from '../pages/pd-question/pd-question-financial-info/pd-question-financial-info'; import { PdQuestionOtherIncomePage } from '../pages/pd-question/pd-question-other-income/pd-question-other-income'; -import { PdQuestionSupplierInfoPage } from '../pages/pd-question/pd-question-supplier-info/pd-question-supplier-info'; +import { PdQuestionSupplierInfoPage } from '../pages/pd-question/pd-question-business-group/pd-question-supplier-info/pd-question-supplier-info'; import { Geolocation } from '@ionic-native/geolocation'; import { PdQuestionPersonalInfoPage } from '../pages/pd-question/pd-question-personal-info/pd-question-personal-info'; -import { PdQuestionStockInfoPage } from '../pages/pd-question/pd-question-stock-info/pd-question-stock-info'; -import { PdQuestionClientInfoPage } from '../pages/pd-question/pd-question-client-info/pd-question-client-info'; +import { PdQuestionStockInfoPage } from '../pages/pd-question/pd-question-business-group/pd-question-stock-info/pd-question-stock-info'; +import { PdQuestionClientInfoPage } from '../pages/pd-question/pd-question-business-group/pd-question-client-info/pd-question-client-info'; // import { DatePicker } from '@ionic-native/date-picker'; import { PdQuestionBusinessInfoPage } from '../pages/pd-question/pd-question-business-group/pd-question-business-info/pd-question-business-info'; import { PdQuestionRentalInfoPage } from '../pages/pd-question/pd-question-rental-info/pd-question-rental-info'; diff --git a/src/pages/pd-question/pd-question-business-group/pd-question-business-assets/pd-question-business-assets.html b/src/pages/pd-question/pd-question-business-group/pd-question-business-assets/pd-question-business-assets.html index 7d313c50..66d3e555 100755 --- a/src/pages/pd-question/pd-question-business-group/pd-question-business-assets/pd-question-business-assets.html +++ b/src/pages/pd-question/pd-question-business-group/pd-question-business-assets/pd-question-business-assets.html @@ -10,7 +10,7 @@ - Business Asset Details + {{formDetails.form_name}} diff --git a/src/pages/pd-question/pd-question-business-group/pd-question-business-assets/pd-question-business-assets.ts b/src/pages/pd-question/pd-question-business-group/pd-question-business-assets/pd-question-business-assets.ts index 34617a66..5a11df68 100755 --- a/src/pages/pd-question/pd-question-business-group/pd-question-business-assets/pd-question-business-assets.ts +++ b/src/pages/pd-question/pd-question-business-group/pd-question-business-assets/pd-question-business-assets.ts @@ -27,7 +27,7 @@ export class PdQuestionBusinessAssetsPage { company_id:any; pdDetails:any; - FormId:any; + formDetails : any; users:any; _businessAssetsQuesFrom:FormGroup; m_assets_type:any; @@ -56,8 +56,8 @@ export class PdQuestionBusinessAssetsPage { constructor(public navCtrl: NavController, public navParams: NavParams,public aws:AwsServiceProvider,public fb:FormBuilder,public qustcat:QuestionCategoryProvider,public cons:ConstantsProvider,public toast:ToastProvider) { - this.pdDetails=this.navParams.get('pdDetails') - this.FormId=this.navParams.get('FormId') + this.pdDetails=this.navParams.get('pdDetails'); + this.formDetails=this.navParams.get('formDetails'); this.users=this.aws.getlocale(); this.company_id=this.pdDetails.company_id; this.applicants = this.pdDetails.applicat_details; @@ -73,9 +73,8 @@ export class PdQuestionBusinessAssetsPage { this.getDetails() this.getDropDown() - console.log("Form Id",this.FormId); - console.log(this.pdDetails); - + + let params:any={}; params.pd_id=this.pdDetails.pd_id; params.pd_form_id='5' @@ -187,7 +186,8 @@ export class PdQuestionBusinessAssetsPage { if(data==null){ this._businessAssetsQuesFrom=this.fb.group({ pdid: [this.pdDetails.pd_id], - formid: ['22'], + /* formid: ['22'],*/ + formid: [this.formDetails.form_id], company_id : [this.company_id], fk_createdby:[this.users], business_years:[''], @@ -209,7 +209,8 @@ export class PdQuestionBusinessAssetsPage { let value=data; this._businessAssetsQuesFrom=this.fb.group({ pdid: [this.pdDetails.pd_id], - formid: ['22'], + /* formid: ['22'],*/ + formid: [this.formDetails.form_id], company_id : [this.company_id], fk_createdby:[this.users], diff --git a/src/pages/pd-question/pd-question-business-group/pd-question-business-banking/pd-question-business-banking.ts b/src/pages/pd-question/pd-question-business-group/pd-question-business-banking/pd-question-business-banking.ts index 596d0c15..87f1ac37 100755 --- a/src/pages/pd-question/pd-question-business-group/pd-question-business-banking/pd-question-business-banking.ts +++ b/src/pages/pd-question/pd-question-business-group/pd-question-business-banking/pd-question-business-banking.ts @@ -25,7 +25,8 @@ pdDetails:any; m_btLenderList: any; applicants: any salaryField: boolean; -FormId: any; +formDetails: any; +form_id:any; accountType: any; users: any; bankingForm:FormGroup; @@ -50,9 +51,10 @@ step:number this.pd_cus_segment=this.pdDetails.customer_segment_abbr.toUpperCase(); this.pd_cus_segment=this.pd_cus_segment.substring(0,3) this.pdid=this.pdDetails.pd_id; - this.FormId = this.navParams.get('FormId'); + this.formDetails=this.navParams.get('formDetails'); + this.form_id = this.formDetails.form_id; this.company_id=this.pdDetails.company_id - console.log("Form Id",this.FormId); + // console.log("Form Id",this.FormId); this.applicants = this.pdDetails.applicat_details; this.applicants = this.applicants.filter(appt=>appt.applicant_type != 2) this.applicants.push({'pd_co_applicant_id':'0','applicant_name':'Others'}); @@ -257,7 +259,7 @@ step:number } retiveBankDetails(){ - let records = {'pd_id':this.pdDetails.pd_id,'pd_form_id':this.FormId,'company_id':this.company_id} + let records = {'pd_id':this.pdDetails.pd_id,'pd_form_id':this.form_id,'company_id':this.company_id} const control = this.bankingForm.controls['itemRows']; this.qustCat.retiverForm(records).subscribe(res=> { @@ -301,7 +303,7 @@ step:number { let records: any = {}; records.pdid = this.pdDetails.pd_id; - records.formid = this.FormId; + records.formid = this.form_id; records.fk_createdby = this.users; records.company_id=this.company_id; records.banking_details = answerData.itemRows; diff --git a/src/pages/pd-question/pd-question-business-group/pd-question-business-group.html b/src/pages/pd-question/pd-question-business-group/pd-question-business-group.html index 2fa1c37b..97edb286 100755 --- a/src/pages/pd-question/pd-question-business-group/pd-question-business-group.html +++ b/src/pages/pd-question/pd-question-business-group/pd-question-business-group.html @@ -23,9 +23,9 @@ - - {{quesIndex+1}} - + + {{quesIndex+1}} + {{quesIndex+1}}

{{ formButton.form_name }}

diff --git a/src/pages/pd-question/pd-question-business-group/pd-question-business-group.scss b/src/pages/pd-question/pd-question-business-group/pd-question-business-group.scss index efcc6c22..33069e84 100755 --- a/src/pages/pd-question/pd-question-business-group/pd-question-business-group.scss +++ b/src/pages/pd-question/pd-question-business-group/pd-question-business-group.scss @@ -33,6 +33,8 @@ page-pd-question-business-group { $cruzeiro: #387ef5; $atletico: darken(#f4f4f4, 45%); $javascript: #f7e023; + $answered: green; + $notanswered: #f53d3d; .item-ribbon{ background-color: #fff; @@ -89,12 +91,12 @@ page-pd-question-business-group { } } - .ribbon.cruzeiro { - @include ribbonize($cruzeiro); + .ribbon.answered { + @include ribbonize($answered); } - .ribbon.atletico { - @include ribbonize($atletico); + .ribbon.notanswered { + @include ribbonize($notanswered); } .ribbon.javascript { diff --git a/src/pages/pd-question/pd-question-business-group/pd-question-business-group.ts b/src/pages/pd-question/pd-question-business-group/pd-question-business-group.ts index 8c0ea333..871e6ef1 100755 --- a/src/pages/pd-question/pd-question-business-group/pd-question-business-group.ts +++ b/src/pages/pd-question/pd-question-business-group/pd-question-business-group.ts @@ -2,8 +2,9 @@ import { Component } from '@angular/core'; import { IonicPage, NavController, NavParams } from 'ionic-angular'; import { QuestionCategoryProvider } from '../../../providers/question-category/question-category'; -import { PdQuestionSupplierInfoPage } from '../../../pages/pd-question/pd-question-supplier-info/pd-question-supplier-info'; -import { PdQuestionClientInfoPage } from '../../../pages/pd-question/pd-question-client-info/pd-question-client-info'; +import { PdQuestionSupplierInfoPage } from '../../../pages/pd-question/pd-question-business-group/pd-question-supplier-info/pd-question-supplier-info'; +import { PdQuestionClientInfoPage } from '../../../pages/pd-question/pd-question-business-group/pd-question-client-info/pd-question-client-info'; +import { PdQuestionStockInfoPage } from '../../../pages/pd-question/pd-question-business-group/pd-question-stock-info/pd-question-stock-info'; import { PdQuestionBusinessInfoPage } from '../../../pages/pd-question/pd-question-business-group/pd-question-business-info/pd-question-business-info'; import { PdQuestionBusinessAssetsPage } from '../../../pages/pd-question/pd-question-business-group/pd-question-business-assets/pd-question-business-assets' import {PdQuestionBusinessBankingPage} from '../../../pages/pd-question/pd-question-business-group/pd-question-business-banking/pd-question-business-banking' @@ -61,32 +62,36 @@ export class PdQuestionBusinessGroupPage { this.pdDetails.business_month = company.business_month; if(details.form_id==1){ - this.navCtrl.push(PdQuestionSupplierInfoPage,{'FormId':details.form_id,'pdDetails':this.pdDetails}); - console.log("form_id",details.form_id) + this.navCtrl.push(PdQuestionSupplierInfoPage,{'formDetails':details,'pdDetails':this.pdDetails}); + // console.log("form_id",details.form_id) } if(details.form_id==2){ - this.navCtrl.push(PdQuestionClientInfoPage,{'FormId':details.form_id,'pdDetails':this.pdDetails}); - console.log("form_id",details.form_id) + this.navCtrl.push(PdQuestionClientInfoPage,{'formDetails':details,'pdDetails':this.pdDetails}); + // console.log("form_id",details.form_id) + } + if(details.form_id==11){ + this.navCtrl.push(PdQuestionStockInfoPage,{'formDetails':details,'pdDetails':this.pdDetails}); + // console.log("form_id",details.form_id) } if(details.form_id==13){ - this.navCtrl.push(PdQuestionBusinessInfoPage,{'FormId':details.form_id,'pdDetails':this.pdDetails}); - console.log("form_id",details.form_id) + this.navCtrl.push(PdQuestionBusinessInfoPage,{'formDetails':details,'pdDetails':this.pdDetails}); + // console.log("form_id",details.form_id) } if(details.form_id==14){ - this.navCtrl.push(PdQuestionSupplierInfoPage,{'FormId':details.form_id,'pdDetails':this.pdDetails}); - console.log("form_id",details.form_id) + this.navCtrl.push('',{'formDetails':details,'pdDetails':this.pdDetails}); + // console.log("form_id",details.form_id) } if(details.form_id==15){ - this.navCtrl.push(PdQuestionSupplierInfoPage,{'FormId':details.form_id,'pdDetails':this.pdDetails}); - console.log("form_id",details.form_id) + this.navCtrl.push(PdQuestionSupplierInfoPage,{'formDetails':details.form_id,'pdDetails':this.pdDetails}); + // console.log("form_id",details.form_id) } if(details.form_id==21){ - this.navCtrl.push(PdQuestionBusinessBankingPage,{'FormId':details.form_id,'pdDetails':this.pdDetails}); - console.log("form_id",details.form_id) + this.navCtrl.push(PdQuestionBusinessBankingPage,{'formDetails':details.form_id,'pdDetails':this.pdDetails}); + // console.log("form_id",details.form_id) } if(details.form_id==22){ - this.navCtrl.push(PdQuestionBusinessAssetsPage,{'FormId':details.form_id,'pdDetails':this.pdDetails}); - console.log("form_id",details.form_id) + this.navCtrl.push(PdQuestionBusinessAssetsPage,{'formDetails':details.form_id,'pdDetails':this.pdDetails}); + // console.log("form_id",details.form_id) } diff --git a/src/pages/pd-question/pd-question-business-group/pd-question-business-info/pd-question-business-info.html b/src/pages/pd-question/pd-question-business-group/pd-question-business-info/pd-question-business-info.html index 734e90a5..63aa5521 100755 --- a/src/pages/pd-question/pd-question-business-group/pd-question-business-info/pd-question-business-info.html +++ b/src/pages/pd-question/pd-question-business-group/pd-question-business-info/pd-question-business-info.html @@ -4,7 +4,7 @@ - {{FormId.form_name}} + {{formdetails.form_name}} diff --git a/src/pages/pd-question/pd-question-business-group/pd-question-business-info/pd-question-business-info.ts b/src/pages/pd-question/pd-question-business-group/pd-question-business-info/pd-question-business-info.ts index 50e028ad..23fd4e45 100755 --- a/src/pages/pd-question/pd-question-business-group/pd-question-business-info/pd-question-business-info.ts +++ b/src/pages/pd-question/pd-question-business-group/pd-question-business-info/pd-question-business-info.ts @@ -22,7 +22,7 @@ import { ConstantsProvider } from '../../../../providers/constants/constants' }) export class PdQuestionBusinessInfoPage { stateList:any=[]; - users: any; + users: any;formdetails:any; FormId: any; pdDetails: any; businessForm:FormGroup; @@ -64,7 +64,8 @@ export class PdQuestionBusinessInfoPage { this.pdDetails = this.navParams.get('pdDetails'); this.pdid=this.pdDetails.pd_id console.log("pdDetails",this.pdDetails) - this.FormId = this.navParams.get('FormId'); + this.formdetails = this.navParams.get('formDetails'); + this.FormId = this.formdetails.form_id; this.users = this.aws.getlocale(); //console.log("pd",this.pdDetails); this.applicants=this.pdDetails.applicat_details; diff --git a/src/pages/pd-question/pd-question-business-group/pd-question-client-info/pd-question-client-info.html b/src/pages/pd-question/pd-question-business-group/pd-question-client-info/pd-question-client-info.html new file mode 100644 index 00000000..7f03730f --- /dev/null +++ b/src/pages/pd-question/pd-question-business-group/pd-question-client-info/pd-question-client-info.html @@ -0,0 +1,464 @@ + + + + + {{formDetails.form_name}} + + + + +
+ + + Manufacturing Product Details +
+
+
+
+ + Product #{{l+1}} + +
+ + + {{ pm.name }} + + + + + + + + + + + + + {{tl.name}} + + + + + + + + + Select + + {{comrelShip.name}} + + + + + + + + + + + Enter Valid Mobile Number. + + + + Enter Valid STD Code Number. + + + + + Enter Valid LandLine Number. + + + + + + + {{ pm.name }} + + + + + + Payment received in Cash. + Payment received through Banking channels. + + + + + + + No of days of Credit provided to Client for payment + + + + + + + + +
+ + + + + + + + + + +
+
+ +
+
+ + +
+
+
+ + Trading Product Details +
+
+
+
+ + Trading Product #{{l+1}} + + +
+ + + {{ pm.name }} + + + + + + + + + + + + {{tl.name}} + + + + + + + + + Select + + {{comrelShip.name}} + + + + + + + + + + + + Enter Valid Mobile Number. + + + + Enter Valid STD Code Number. +   -   + + + Enter Valid LandLine Number. + + + + + + + {{ pm.name }} + + + + + + Payment received in Cash. + Payment received through Banking channels. + + + + + + + No of days of Credit provided to Client for payment + + + + + + +
+ + + + + + + + + + +
+
+ +
+
+
+ + + +
+
+
+
+ + + +
+
+
+
+ + Service Provided #{{l+1}} + + +
+ + + {{ pm.name }} + + + + + + + + + + + {{tl.name}} + + + + + + + + + Select + + {{comrelShip.name}} + + + + + + + + + + + Enter Valid Mobile Number. + + + + Enter Valid STD Code Number. +   -   + + + Enter Valid LandLine Number. + + + + + + {{ pm.name }} + + + + + + Payment received in Cash. + Payment received through Banking channels. + + + + +
+ + No of days of Credit provided to Client for payment + + + + + + + + + + + + + + + + + + +
+
+
+
+ +
+ + + +
+ +
+
+
+ + + Remarks + + + + + + + + +
+
+ + + + + \ No newline at end of file diff --git a/src/pages/pd-question/pd-question-business-group/pd-question-client-info/pd-question-client-info.scss b/src/pages/pd-question/pd-question-business-group/pd-question-client-info/pd-question-client-info.scss new file mode 100644 index 00000000..7d3770d4 --- /dev/null +++ b/src/pages/pd-question/pd-question-business-group/pd-question-client-info/pd-question-client-info.scss @@ -0,0 +1,13 @@ +page-pd-question-client-info { + mat-hint{ + font-size:12px; + } + .mat-card{ + margin-bottom: 15px; + border-radius: 10px !important; + box-shadow: 0 16px 38px -12px rgba(0, 0, 0, 0.56), 0 4px 25px 0 rgba(0, 0, 0, 0.12), 0 8px 10px -5px rgba(0, 0, 0, 0.2) !important; + } + .mat-card-content{ + margin-bottom: 0px !important; + } +} diff --git a/src/pages/pd-question/pd-question-business-group/pd-question-client-info/pd-question-client-info.ts b/src/pages/pd-question/pd-question-business-group/pd-question-client-info/pd-question-client-info.ts new file mode 100644 index 00000000..c9ce875b --- /dev/null +++ b/src/pages/pd-question/pd-question-business-group/pd-question-client-info/pd-question-client-info.ts @@ -0,0 +1,731 @@ +import { Component } from '@angular/core'; +import { IonicPage, NavController, NavParams } from 'ionic-angular'; +import { QuestionCategoryProvider } from '../../../../providers/question-category/question-category'; +import { AwsServiceProvider } from '../../../../providers/aws-service/aws-service'; +import { ToastProvider } from '../../../../providers/common-provider/toast'; +import { FormGroup, FormBuilder, FormArray } from '@angular/forms'; + +/** + * Generated class for the PdQuestionClientInfoPage page. + * + * See https://ionicframework.com/docs/components/#navigation for more info on + * Ionic pages and navigation. + */ + + +@Component({ + selector: 'page-pd-question-client-info', + templateUrl: 'pd-question-client-info.html', +}) +export class PdQuestionClientInfoPage { + + users: any; + pdDetails: any; + formDetails: any; + pdid:any; + company_id:any; + questionDetails: any; + clientInfoForm: FormGroup; + + + + + public submitted = false; + + public m_paymentType = []; + + companyRelationShipList: any=[]; + + titleList: any=[]; + noRecordsFound: Boolean = false; + errorMessage: any = ''; + m_manufacturingProducts : any =[]; + m_tradingProducts:any=[]; + m_suplierProducts : any =[]; + + + constructor(public navCtrl: NavController, public navParams: NavParams,public qustCat:QuestionCategoryProvider,public aws:AwsServiceProvider,public toast:ToastProvider,public fb:FormBuilder) { + this.pdDetails = this.navParams.get('pdDetails'); + this.formDetails=this.navParams.get('formDetails'); + this.users = this.aws.getlocale(); + this.pdid=this.pdDetails.pd_id; + this.company_id=this.pdDetails.company_id; + + this.qustCat.getTypeofActivityForSuppliedInfoForm(this.pdid,this.company_id).subscribe(data => { + + if(data.dataStatus){ + + let datas = data.records; + this.m_manufacturingProducts = datas.type_of_activity.filter(data=>{if(data.type_of_activity_id == 2 ){return data}}).map(data=> [...data.prodcuts]); + // this.m_tradingProducts = datas.type_of_activity.filter(data=>{if(data.type_of_activity_id == 3){return data}}).map(data=> [...data.prodcuts]); + this.m_suplierProducts = datas.type_of_activity.filter(data=>{if(data.type_of_activity_id == 5 ){return data}}).map(data=> [...data.prodcuts]); + let api = Object.keys(datas.type_of_activity).map(function (key) { + return datas.type_of_activity[key]; + }); + if(api.length > 0){ + api.forEach(val => { + if (val.type_of_activity_id == 3) { + if(val.prodcuts){ + this.m_tradingProducts.push(val.prodcuts); + } + } + + if (val.type_of_activity_id == 4) { + if(val.prodcuts){ + this.m_tradingProducts.push(val.prodcuts); + } + } + }); + } + this.m_tradingProducts = [].concat.apply([], this.m_tradingProducts); + + this.initFormLoadDetails(datas.type_of_activity); + + }else { + this.toast.pdTriggerappmessage('No Category Records Found.!'); + this.noRecordsFound = false; + this.errorMessage = data.msg; + } + }, err => { + this.toast.pdTriggerappmessage('No Category Records Found.!'); + this.noRecordsFound = false; + this.errorMessage = 'No Records Found , Something went Wrong!'; + }); + + this.getdropList(); + } + + ionViewDidLoad() { + console.log('ionViewDidLoad PdQuestionClientInfoPage'); + } + + initFormLoadDetails(record) { + let params: any = {}; + params.pd_id = this.pdid; + params.pd_form_id = this.formDetails.form_id; + params.company_id = this.company_id; + this.qustCat.retiverForm(params).subscribe( + data => { + if (data['dataStatus']) { + let dataForm = data['records']; + if (dataForm !== undefined) { + this.clientInfoForm = this.fb.group({ + pdid: [this.pdid], + formid: [this.formDetails.form_id], + company_id:[this.company_id], + fk_createdby:[this.users], + manufacturing_details: this.fb.array([this.manufacturingFormCreation(record)]), + trade_details: this.fb.array([this.tradingFormCreation(record)]), + service_provider_details: this.fb.array([this.serviceProviderFormCreation(record)]), + supplier_info_form_remark: [dataForm.supplier_info_form_remark || null] + // wholesale_trade_details: this.fb.array([this.tradingFormCreation(record)]), + }); + // Load form details for manufacturing + let arr = record.filter(data => data.type_of_activity_id == 2); + if (arr.length > 0) { + // let api_main_raw_materials = Object.keys(dataForm.main_raw_materials).map(function (key) { + // return dataForm.main_raw_materials[key]; + // }); + let api_main_raw_materials = dataForm.manufacturing_details[0].main_raw_materials; + + this.initManufacturingProductsDetails(api_main_raw_materials); + this.clientInfoForm.controls['manufacturing_details']['controls'][0].controls['main_raw_materials_total_payments_percent_on_credit'].setValue(dataForm.manufacturing_details[0].main_raw_materials_total_payments_percent_on_credit || null); + } + + // Load form details for the wholeshale trading details + let arr1 = record.filter(data => data.type_of_activity_id == 3 || data.type_of_activity_id == 4); + if (arr1.length > 0) { + // let api_trading_products = Object.keys(dataForm.trading_products).map(function (key) { + // return dataForm.trading_products[key]; + // }); + let api_trading_products = dataForm.trade_details[0].trading_products; + + this.initTradingProductsDetails(api_trading_products); + this.clientInfoForm.controls['trade_details']['controls'][0].controls['trading_products_total_payments_percent_on_credit'].setValue(dataForm.trade_details[0].trading_products_total_payments_percent_on_credit || null); + } + + // Load form details for the service provider prduct details + let arr2 = record.filter(data => data.type_of_activity_id == 5); + if (arr2.length > 0) { + // let api_service_provider_products = Object.keys(dataForm.service_products).map(function (key) { + // return dataForm.service_products[key]; + // }); + let api_service_provider_products = dataForm.service_provider_details[0].service_products; + this.initServiceProviderProductsDetails(api_service_provider_products); + this.clientInfoForm.controls['service_provider_details']['controls'][0].controls['service_products_total_payments_percent_on_credit'].setValue(dataForm.service_provider_details[0].service_products_total_payments_percent_on_credit || null); + } + // Load form details for the retail trading details + let arr3 = record.filter(data => data.type_of_activity_id == 3); + // if (arr3.length > 0) { + // this.retaildTradingForm = true; + // } + this.noRecordsFound = true; + } else { + this.clientInfoForm = this.fb.group({ + pdid: [this.pdid], + formid: [this.formDetails.form_id], + company_id:[this.company_id], + fk_createdby:[this.users], + manufacturing_details: this.fb.array([this.manufacturingFormCreation(record)]), + trade_details: this.fb.array([this.tradingFormCreation(record)]), + service_provider_details: this.fb.array([this.serviceProviderFormCreation(record)]), + supplier_info_form_remark: [dataForm.supplier_info_form_remark || null] + // wholesale_trade_details: this.fb.array([this.tradingFormCreation(record)]), + }); + let arr = record.filter(data => data.type_of_activity_id == 2); + if (arr.length > 0) { + this.initManufacturingProductsDetails(null); + this.clientInfoForm.controls['manufacturing_details']['controls'][0].controls['main_raw_materials_total_payments_percent_on_credit'].setValue(null); + } + let arr1 = record.filter(data => data.type_of_activity_id == 3 || data.type_of_activity_id == 4); + if (arr1.length > 0) { + this.initTradingProductsDetails(null); + this.clientInfoForm.controls['trade_details']['controls'][0].controls['trading_products_total_payments_percent_on_credit'].setValue(null); + } + let arr2 = record.filter(data => data.type_of_activity_id == 5); + if (arr2.length > 0) { + let api_service_provider_products = Object.keys(dataForm.service_products).map(function (key) { + return dataForm.service_products[key]; + }); + this.initServiceProviderProductsDetails(api_service_provider_products); + this.clientInfoForm.controls['service_provider_details']['controls'][0].controls['service_products_total_payments_percent_on_credit'].setValue(null); + } + // Load form details for the retail trading details + let arr3 = record.filter(data => data.type_of_activity_id == 3); + // if (arr3.length > 0) { + // this.retaildTradingForm = true; + // } + this.noRecordsFound = true; + } + } else { + this.clientInfoForm = this.fb.group({ + pdid: [this.pdid], + formid: [this.formDetails.form_id], + company_id:[this.company_id], + fk_createdby:[this.users], + manufacturing_details: this.fb.array([this.manufacturingFormCreation(record)]), + trade_details: this.fb.array([this.tradingFormCreation(record)]), + service_provider_details: this.fb.array([this.serviceProviderFormCreation(record)]), + supplier_info_form_remark: [] + // wholesale_trade_details: this.fb.array([this.tradingFormCreation(record)]), + }); + let arr = record.filter(data => data.type_of_activity_id == 2); + if (arr.length > 0) { + this.initManufacturingProductsDetails(null); + this.clientInfoForm.controls['manufacturing_details']['controls'][0].controls['main_raw_materials_total_payments_percent_on_credit'].setValue(null); + } + let arr1 = record.filter(data => data.type_of_activity_id == 3 || data.type_of_activity_id == 4); + if (arr1.length > 0) { + this.initTradingProductsDetails(null); + this.clientInfoForm.controls['trade_details']['controls'][0].controls['trading_products_total_payments_percent_on_credit'].setValue(null); + } + let arr2 = record.filter(data => data.type_of_activity_id == 5); + if (arr2.length > 0) { + this.initServiceProviderProductsDetails(null); + this.clientInfoForm.controls['service_provider_details']['controls'][0].controls['service_products_total_payments_percent_on_credit'].setValue(null); + } + // Load form details for the retail trading details + let arr3 = record.filter(data => data.type_of_activity_id == 3); + // if (arr3.length > 0) { + // this.retaildTradingForm = true; + // } + this.noRecordsFound = true; + } + }, err => { + + } + ); + } + + manufacturingForm: Boolean = false; + manufacturingFormCreation(val) { + let arr = val.filter(data => data.type_of_activity_id == 2); + if (arr.length > 0) { + this.manufacturingForm = true; + return this.fb.group({ + main_raw_materials: this.fb.array([]), + main_raw_materials_total_payments_percent_on_credit: [] + }) + // } + } else { + return; + } + } + + tradingForm: Boolean = false; + tradingFormCreation(val) { + // let arr = val.filter(data => data.type_of_activity_id == 4); + let arr = val.filter(data => data.type_of_activity_id == 3 || data.type_of_activity_id == 4); + if (arr.length > 0) { + this.tradingForm = true; + return this.fb.group({ + trading_products: this.fb.array([]), + trading_products_total_payments_percent_on_credit: [] + }); + } else { + return; + } + } + + serviceProviderForm: Boolean = false; + serviceProviderFormCreation(val) { + let arr = val.filter(data => data.type_of_activity_id == 5); + if (arr.length > 0) { + this.serviceProviderForm = true; + return this.fb.group({ + service_products: this.fb.array([]), + service_products_total_payments_percent_on_credit: [] + }); + } else { + return; + } + } + + initManufacturingProductsDetails(datas) { + const control = this.clientInfoForm.controls['manufacturing_details']['controls'][0].controls['main_raw_materials']; + if (datas === null) { + control.push(this.initManufacturingProducts(null)); + } else { + datas.forEach((val,inx) => { + this.checkCard(val.manufacturing_payment_type,1,inx); + control.push(this.initManufacturingProducts(val)); + }); + // for (let val of datas) { + // control.push(this.initManufacturingProducts(val)); + // } + } + } + + initManufacturingProducts(records) { + if (records === null) { + return this.fb.group({ + manufacturing_product_name: [''], + manufacturing_client_name: [''], + manufacturing_contact_person_name: [''], + manufacturing_contact_person_mobile_number: [''],//,Validators.compose([Validators.minLength(10),Validators.maxLength(10)])], + manufacturing_payment_type: [''], + manufacturing_payment_mode:[''], + // manufacturing_credit_days: [''], + person_title_name:[''], + person_designation:[''], + person_stdcode:[''],// Validators.compose([Validators.minLength(3),Validators.maxLength(5),Validators.pattern('^[0-9]*$')])], + person_landline:[''],// Validators.compose([Validators.minLength(6),Validators.maxLength(8),Validators.pattern('^[0-9]*$')])], + other_person_designation:[''], + manufacturing_credit_days_from:[''], + manufacturing_credit_days_to:[''] + }) + } else { + return this.fb.group({ + manufacturing_product_name: [records.manufacturing_product_name || null], + manufacturing_client_name: [records.manufacturing_client_name || null], + manufacturing_contact_person_name: [records.manufacturing_contact_person_name || null], + manufacturing_contact_person_mobile_number: [records.manufacturing_contact_person_mobile_number || null],//Validators.compose([Validators.minLength(10),Validators.maxLength(10)])], + manufacturing_payment_type: [records.manufacturing_payment_type || null], + manufacturing_payment_mode:[records.manufacturing_payment_mode || null], + manufacturing_credit_days: [records.manufacturing_credit_days || null], + person_title_name:[records.person_title_name || null], + person_designation:[records.person_designation || null], + person_stdcode:[records.person_stdcode || null],// Validators.compose([Validators.minLength(3),Validators.maxLength(5),Validators.pattern('^[0-9]*$')])], + person_landline:[records.person_landline || null],// Validators.compose([Validators.minLength(6),Validators.maxLength(8),Validators.pattern('^[0-9]*$')])], + other_person_designation:[records.other_person_designation || null], + manufacturing_credit_days_from:[records.manufacturing_credit_days_from || null], + manufacturing_credit_days_to:[records.manufacturing_credit_days_to || null] + }) + } + } + + initTradingProductsDetails(datas) { + const control = this.clientInfoForm.controls['trade_details']['controls'][0].controls['trading_products']; + if (datas === null) { + control.push(this.initTradingProducts(null)); + } else { + datas.forEach((val,inx) => { + this.checkCard(val.trade_product_payment_type,2,inx); + control.push(this.initTradingProducts(val)); + }); + // for (let val of datas) { + // control.push(this.initTradingProducts(val)); + // } + } + } + + initTradingProducts(records) { + if (records === null) { + return this.fb.group({ + trade_product_name: [''], + trade_client_name: [''], + trade_product_contact_person_name: [''], + trade_product_contact_person_mobile_number: [''],//Validators.compose([Validators.minLength(10),Validators.maxLength(10)])], + trade_product_payment_type: [''], + trade_product_payment_mode:[''], + trade_product_frequency_of_purchase: [''], + trade_product_credit_days_from: [''], + trade_product_credit_days_to: [''], + person_title_name:[''], + person_designation:[''], + person_stdcode:[''],// Validators.compose([Validators.minLength(3),Validators.maxLength(5),Validators.pattern('^[0-9]*$')])], + person_landline:[''],// Validators.compose([Validators.minLength(6),Validators.maxLength(8),Validators.pattern('^[0-9]*$')])], + other_person_designation:[''], + }) + } else { + return this.fb.group({ + trade_product_name: [records.trade_product_name], + trade_client_name: [records.trade_client_name], + trade_product_contact_person_name: [records.trade_product_contact_person_name], + trade_product_contact_person_mobile_number: [records.trade_product_contact_person_mobile_number],//Validators.compose([Validators.minLength(10),Validators.maxLength(10)])], + trade_product_payment_type: [records.trade_product_payment_type], + trade_product_payment_mode:[records.trade_product_payment_mode], + trade_product_frequency_of_purchase: [records.trade_product_frequency_of_purchase], + trade_product_credit_days_from: [records.trade_product_credit_days_from], + trade_product_credit_days_to: [records.trade_product_credit_days_to], + person_title_name:[records.person_title_name || null], + person_designation:[records.person_designation || null], + person_stdcode:[records.person_stdcode || null],// Validators.compose([Validators.minLength(3),Validators.maxLength(5),Validators.pattern('^[0-9]*$')])], + person_landline:[records.person_landline || null],// Validators.compose([Validators.minLength(6),Validators.maxLength(8),Validators.pattern('^[0-9]*$')])], + other_person_designation:[records.other_person_designation || null], + }) + } + } + + initServiceProviderProductsDetails(datas) { + const control = this.clientInfoForm.controls['service_provider_details']['controls'][0].controls['service_products']; + if (datas === null) { + control.push(this.initServiceProviderProducts(null)); + } else { + datas.forEach((val,inx) => { + this.checkCard(val.service_provider_product_payment_type,3,inx); + control.push(this.initServiceProviderProducts(val)); + }); + // for (let val of datas) { + // control.push(this.initServiceProviderProducts(val)); + // } + } + } + + initServiceProviderProducts(records) { + if (records === null) { + return this.fb.group({ + service_provider_product_name: [''], + service_provider_client_name: [''], + service_provider_product_contact_person_name: [''], + service_provider_product_contact_person_mobile_number: [''],//Validators.compose([Validators.minLength(10),Validators.maxLength(10)])], + service_provider_product_payment_type: [''], + service_provider_product_payment_mode:[''], + service_provider_product_frequency_of_purchase: [''], + service_provider_product_credit_days_from: [''], + service_provider_product_credit_days_to: [''], + person_title_name:[''], + person_designation:[''], + person_stdcode:[''], //Validators.compose([Validators.minLength(3),Validators.maxLength(5),Validators.pattern('^[0-9]*$')])], + person_landline:[''],// Validators.compose([Validators.minLength(6),Validators.maxLength(8),Validators.pattern('^[0-9]*$')])], + other_person_designation:[''], + }) + } else { + return this.fb.group({ + service_provider_product_name: [records.service_provider_product_name], + service_provider_client_name: [records.service_provider_client_name], + service_provider_product_contact_person_name: [records.service_provider_product_contact_person_name], + service_provider_product_contact_person_mobile_number: [records.service_provider_product_contact_person_mobile_number],//Validators.compose([Validators.minLength(10),Validators.maxLength(10)])], + service_provider_product_payment_type: [records.service_provider_product_payment_type], + service_provider_product_payment_mode: [records.service_provider_product_payment_mode], + service_provider_product_frequency_of_purchase: [records.service_provider_product_frequency_of_purchase], + service_provider_product_credit_days_from: [records.service_provider_product_credit_days_from], + service_provider_product_credit_days_to: [records.service_provider_product_credit_days_to], + person_title_name:[records.person_title_name || null], + person_designation:[records.person_designation || null], + person_stdcode:[records.person_stdcode || null],// Validators.compose([Validators.minLength(3),Validators.maxLength(5),Validators.pattern('^[0-9]*$')])], + person_landline:[records.person_landline || null],// Validators.compose([Validators.minLength(6),Validators.maxLength(8),Validators.pattern('^[0-9]*$')])], + other_person_designation:[records.other_person_designation || null], + }) + } + } + + addMoreRawMaterials(e): void { + // e.stropPropagation(); + const control = this.clientInfoForm.controls['manufacturing_details']['controls'][0].controls['main_raw_materials']; + + control.push(this.initManufacturingProducts(null)); + } + + removeRawMaterials(inx): void { + const control = this.clientInfoForm.controls['manufacturing_details']['controls'][0].controls['main_raw_materials']; + control.removeAt(inx); + } + + addMoretradeProduct(e): void { + // e.stropPropagation(); + const control = this.clientInfoForm.controls['trade_details']['controls'][0].controls['trading_products']; + + control.push(this.initTradingProducts(null)); + } + + removeTradingProduct(inx): void { + const control = this.clientInfoForm.controls['trade_details']['controls'][0].controls['trading_products']; + control.removeAt(inx); + } + + addMoreServiceProduct(e): void { + // e.stropPropagation(); + const control = this.clientInfoForm.controls['service_provider_details']['controls'][0].controls['service_products']; + + control.push(this.initServiceProviderProducts(null)); + } + + removeServiceProduct(inx): void { + const control = this.clientInfoForm.controls['service_provider_details']['controls'][0].controls['service_products']; + control.removeAt(inx); + } + + getdropList(){ + + this.qustCat.getcommondrop('COMPANYRELATIONSHIPS').subscribe( + data => { + this.companyRelationShipList = data['records'].filter(data => data.isactive == 1); + }); + + this.qustCat.getcommondrop('TITLES').subscribe( + data => { + this.titleList = data['records'].filter(data => data.isactive == 1); + }); + + this.qustCat.getcommondrop('PAYMENTMODE').subscribe( + data => { + this.m_paymentType = data['records'].filter(data => data.isactive == 1); + }); + } +// saveclientDetails(answerData) +// { +// let records:any ={}; + +// records.pdid = this.pdDetails.pd_id; +// records.formid = this.FormId.form_id; +// records.fk_createdby = this.users; + +// records.client_details = answerData.clientArray; + +// this.qustCat.saveForm(records).subscribe(res=> +// { +// if(res['dataStatus']==true) +// { +// this.toast.pdTriggerappmessage('Record Saved Successfully.!'); +// this.navCtrl.pop(); +// } +// }); + + +// } +/** To Save/Edited Popup Data */ +saveClientInfo(answerFormValues){ +// console.log(answerFormValues); +Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]); +if(answerFormValues.manufacturing_details[0]==null){ + delete answerFormValues['manufacturing_details']; +} +if(answerFormValues.trade_details[0]==null){ + delete answerFormValues['trade_details']; +} +if(answerFormValues.service_provider_details[0]==null){ + delete answerFormValues['service_provider_details']; +} + + //To Remove The "Null" With Key also + Object.keys(answerFormValues).forEach((key) => {if(answerFormValues[key] === null || answerFormValues[key] === undefined || answerFormValues[key] === ''){ delete answerFormValues[key]}; }); + this.qustCat.saveForm(answerFormValues).subscribe(responsed=> + { + if(responsed['status'] == 200) { + this.navCtrl.pop(); + this.toast.pdTriggerappmessage('Record Saved Successfully.!'); + }else{ + this.toast.pdTriggerappmessage('Something Wents Wrong Try Again.!'); + } + }); + +} + +selectedPersonDesignation(items,e,flag){ + if(flag == 1){ + // e==1 ? items.controls['other_person_designation'].setValidators([Validators.required]) + // : items.controls['other_person_designation'].clearValidators(),items.controls['other_person_designation'].setValue(''); + // items.controls['other_person_designation'].updateValueAndValidity(); + } + else if(flag == 2){ + // e==1 ?items.controls['other_person_designation'].setValidators([Validators.required]) + // :items.controls['other_person_designation'].clearValidators(),items.controls['other_person_designation'].setValue(''); + // items.controls['other_person_designation'].updateValueAndValidity(); + } + else if(flag == 3){ + // e==1 ?items.controls['other_person_designation'].setValidators([Validators.required]) + // :items.controls['other_person_designation'].clearValidators(),items.controls['other_person_designation'].setValue(''); + // items.controls['other_person_designation'].updateValueAndValidity(); + } +} + +mfgCreditCardFlag : boolean = false; +trdCreditCardFlag : boolean = false; +spCreditCardFlag : boolean = false; +mfgCounter: any = []; +trdCounter: any = []; +spCounter: any =[]; +checkCard(e,flag,index){ + + if(flag == 3 && e==3){ + this.spCounter[index] = 1; + } + else if(flag == 3 && e!=3){ + this.spCounter[index] = 0; + } + let SP = this.spCounter.reduce((sum, val) => sum + +val, 0); + this.spCreditCardFlag = SP > 0 ? true : false ; + + if(flag == 2 && e==3){ + this.trdCounter[index] = 1; + } + else if(flag == 2 && e!=3){ + this.trdCounter[index] = 0; + } + let TRD = this.trdCounter.reduce((sum, val) => sum + +val, 0); + this.trdCreditCardFlag = TRD > 0 ? true : false ; + + if(flag == 1 && e==3){ + this.mfgCounter[index] = 1; + } + else if(flag == 1 && e!=3){ + this.mfgCounter[index] = 0; + } + let MFG = this.mfgCounter.reduce((sum, val) => sum + +val, 0); + this.mfgCreditCardFlag = MFG > 0 ? true : false ; + +} + + +} +//paymentModeTextBox: any; +//clientDataArray:FormArray; +//apiLoadFinish:boolean = false; +// this.clientForms = this.fb.group({ +// clientArray:this.fb.array([]) +// }); +// this.getClientDetails(); +// this.getdropdown(); + + +// createClientItem() +// { +// return this.fb.group( +// { +// client_name: [''], +// contact_person: [''], +// mobile_number: [''], +// payment_mode: [''], +// per_of_immediate_advance_payment:[''], +// credit_period:[''], +// frequency_of_purchase: [''], +// freq_purchase_others_text_value: [''] +// }) +// } +// selectedPM(e) { +// this.paymentModeTextBox = e.value; +// // this.f.supplier_details.controls.get('payment_mode_value'); +// } +// public freqPurchaseTextBox: number; +// selectedFreqPurchase(e){ +// this.freqPurchaseTextBox = e.value; +// } +// getdropdown() +// { +// this.qustCat.getcommondrop('FREQUENCY').subscribe( +// data => { +// this.m_freqOfPurchase = data['records'].filter(data => data.isactive == 1); +// }, +// error => { +// // this.notifier.notify('warning', 'No Category Records Found.!'); +// // this.m_assets_type = "No Category Records Found."; +// } +// ) +// this.qustCat.getcommondrop('PAYMENTMODE').subscribe( +// data => { +// this.m_paymentModeType = data['records'].filter(data => data.isactive == 1); +// }, +// error => { +// // this.notifier.notify('warning', 'No Category Records Found.!'); +// // this.m_assets_type = "No Category Records Found."; +// } +// ) +// } +// addClientDetails() +// { +// this.clientDataArray = this.clientForms.get('clientArray') as FormArray; +// this.clientDataArray.push(this.createClientItem()); +// } +// removeClientDetails(i) +// { + +// if(this.clientDataArray.length==1) +// { +// this.clientForms.controls['clientArray'].reset(); +// }else{ +// this.clientDataArray = this.clientForms.get('clientArray') as FormArray; +// this.clientDataArray.removeAt(i); +// } +// } + +// saveclientDetails(answerData) +// { +// let records:any ={}; + +// records.pdid = this.pdDetails.pd_id; +// records.formid = this.FormId.form_id; +// records.fk_createdby = this.users; + +// records.client_details = answerData.clientArray; + +// this.qustCat.saveForm(records).subscribe(res=> +// { +// if(res['dataStatus']==true) +// { +// this.toast.pdTriggerappmessage('Record Saved Successfully.!'); +// this.navCtrl.pop(); +// } +// }); + + +// } +// getClientDetails() +// { +// let records = {'pd_id':this.pdDetails.pd_id,'pd_form_id':this.FormId.form_id} +// let clientData:any = []; +// this.qustCat.retiverForm(records).subscribe( +// data => { +// if(data['dataStatus']==true) +// { +// let clientDetails = data['records']; + +// clientData = Object.keys(data['records'].client_details).map(function(key) { + +// return clientDetails.client_details[key]; +// }); +// this.clientDataArray = this.clientForms.get('clientArray') as FormArray; + +// if(clientData.length ==0) +// { + +// this.clientDataArray.push(this.createClientItem()); +// }else +// { + +// clientData.forEach(datas=> +// { +// this.clientDataArray.push(this.createClientItem()); +// }) + +// this.clientForms.controls['clientArray'].setValue(clientData); +// this.apiLoadFinish = true; +// } +// }else{ + +// this.addClientDetails(); +// this.apiLoadFinish = true; +// } +// } +// ); +// } diff --git a/src/pages/pd-question/pd-question-business-group/pd-question-stock-info/pd-question-stock-info.html b/src/pages/pd-question/pd-question-business-group/pd-question-stock-info/pd-question-stock-info.html new file mode 100644 index 00000000..6e631cf0 --- /dev/null +++ b/src/pages/pd-question/pd-question-business-group/pd-question-stock-info/pd-question-stock-info.html @@ -0,0 +1,452 @@ + + + + + {{formDetails.form_name}} + + + + + + +
+ + + Manufacturing Stock Details +
+
+
+
+ + Raw Material #{{a+1}} + + + + + + + + Add Stock Details + No Stock Observed + + + + + + + + + {{uom.name}} + + + + + + + + {{"₹"}} {{M_rawValueInWords[a]}} Only + + + + + Yes + No + + + + + Please comment on the stock level observed? + + + + + + + + + + + + + + + + +
+
+ +
+
+ + Finished Goods #{{b+1}} + + + + + + + + Add Stock Details + No Stock Observed + + + + + + + + + {{uom.name}} + + + + + + + + {{"₹"}} {{M_goodsValueInWords[b]}} Only + + + + + Yes + No + + + + Please comment on the finished goods stock level observed? + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + Retail Trading Details +
+
+ +
+
+ + + Traded Goods #{{e+1}} + + + + + + + Add Stock Details + No Stock Observed + + + + + + + + + {{uom.name}} + + + + + + + + {{"₹"}} {{R_tradedGoodsValueInWords[e]}} Only + + + + + Yes + No + + + + + Please comment on the Traded Goods stock level observed? + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + Wholesale Trading Details +
+
+
+
+ + Traded Goods #{{g+1}} + + + + + + + Add Stock Details + No stock observed + + + + + + + + + {{uom.name}} + + + + + + + + {{"₹"}} {{T_tradedGoodsValueInWords[g]}} Only + + + + + + Yes + No + + + + + Please comment on the Traded Goods stock level observed? + + + + + + + + + + + + + + + + + +
+
+
+
+ +
+ + + Service Provider Details +
Service Provider Details Not applicable here !!
+
+ + + + Remarks + + + + + + + + + + + + + + + + +
+ +
+ +
{{ errorMessage }}
+
+ + \ No newline at end of file diff --git a/src/pages/pd-question/pd-question-business-group/pd-question-stock-info/pd-question-stock-info.scss b/src/pages/pd-question/pd-question-business-group/pd-question-stock-info/pd-question-stock-info.scss new file mode 100644 index 00000000..af5e7d9d --- /dev/null +++ b/src/pages/pd-question/pd-question-business-group/pd-question-stock-info/pd-question-stock-info.scss @@ -0,0 +1,13 @@ +page-pd-question-stock-info { + mat-hint{ + font-size:12px; + } + .mat-card{ + margin-bottom: 15px; + border-radius: 10px !important; + box-shadow: 0 16px 38px -12px rgba(0, 0, 0, 0.56), 0 4px 25px 0 rgba(0, 0, 0, 0.12), 0 8px 10px -5px rgba(0, 0, 0, 0.2) !important; + } + .mat-card-content{ + margin-bottom: 0px !important; + } +} diff --git a/src/pages/pd-question/pd-question-business-group/pd-question-stock-info/pd-question-stock-info.ts b/src/pages/pd-question/pd-question-business-group/pd-question-stock-info/pd-question-stock-info.ts new file mode 100644 index 00000000..9c0d8ab5 --- /dev/null +++ b/src/pages/pd-question/pd-question-business-group/pd-question-stock-info/pd-question-stock-info.ts @@ -0,0 +1,803 @@ +import { Component } from '@angular/core'; +import { IonicPage, NavController, NavParams } from 'ionic-angular'; +import { QuestionCategoryProvider } from '../../../../providers/question-category/question-category'; +import { AwsServiceProvider } from '../../../../providers/aws-service/aws-service'; +import { ToastProvider } from '../../../../providers/common-provider/toast'; +import { FormArray, FormGroup, FormBuilder } from '@angular/forms'; +import { ConstantsProvider } from '../../../../providers/constants/constants'; + +/** + * Generated class for the PdQuestionStockInfoPage page. + * + * See https://ionicframework.com/docs/components/#navigation for more info on + * Ionic pages and navigation. + */ + + +@Component({ + selector: 'page-pd-question-stock-info', + templateUrl: 'pd-question-stock-info.html', +}) +export class PdQuestionStockInfoPage { + + uomData: any; + rawmaterial: any; + users: any; + formDetails: any; + pdDetails: any; + company_id : any; + pdid:any; + stockForm: FormGroup; + + noRecordsFound: Boolean; + errorMessage: any = ''; + + M_rawValueInWords : any = []; + M_goodsValueInWords : any = []; + R_tradedGoodsValueInWords : any = []; + T_tradedGoodsValueInWords : any = []; + + mrmCommentFlag:any=[]; + mfgCommentFlag:any=[]; + rtrdCommentFlag:any=[]; + wtrdCommentFlag:any=[]; + + serviceProviderForm: Boolean = false; + suppliers_raw_materials : any = []; + suppliers_retail_trade_details : any = []; + suppliers_wholesale_trade_details : any = []; + suppliers_finished_goods : any =[]; + + constructor(public navCtrl: NavController, public navParams: NavParams, public qustCat: QuestionCategoryProvider, public aws: AwsServiceProvider, public toast: ToastProvider, public fb: FormBuilder,public constant:ConstantsProvider) { + this.pdDetails = this.navParams.get('pdDetails'); + this.formDetails=this.navParams.get('formDetails'); + this.users = this.aws.getlocale(); + this.company_id=this.pdDetails.company_id; + this.pdid=this.pdDetails.pd_id; + + this.qustCat.stockFormAccess(this.pdid,this.company_id).subscribe(data => { + + if(data.dataStatus == true){ + this.initstockForm(data.record); + } + else if(data.dataStatus == false) + { + this.toast.pdTriggerappmessage('Fill Business Form First! / No Company Found at this ID '+ this.company_id ); + this.noRecordsFound = false; + this.errorMessage = 'Fill Business Form First! / No Company Found at this ID' + this.company_id +'! ....'; + return; + } + else{ + this.toast.pdTriggerappmessage('Fill Business Form First! / No Company Found at this ID '+ this.company_id ); + this.noRecordsFound = false; + this.errorMessage = 'Fill Business Form First! / No Company Found at this ID' + this.company_id +'! ....'; + return; + } + }, err => { + this.toast.pdTriggerappmessage('Business Type Of Activity Not Available Please Check Business Information.!'); + this.noRecordsFound = false; + this.errorMessage = 'No Records Found , Something went Wrong!'; + }) + + this.getdropdown(); + } + + public initstockForm(record){ + + let api = Object.keys(record.from_business).map(function (key) { + return record.from_business[key]; + }); + let rm_api = record.from_supplier; + + let params: any = {}; + params.pd_id = this.pdid; + params.pd_form_id = this.formDetails.form_id; + params.company_id = this.company_id; + this.qustCat.retiverForm(params).subscribe(value => { + + if (value['status'] == 200) { + let dataForm = value['records']; + + if(dataForm !== undefined) { + this.stockForm = this.fb.group({ + pdid: [this.pdid], + formid: [this.formDetails.form_id], + company_id: [this.company_id], + fk_createdby:[this.users], + stock_remarks: [dataForm.stock_remarks], + manufacturing_details: this.fb.array([this.manufacturingFormCreation(record)]), + retail_details : this.fb.array([this.retailFormCreation(api)]), + trade_details: this.fb.array([this.tradingFormCreation(api)]), + }); + if(api.length > 0){ + api.forEach(val => { + if (val.type_of_activity_id == 2) { + if(val.products){ + let manufacturing_temparr = []; + manufacturing_temparr['manufacturing_raw_materials'] = dataForm.manufacturing_details[0].manufacturing_raw_materials; + manufacturing_temparr['manufacturing_finished_goods'] = dataForm.manufacturing_details[0].manufacturing_finished_goods; + this.initManufacturingDetails(manufacturing_temparr); + } + } + if (val.type_of_activity_id == 3) { + if(val.products){ + let retail_temparr = []; + retail_temparr['retail_traded_goods'] = dataForm.retail_details[0].retail_traded_goods; + this.initRetailDetails(retail_temparr); + } + } + if (val.type_of_activity_id == 4) { + if(val.products){ + let trading_temparr = []; + trading_temparr['trading_traded_goods'] = dataForm.trade_details[0].trading_traded_goods; + this.initTradingDetails(trading_temparr); + } + } + if (val.type_of_activity_id == 5) { + if(val.products){ + this.serviceProviderForm = true; + } + } + }); + this.noRecordsFound = true; + } + } + else{ + + this.stockForm = this.fb.group({ + pdid: [this.pdid], + formid: [this.formDetails.form_id], + company_id: [this.company_id], + fk_createdby:[this.users], + stock_remarks: [''], + manufacturing_details: this.fb.array([this.manufacturingFormCreation(record)]), + retail_details : this.fb.array([this.retailFormCreation(record.from_business)]), + trade_details: this.fb.array([this.tradingFormCreation(record.from_business)]), + }); + + if(api.length > 0){ + api.forEach(val => { + if (val.type_of_activity_id == 2) { + if(val.products){ + this.suppliers_finished_goods = val.products; + this.initManufacturingDetails(null); + } + } + if (val.type_of_activity_id == 3) { + if(val.products){ + this.suppliers_retail_trade_details = val.products; + this.initRetailDetails(null); + } + } + if (val.type_of_activity_id == 4) { + if(val.products){ + this.suppliers_wholesale_trade_details =val.products; + this.initTradingDetails(null); + } + } + if (val.type_of_activity_id == 5) { + if(val.products){ + // this.suppliers_service_product = val.products; + this.serviceProviderForm = true; + } + + } + + }); + this.noRecordsFound = true; + } + } + } + else { + this.stockForm = this.fb.group({ + pdid: [this.pdid], + formid: [this.formDetails.form_id], + company_id: [this.company_id], + fk_createdby:[this.users], + stock_remarks: [''], + manufacturing_details: this.fb.array([this.manufacturingFormCreation(record)]), + retail_details : this.fb.array([this.retailFormCreation(record.from_business)]), + trade_details: this.fb.array([this.tradingFormCreation(record.from_business)]), + }); + if(api.length > 0){ + api.forEach(val => { + if (val.type_of_activity_id == 2) { + if(val.products){ + this.suppliers_finished_goods = val.products; + this.suppliers_raw_materials = rm_api; + this.initManufacturingDetails(null); + } + } + if (val.type_of_activity_id == 3) { + if(val.products){ + this.suppliers_retail_trade_details= val.products; + this.initRetailDetails(null); + } + } + if (val.type_of_activity_id == 4) { + if(val.products){ + this.suppliers_wholesale_trade_details = val.products; + this.initTradingDetails(null); + } + } + if (val.type_of_activity_id == 5) { + if(val.products){ + // this.suppliers_service_product = val.products; + this.serviceProviderForm = true; + } + } + }); + this.noRecordsFound = true; + } + } + }) + } + + ionViewDidLoad() { + console.log('ionViewDidLoad PdQuestionStockInfoPage'); + } + + + getdropdown() + { + this.qustCat.getcommondrop('UOM').subscribe(data => { + + if(data['dataStatus']==true){ + + this.uomData = data['records'].filter(uom=>uom.isactive==1); + + } + }); + } + + manufacturingForm: Boolean = false; + manufacturingFormCreation(record) { + + let arr = record.from_business.filter(data => data.type_of_activity_id == 2); + let rm_arr = record.from_supplier; + + if (arr.length > 0) { + this.manufacturingForm = true; + return this.fb.group({ + manufacturing_raw_materials: this.fb.array([]), + manufacturing_finished_goods: this.fb.array([]), + }) + } else { + return; + } + } + + retailForm: Boolean = false; + retailFormCreation(val) { + + let arr = val.filter(data => data.type_of_activity_id == 3); + if (arr.length > 0) { + this.retailForm = true; + return this.fb.group({ + retail_traded_goods: this.fb.array([]) + }) + // } + } else { + return; + } + } + + tradingForm: Boolean = false; + tradingFormCreation(val) { + let arr = val.filter(data => data.type_of_activity_id == 4); + if (arr.length > 0) { + this.tradingForm = true; + return this.fb.group({ + trading_traded_goods: this.fb.array([]) + }); + } else { + return; + } + } + + initManufacturingDetails(datas) { + + const rawMaterial = this.stockForm.controls['manufacturing_details']['controls'][0].controls['manufacturing_raw_materials']; + const finishedGoods = this.stockForm.controls['manufacturing_details']['controls'][0].controls['manufacturing_finished_goods']; + const control = this.stockForm.controls['manufacturing_details']['controls'][0].controls['main_raw_materials']; + if(datas === null){ + + + if(this.suppliers_raw_materials.length > 0){ + this.suppliers_raw_materials.forEach(val => { + let Ref_RawMaterials : any = {'raw_name': val, + 'stock_observed':'', + 'raw_quantity': '', + 'raw_uom': '', + 'other_uom': '', + 'raw_value': '', + 'is_sufficiant_raw': '', + 'rawmaterial_remarks':''}; + rawMaterial.push(this.createRawmaterial(Ref_RawMaterials)); + }); + } + else{ + rawMaterial.push(this.createRawmaterial(null)); + } + + if(this.suppliers_finished_goods.length > 0){ + // for (let val of this.suppliers_finished_goods) { + this.suppliers_finished_goods.forEach(val => { + let Ref_Finished_Goods : any = {'goods_name': val, + 'goods_observed': '', + 'goods_quantity': '', + 'goods_uom': '', + 'goods_other_uom': '', + 'goods_value': '', + 'is_sufficiant_goods': '', + 'finishedgoods_remarks':''}; + finishedGoods.push(this.createGoods(Ref_Finished_Goods)); + // finishedGoods.push(this.createGoods(null)); + }); + } + else{ + finishedGoods.push(this.createGoods(null)); + } + + } else { + + if(datas.manufacturing_raw_materials != undefined){ + // for (let val of datas.manufacturing_raw_materials) { + datas.manufacturing_raw_materials.forEach((val,index) => { + if(val.raw_value){ + this.inWords(val.raw_value,1,index); + } + this.checkComments(val.is_sufficiant_raw,1,index); + rawMaterial.push(this.createRawmaterial(val)); + }); + } + else{ + rawMaterial.push(this.createRawmaterial(null)); + } + if(datas.manufacturing_finished_goods != undefined){ + // for (let val of datas.manufacturing_finished_goods) { + datas.manufacturing_finished_goods.forEach((val,index) => { + + if(val.goods_value){ + this.inWords(val.goods_value,2,index); + } + this.checkComments(val.is_sufficiant_goods,2,index); + finishedGoods.push(this.createGoods(val)); + + }); + } + else{ + finishedGoods.push(this.createGoods(null)); + } + } + } + + createRawmaterial(records) { + + if(records === null) { + + return this.fb.group({ + raw_name: [''], + stock_observed:[''], + raw_quantity: [''], + raw_uom: [''], + other_uom : [''], + raw_value: [''], + // rawmaterial_value: [''], + is_sufficiant_raw: [''], + rawmaterial_remarks:[''] + }) + } else { + + return this.fb.group({ + // manufacturing_raw_material_name: [records.manufacturing_raw_material_name || null], + raw_name: [records.raw_name], + stock_observed:[records.stock_observed], + raw_quantity: [records.raw_quantity], + raw_uom: [records.raw_uom], + other_uom : [records.other_uom], + raw_value: [records.raw_value], + // rawmaterial_value: [records.rawmaterial_value], + is_sufficiant_raw: [records.is_sufficiant_raw], + rawmaterial_remarks:[records.rawmaterial_remarks] + }) + } + } + + initRetailDetails(datas) { + + const tradedGoods = this.stockForm.controls['retail_details']['controls'][0].controls['retail_traded_goods']; + + if(datas === null){ + + if(this.suppliers_retail_trade_details.length > 0){ + // this.rawMaterialAccess = true; + + this.suppliers_retail_trade_details.forEach(val => { + let Ref_Trade_Goods : any = { + 'traded_goods_name': val, + 'traded_goods_observed': '', + 'traded_goods_quantity': '', + 'traded_goods_uom': '', + 'traded_goods_other_uom': '', + 'estimated_traded_goods_value': '', + 'is_sufficiant_traded_goods': '', + 'traded_goods_remarks':''}; + tradedGoods.push(this.createTradedGoods(Ref_Trade_Goods)); + }); + } + else{ + tradedGoods.push(this.createTradedGoods(null)); + } + + } else { + if(datas.retail_traded_goods !== undefined){ + // for (let val of datas.retail_traded_goods) { + datas.retail_traded_goods.forEach((val,index) => { + + if(val.estimated_traded_goods_value){ + this.inWords(val.estimated_traded_goods_value,3,index); + } + this.checkComments(val.is_sufficiant_traded_goods,3,index); + tradedGoods.push(this.createTradedGoods(val)); + + }); + } + else{ + tradedGoods.push(this.createTradedGoods(null)); + } + } + } + + + createGoods(records) { + if(records === null) { + return this.fb.group({ + goods_name: [''], + goods_observed: [''], + goods_quantity: [''], + goods_uom: [''], + goods_other_uom: [''], + goods_value: [''], + // finished_goods_value: [''], + is_sufficiant_goods: [''], + finishedgoods_remarks:[''] + }); + } + else { + return this.fb.group({ + goods_name: [records.goods_name], + goods_observed: [records.goods_observed], + goods_quantity: [records.goods_quantity], + goods_uom: [records.goods_uom], + goods_other_uom: [records.goods_other_uom], + goods_value: [records.goods_value], + // finished_goods_value: [records.finished_goods_value], + is_sufficiant_goods: [records.is_sufficiant_goods], + finishedgoods_remarks:[records.finishedgoods_remarks] + }) + } + } + + initTradingDetails(datas) { + const tradedGoods = this.stockForm.controls['trade_details']['controls'][0].controls['trading_traded_goods']; + if(datas === null){ + + + if(this.suppliers_wholesale_trade_details.length > 0){ + // for (let val of this.suppliers_trade_details) { + this.suppliers_wholesale_trade_details.forEach(val => { + let Ref_Trade_Goods : any = { + 'traded_goods_name': val, + 'traded_goods_observed': '', + 'traded_goods_quantity': '', + 'traded_goods_uom': '', + 'traded_goods_other_uom': '', + 'estimated_traded_goods_value': '', + 'is_sufficiant_traded_goods': '', + 'traded_goods_remarks':''}; + tradedGoods.push(this.createTradedGoods(Ref_Trade_Goods)); + }); + } + else{ + tradedGoods.push(this.createTradedGoods(null)); + } + + } else { + if(datas.trading_traded_goods !==undefined) + { + // for (let val of datas.trading_traded_goods) { + datas.trading_traded_goods.forEach((val,index) => { + + if(val.estimated_traded_goods_value){ + this.inWords(val.estimated_traded_goods_value,4,index); + } + this.checkComments(val.is_sufficiant_traded_goods,4,index); + tradedGoods.push(this.createTradedGoods(val)); + }); + } + else{ + tradedGoods.push(this.createTradedGoods(null)); + } + + } + } + + createTradedGoods(records) { + if(records === null) { + return this.fb.group({ + traded_goods_name: [''], + traded_goods_observed: [''], + traded_goods_quantity: [''], + traded_goods_uom: [''], + traded_goods_other_uom: [''], + estimated_traded_goods_value: [''], + // traded_goods_value: [''], + is_sufficiant_traded_goods: [''], + traded_goods_remarks:[''] + }); + } + else { + return this.fb.group({ + traded_goods_name: [records.traded_goods_name], + traded_goods_observed: [records.traded_goods_observed], + traded_goods_quantity: [records.traded_goods_quantity], + traded_goods_uom: [records.traded_goods_uom], + traded_goods_other_uom: [records.traded_goods_other_uom], + estimated_traded_goods_value: [records.estimated_traded_goods_value], + // traded_goods_value: [records.traded_goods_value], + is_sufficiant_traded_goods: [records.is_sufficiant_traded_goods], + traded_goods_remarks:[records.traded_goods_remarks] + }) + } + } + + /** Manufacturing -> To Add More Raw Material Details */ + addRawMaterials(flag) { + if(flag==1){ + const control = this.stockForm.controls['manufacturing_details']['controls'][0].controls['manufacturing_raw_materials']; + control.push(this.createRawmaterial(null)); + } + } + + /** Manufacturing -> To Remove Raw Material Details */ + deleteRawMaterials(index,flag) { + if(flag==1){ + const control = this.stockForm.controls['manufacturing_details']['controls'][0].controls['manufacturing_raw_materials']; + control.removeAt(index); + } + } + + /** Manufacturing -> To Add More Finished Goods */ + addGoods(flag) { + if(flag == 1){ + const control = this.stockForm.controls['manufacturing_details']['controls'][0].controls['manufacturing_finished_goods']; + control.push(this.createGoods(null)); + } + } + + /** Manufacturing -> To Remove Finished Goods */ + deleteGoods(index,flag) { + if(flag == 1){ + const control = this.stockForm.controls['manufacturing_details']['controls'][0].controls['manufacturing_finished_goods']; + control.removeAt(index); + } + } + + /** + * Case 1 Retail Traded -> To Add More trade Goods + * Case 2 wholesale Traded -> To Add More trade Goods + */ + addTradedGoods(flag) { + switch(flag){ + + case 1: { + const control = this.stockForm.controls['retail_details']['controls'][0].controls['retail_traded_goods']; + control.push(this.createTradedGoods(null)); + break; + } + case 2: { + const control = this.stockForm.controls['trade_details']['controls'][0].controls['trading_traded_goods']; + control.push(this.createTradedGoods(null)); + break; + } + default: { + break; + } + } + } + + /** + * Case 1 Retail Traded -> To remove trade Goods + * Case 2 wholesale Traded -> To remove trade Goods + */ + deleteTradedGoods(index,flag) { + switch(flag){ + case 1: { + const control = this.stockForm.controls['retail_details']['controls'][0].controls['retail_traded_goods']; + control.removeAt(index); + break; + } + case 2: { + const control = this.stockForm.controls['trade_details']['controls'][0].controls['trading_traded_goods']; + control.removeAt(index); + break; + } + default: { + break; + } + } + + //const control = this.stockForm.controls['traded_goods']; + + } + + checkComments(e,flag,index){ + + if(flag == 1 && e=='no'){ + this.mrmCommentFlag[index] = true; + } + else if(flag == 1 && e!='no'){ + this.mrmCommentFlag[index] = false; + } + if(flag == 2 && e=='no'){ + this.mfgCommentFlag[index] = true; + } + else if(flag == 2 && e!='no'){ + this.mfgCommentFlag[index] = false; + } + if(flag == 3 && e=='no'){ + this.rtrdCommentFlag[index] = true; + } + else if(flag == 3 && e!='no'){ + this.rtrdCommentFlag[index] = false; + } + if(flag == 4 && e=='no'){ + this.wtrdCommentFlag[index] = true; + } + else if(flag == 4 && e!='no'){ + this.wtrdCommentFlag[index] = false; + } + } + + /** To Save/Edited Popup Data */ + saveStockInfo(answerFormValues) { + + //To Remove The "Null" With Key also + Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]); + + this.qustCat.saveForm(answerFormValues).subscribe(responsed => { + if(responsed['status'] == 200) { + this.navCtrl.pop(); + this.toast.pdTriggerappmessage('Record Saved Successfully.!'); + }else{ + this.toast.pdTriggerappmessage('Something Wents Wrong Try Again.!'); + } + }); + } + + inWords(e,flag:number,i){ + + switch(flag){ + case 1 : + this.M_rawValueInWords[i] = this.constant.convertNumberToWords(e); + break; + case 2 : + this.M_goodsValueInWords[i] = this.constant.convertNumberToWords(e); + break; + case 3 : + this.R_tradedGoodsValueInWords[i] = this.constant.convertNumberToWords(e); + break; + case 4 : + this.T_tradedGoodsValueInWords[i] = this.constant.convertNumberToWords(e); + break; + default: + break; + } +} + + // createRawmaterial() { + // return this.fb.group({ + // raw_name: [''], + // stock_observed:[''], + // raw_quantity: [''], + // raw_uom: [''], + // other_uom : [''], + // raw_value: [''], + // rawmaterial_value: [''], + // is_sufficiant_raw: [''], + // }); + // } + // createGoods() { + // return this.fb.group({ + // goods_name: [''], + // goods_quantity: [''], + // goods_value: [''], + // finished_goods_value: [''], + // is_sufficiant_goods: [''], + // }); + // } + // addRawMaterials() { + // const control = this.stockForm.controls['raw_materials']; + // control.push(this.createRawmaterial()); + // } + // deleteRawMaterials(index) { + // const control = this.stockForm.controls['raw_materials']; + // if(control.length==1) + // { + // this.stockForm.controls['raw_materials'].reset(); + // }else{ + // control.removeAt(index); + // } + // } + // addGoods() { + // const control = this.stockForm.controls['finished_goods']; + + // control.push(this.createGoods()); + // } + // deleteGoods(index) { + // const control = this.stockForm.controls['finished_goods']; + // if(control.length==1) + // { + // this.stockForm.controls['finished_goods'].reset(); + // }else{ + // control.removeAt(index); + // } + // } + + + // submitDetails(answerData) { + + // let records: any = {}; + // records.pdid = this.pdDetails.pd_id; + // records.formid = this.FormId.form_id; + // records.fk_createdby = this.users; + // records.raw_materials = answerData.raw_materials; + // records.stock_remarks = answerData.stock_remarks; + // records.finished_goods = answerData.finished_goods; + + // this.qustCat.saveForm(records).subscribe(data => { + // this.navCtrl.pop(); + // this.toast.pdTriggerappmessage('Record Saved Successfully.!'); + // }); + // } + + // getStockDetails() { + // let records = { 'pd_id': this.pdDetails.pd_id, 'pd_FormId': this.FormId.form_id }; + + // this.qustCat.retiverForm(records).subscribe(value => { + + // const rawMaterial = this.stockForm.controls['raw_materials']; + // const finishedGoods = this.stockForm.controls['finished_goods']; + // if (value['dataStatus'] == true) { + // let stockDetails = value['records']; + // let result = Object.keys(stockDetails.raw_materials).map(function (key) { + // return stockDetails.raw_materials[key]; + // }); + // let result_Goods = Object.keys(stockDetails.finished_goods).map(function (key) { + // return stockDetails.finished_goods[key]; + // }); + // this.stockForm.controls['stock_remarks'].setValue(stockDetails.stock_remarks); + // if (result.length > 0) { + // result.forEach(val => { + // rawMaterial.push(this.createRawmaterial()); + // }); + // this.stockForm.controls['raw_materials'].setValue(result); + // } else { + // rawMaterial.push(this.createRawmaterial()); + // } + // if (result_Goods.length > 0) { + // result_Goods.forEach(val => { + // finishedGoods.push(this.createGoods()); + // }); + // this.stockForm.controls['finished_goods'].setValue(result_Goods); + // } else { + // finishedGoods.push(this.createGoods()); + // } + // } else { + // this.addRawMaterials(); + // this.addGoods(); + // } + // }) + // } +} diff --git a/src/pages/pd-question/pd-question-business-group/pd-question-supplier-info/pd-question-supplier-info.html b/src/pages/pd-question/pd-question-business-group/pd-question-supplier-info/pd-question-supplier-info.html new file mode 100755 index 00000000..f72792aa --- /dev/null +++ b/src/pages/pd-question/pd-question-business-group/pd-question-supplier-info/pd-question-supplier-info.html @@ -0,0 +1,278 @@ + + + + + {{formDetails.form_name}} + + + + + + +
+ + + + Manufacturing Product Details +
+
+
+
+ + Raw Material #{{l+1}} + + +
+ + + + + + + + + + + + {{tl.name}} + + + + + + + + + + Select + + {{comrelShip.name}} + + + + + + + + + + + + Enter Valid Mobile Number. + + + + + Enter Valid STD Code Number. + + + + + Enter Valid LandLine Number. + + + + + + {{ pm.name }} + + + + + + Payment made in Cash. + Payment made through Banking + channels. + + + + + No.of days of Credit Provided by Supplier + + + + + + + + +
+ +
+ + + + + + + + +
+ + + +
+
+ + + + + +
+ + + +
+ + +
+
+ +
+ + + Trading Product Details + +
+
+
+
+ + Trading Product #{{l+1}} + + + +
+ + + {{ tp.name }} + + + + + + + + + {{tl.name}} + + + + + + + + + Select + + {{comrelShip.name}} + + + + + + + + + + Enter Valid Mobile Number. + + + + + Enter Valid STD Code Number. + + + + + Enter Valid LandLine Number. + + + + {{ pm.name }} + + + + + Payment received in Cash. + Payment received through Banking + channels. + + + + + + No.of days of Credit Provided by Supplier + + + + + + + +
+
+ + + + + + + + +
+
+
+ + + + +
+ + + +
+ + + +
+
+
+ + + Service Provider Product Details +
Service Provider Details Not applicable here !!
+
+ + + + Remarks + + + + + + + + +
+ +
+ + +
{{ errorMessage }}
+
\ No newline at end of file diff --git a/src/pages/pd-question/pd-question-business-group/pd-question-supplier-info/pd-question-supplier-info.scss b/src/pages/pd-question/pd-question-business-group/pd-question-supplier-info/pd-question-supplier-info.scss new file mode 100755 index 00000000..42ac55c9 --- /dev/null +++ b/src/pages/pd-question/pd-question-business-group/pd-question-supplier-info/pd-question-supplier-info.scss @@ -0,0 +1,13 @@ +page-pd-question-supplier-info { + mat-hint{ + font-size:12px; + } + .mat-card{ + margin-bottom: 15px; + border-radius: 10px !important; + box-shadow: 0 16px 38px -12px rgba(0, 0, 0, 0.56), 0 4px 25px 0 rgba(0, 0, 0, 0.12), 0 8px 10px -5px rgba(0, 0, 0, 0.2) !important; + } + .mat-card-content{ + margin-bottom: 0px !important; + } +} diff --git a/src/pages/pd-question/pd-question-business-group/pd-question-supplier-info/pd-question-supplier-info.ts b/src/pages/pd-question/pd-question-business-group/pd-question-supplier-info/pd-question-supplier-info.ts new file mode 100755 index 00000000..50330b2b --- /dev/null +++ b/src/pages/pd-question/pd-question-business-group/pd-question-supplier-info/pd-question-supplier-info.ts @@ -0,0 +1,475 @@ +import { Component } from '@angular/core'; +import { IonicPage, NavController, NavParams } from 'ionic-angular'; +import { FormBuilder, FormGroup, FormArray } from '@angular/forms'; +import { AwsServiceProvider } from '../../../../providers/aws-service/aws-service'; +import { QuestionCategoryProvider } from '../../../../providers/question-category/question-category'; +import { ToastProvider } from '../../../../providers/common-provider/toast'; + +/** + * Generated class for the PdQuestionSupplierInfoPage page. + * + * See https://ionicframework.com/docs/components/#navigation for more info on + * Ionic pages and navigation. + */ + + +@Component({ + selector: 'page-pd-question-supplier-info', + templateUrl: 'pd-question-supplier-info.html', +}) + +export class PdQuestionSupplierInfoPage { + users: any; + pdDetails: any; + formDetails:any; + company_id:any; + form_id:any; + questionDetails: any; + supplierInfoForm: FormGroup; + + business_manufacturingProducts : any = []; + business_tradingProducts : any = []; + m_titleList: any = []; + m_paymentList: any = []; + m_companyRelationShipList : any = []; + + noRecordsFound: Boolean = false; + public submitted = false; + errorMessage: any = ''; + + constructor(public navCtrl: NavController, public navParams: NavParams,public fb:FormBuilder,public aws:AwsServiceProvider,public qustCat:QuestionCategoryProvider,public toast:ToastProvider) { + + this.questionDetails = this.navParams.get('questionDetails'); + this.pdDetails = this.navParams.get('pdDetails'); + this.formDetails=this.navParams.get('formDetails'); + this.form_id = this.formDetails.form_id; + // console.log(this.formDetails); + this.company_id=this.pdDetails.company_id; + this.users = this.aws.getlocale(); + + + this.qustCat.getTypeofActivityForSuppliedInfoForm(this.pdDetails.pd_id, this.company_id).subscribe(data => { + + if(data.dataStatus){ + + let datas = data.records; + this.initFormLoadDetails(datas.type_of_activity); + this.business_manufacturingProducts = datas.type_of_activity.filter(data=>{if(data.type_of_activity_id == 2 ){return data}}).map(data=> [...data.prodcuts]); + // this.business_tradingProducts = datas.type_of_activity.filter(data=>{if(data.type_of_activity_id == 3){return data}}).map(data=> [...data.prodcuts]); + + let api = Object.keys(datas.type_of_activity).map(function (key) { + return datas.type_of_activity[key]; + }); + + if(api.length > 0){ + api.forEach(val => { + if (val.type_of_activity_id == 3) { + if(val.prodcuts){ + this.business_tradingProducts.push(val.prodcuts); + } + } + + if (val.type_of_activity_id == 4) { + if(val.prodcuts){ + this.business_tradingProducts.push(val.prodcuts); + } + } + }); + } + + this.business_tradingProducts = [].concat.apply([], this.business_tradingProducts); + + }else { + this.toast.pdTriggerappmessage('No Category Records Found.!'); + this.noRecordsFound = false; + this.errorMessage = data.msg; + } + }, err => { + this.toast.pdTriggerappmessage('No Category Records Found.!'); + this.noRecordsFound = false; + this.errorMessage = 'No Records Found , Something went Wrong!'; + }) + this.getdropList(); + } + + + ionViewDidLoad() { + console.log('ionViewDidLoad PdQuestionSupplierInfoPage'); + } + + + serviceProviderForm: Boolean = false; + initFormLoadDetails(record) { + let params: any = {}; + params.pd_id = this.pdDetails.pd_id; + params.pd_form_id = this.form_id; + params.company_id = this.company_id; + + this.qustCat.retiverForm(params).subscribe( + data => { + if(data['dataStatus'] == true){ + let dataForm = data['records']; + if(dataForm !== undefined) { + this.supplierInfoForm = this.fb.group({ + pdid: [this.pdDetails.pd_id], + formid: [this.form_id], + company_id: [this.company_id], + fk_createdby:[this.users], + manufacturing_details: this.fb.array([this.manufacturingFormCreation(record)]), + trade_details: this.fb.array([this.tradingFormCreation(record)]), + supplier_info_form_remark: [dataForm.supplier_info_form_remark || null] + // wholesale_trade_details: this.fb.array([this.tradingFormCreation(record)]), + }); + let arr = record.filter(data => data.type_of_activity_id == 2); + if(arr.length > 0) { + // let api_main_raw_materials = Object.keys(dataForm.main_raw_materials).map(function (key) { + // return dataForm.main_raw_materials[key]; + // }); + let api_main_raw_materials = dataForm.manufacturing_details[0].main_raw_materials; + + this.initManufacturingProductsDetails(api_main_raw_materials); + this.supplierInfoForm.controls['manufacturing_details']['controls'][0].controls['main_raw_materials_total_payments_percent_on_credit'].setValue(dataForm.manufacturing_details[0].main_raw_materials_total_payments_percent_on_credit || null); + } + let arr1 = record.filter(data => data.type_of_activity_id == 3 || data.type_of_activity_id ==4); + if(arr1.length > 0) { + // let api_trading_products = Object.keys(dataForm.trading_products).map(function (key) { + // return dataForm.trading_products[key]; + // }); + let api_trading_products = dataForm.trade_details[0].trading_products; + this.initTradingProductsDetails(api_trading_products); + this.supplierInfoForm.controls['trade_details']['controls'][0].controls['trading_products_total_payments_percent_on_credit'].setValue(dataForm.trade_details[0].trading_products_total_payments_percent_on_credit || null); + } + this.noRecordsFound = true; + } else { + this.supplierInfoForm = this.fb.group({ + pdid: [this.pdDetails.pd_id], + formid: [this.form_id], + company_id: [this.company_id], + fk_createdby:[this.users], + manufacturing_details: this.fb.array([this.manufacturingFormCreation(record)]), + trade_details: this.fb.array([this.tradingFormCreation(record)]), + supplier_info_form_remark: [dataForm.supplier_info_form_remark || null] + // wholesale_trade_details: this.fb.array([this.tradingFormCreation(record)]), + }); + let arr = record.filter(data => data.type_of_activity_id == 2); + if(arr.length > 0) { + this.initManufacturingProductsDetails(null); + this.supplierInfoForm.controls['manufacturing_details']['controls'][0].controls['main_raw_materials_total_payments_percent_on_credit'].setValue(null); + } + let arr1 = record.filter(data => data.type_of_activity_id == 3 || data.type_of_activity_id == 4); + if(arr1.length > 0) { + this.initTradingProductsDetails(null); + this.supplierInfoForm.controls['trade_details']['controls'][0].controls['trading_products_total_payments_percent_on_credit'].setValue(dataForm.trading_products_total_payments_percent_on_credit || null); + } + this.noRecordsFound = true; + } + let arr2 = record.filter(data => data.type_of_activity_id == 5); + if(arr2.length > 0) { + this.serviceProviderForm = true; + } + } else { + this.supplierInfoForm = this.fb.group({ + pdid: [this.pdDetails.pd_id], + formid: [this.form_id], + company_id: [this.company_id], + fk_createdby:[this.users], + manufacturing_details: this.fb.array([this.manufacturingFormCreation(record)]), + trade_details: this.fb.array([this.tradingFormCreation(record)]), + supplier_info_form_remark: [] + // wholesale_trade_details: this.fb.array([this.tradingFormCreation(record)]), + }); + let arr = record.filter(data => data.type_of_activity_id == 2); + if(arr.length > 0) { + this.initManufacturingProductsDetails(null); + this.supplierInfoForm.controls['manufacturing_details']['controls'][0].controls['main_raw_materials_total_payments_percent_on_credit'].setValue(null); + } + let arr1 = record.filter(data => data.type_of_activity_id == 3 || data.type_of_activity_id== 4); + if(arr1.length > 0) { + this.initTradingProductsDetails(null); + this.supplierInfoForm.controls['trade_details']['controls'][0].controls['trading_products_total_payments_percent_on_credit'].setValue(null); + } + let arr2 = record.filter(data => data.type_of_activity_id == 5); + if(arr2.length > 0) { + this.serviceProviderForm = true; + } + this.noRecordsFound = true; + } + }, err => { + + } + ); + } + + manufacturingForm: Boolean = false; + manufacturingFormCreation(val) { + let arr = val.filter(data => data.type_of_activity_id == 2); + if (arr.length > 0) { + this.manufacturingForm = true; + return this.fb.group({ + main_raw_materials: this.fb.array([]), + main_raw_materials_total_payments_percent_on_credit: [] + }) + // } + } else { + return; + } + } + + tradingForm: Boolean = false; + tradingFormCreation(val) { + let arr = val.filter(data => data.type_of_activity_id == 3 || data.type_of_activity_id == 4); + if (arr.length > 0) { + this.tradingForm = true; + return this.fb.group({ + trading_products: this.fb.array([]), + trading_products_total_payments_percent_on_credit: [] + }); + } else { + return; + } + } + + initManufacturingProductsDetails(datas) { + const control = this.supplierInfoForm.controls['manufacturing_details']['controls'][0].controls['main_raw_materials']; + if(datas === null){ + control.push(this.initManufacturingProducts(null)); + } else { + datas.forEach((val,inx) => { + this.checkCard(val.manufacturing_payment_type,1,inx); + control.push(this.initManufacturingProducts(val)); + }); + } + } + + initManufacturingProducts(records) { + if(records === null) { + return this.fb.group({ + manufacturing_raw_material_name: [''], + manufacturing_supplier_name: [''], + person_title_name:[''], + person_designation:[''], + other_person_designation:[''], + manufacturing_contact_person_name: [''], + manufacturing_contact_person_mobile_number: [''], + //,Validators.compose([Validators.minLength(10),Validators.maxLength(10)]) + manufacturing_payment_type: [''], + manufacturing_payment_mode:[''], + manufacturing_credit_days_from: [''], + manufacturing_credit_days_to:[''], + manufacturing_frequency_of_purchase: [''], + person_stdcode:[''], + //, Validators.compose([Validators.minLength(3),Validators.maxLength(5),Validators.pattern('^[0-9]*$')]) + person_landline:[''], + //, Validators.compose([Validators.minLength(6),Validators.maxLength(8),Validators.pattern('^[0-9]*$')]) + + }) + } else { + return this.fb.group({ + manufacturing_raw_material_name: [records.manufacturing_raw_material_name || null], + manufacturing_supplier_name: [records.manufacturing_supplier_name || null], + person_title_name:[records.person_title_name || null], + person_designation:[records.person_designation || null], + other_person_designation:[records.other_person_designation || null], + manufacturing_contact_person_name: [records.manufacturing_contact_person_name || null], + manufacturing_contact_person_mobile_number: [records.manufacturing_contact_person_mobile_number || null], + //Validators.compose([Validators.minLength(10),Validators.maxLength(10)])], + manufacturing_payment_type: [records.manufacturing_payment_type || null], + manufacturing_payment_mode:[records.manufacturing_payment_mode], + manufacturing_credit_days_from: [records.manufacturing_credit_days_from || null], + manufacturing_credit_days_to:[records.manufacturing_credit_days_to || null], + manufacturing_frequency_of_purchase: [records.manufacturing_frequency_of_purchase || null], + person_stdcode:[records.person_stdcode || null], + //, Validators.compose([Validators.minLength(3),Validators.maxLength(5),Validators.pattern('^[0-9]*$')]) + person_landline:[records.person_landline || null], + //, Validators.compose([Validators.minLength(6),Validators.maxLength(8),Validators.pattern('^[0-9]*$')]) + }) + } + } + + initTradingProductsDetails(datas) { + const control = this.supplierInfoForm.controls['trade_details']['controls'][0].controls['trading_products']; + + if(datas === null){ + control.push(this.initTradingProducts(null)); + } else { + datas.forEach((val,inx) => { + this.checkCard(val.trade_product_payment_type,2,inx); + control.push(this.initTradingProducts(val)); + }); + } + } + + initTradingProducts(records) { + if(records === null) { + return this.fb.group({ + trade_product_name: [''], + trade_supplier_name: [''], + person_title_name:[''], + person_designation:[''], + other_person_designation:[''], + trade_product_contact_person_name: [''], + trade_product_contact_person_mobile_number: [''], + //,Validators.compose([Validators.minLength(10),Validators.maxLength(10)]) + person_stdcode:[null], + //, Validators.compose([Validators.minLength(3),Validators.maxLength(5),Validators.pattern('^[0-9]*$')]) + person_landline:[null], + //, Validators.compose([Validators.minLength(6),Validators.maxLength(8),Validators.pattern('^[0-9]*$')]) + trade_product_payment_type: [''], + trade_product_payment_mode: [''], + trade_product_frequency_of_purchase: [''], + trade_product_credit_days_from: [''], + trade_product_credit_days_to: [''], + }) + } else { + return this.fb.group({ + trade_product_name: [records.trade_product_name], + person_title_name:[records.person_title_name], + person_designation:[records.person_designation], + other_person_designation:[records.other_person_designation], + trade_supplier_name: [records.trade_supplier_name], + trade_product_contact_person_name: [records.trade_product_contact_person_name], + trade_product_contact_person_mobile_number: [records.trade_product_contact_person_mobile_number], + //, Validators.compose([Validators.minLength(10),Validators.maxLength(10)]) + person_stdcode:[records.person_stdcode], + //, Validators.compose([Validators.minLength(3),Validators.maxLength(5),Validators.pattern('^[0-9]*$')]) + person_landline:[records.person_landline], + //, Validators.compose([Validators.minLength(6),Validators.maxLength(8),Validators.pattern('^[0-9]*$')]) + trade_product_payment_type: [records.trade_product_payment_type], + trade_product_payment_mode: [records.trade_product_payment_mode], + trade_product_frequency_of_purchase: [records.trade_product_frequency_of_purchase], + trade_product_credit_days_from: [records.trade_product_credit_days_from], + trade_product_credit_days_to: [records.trade_product_credit_days_to], + }) + } + } + + addMoreRawMaterials(e): void { + // e.stropPropagation(); + const control = this.supplierInfoForm.controls['manufacturing_details']['controls'][0].controls['main_raw_materials']; + + control.push(this.initManufacturingProducts(null)); + } + + removeRawMaterials(inx): void { + const control = this.supplierInfoForm.controls['manufacturing_details']['controls'][0].controls['main_raw_materials']; + control.removeAt(inx); + } + + addMoretradeProduct(e): void { + // e.stropPropagation(); + const control = this.supplierInfoForm.controls['trade_details']['controls'][0].controls['trading_products']; + + control.push(this.initTradingProducts(null)); + } + + removeTradingProduct(inx): void { + const control = this.supplierInfoForm.controls['trade_details']['controls'][0].controls['trading_products']; + control.removeAt(inx); + } + + + getdropList(){ + + this.qustCat.getcommondrop('COMPANYRELATIONSHIPS').subscribe( + data => { + this.m_companyRelationShipList = data['records'].filter(data => data.isactive == 1); + }); + + this.qustCat.getcommondrop('TITLES').subscribe( + data => { + this.m_titleList = data['records'].filter(data => data.isactive == 1); + }); + + this.qustCat.getcommondrop('PAYMENTMODE').subscribe( + data => { + this.m_paymentList = data['records'].filter(data => data.isactive == 1); + }); + } + + +saveSupplierInfo(FormValues) { + + var answerFormValues = FormValues; + + Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]); + + this.qustCat.saveForm(answerFormValues).subscribe(responsed => { + if(responsed['status'] == 200) { + this.navCtrl.pop(); + this.toast.pdTriggerappmessage('Record Saved Successfully.!'); + }else{ + this.toast.pdTriggerappmessage('Something Wents Wrong Try Again.!'); + } + }); + +} + +selectedPersonDesignation(items,e,flag){ + if(flag == 1){ + e==1 ? '' : '' ; + // e==1 ? items.controls['other_person_designation'].setValidators([Validators.required]) + // : items.controls['other_person_designation'].clearValidators(),items.controls['other_person_designation'].setValue(''); + // items.controls['other_person_designation'].updateValueAndValidity(); + } + else if(flag == 2){ + e==1 ? '' : '' ; + // e==1 ?items.controls['other_person_designation'].setValidators([Validators.required]) + // :items.controls['other_person_designation'].clearValidators(),items.controls['other_person_designation'].setValue(''); + // items.controls['other_person_designation'].updateValueAndValidity(); + } +} + +mfgCreditCardFlag : boolean = false; +trdCreditCardFlag : boolean = false; +mfgCounter: any = []; +trdCounter: any = []; +checkCard(e,flag,index){ + if(flag == 2 && e==3){ + this.trdCounter[index] = 1; + } + else if(flag == 2 && e!=3){ + this.trdCounter[index] = 0; + } + let TRD = this.trdCounter.reduce((sum, val) => sum + +val, 0); + this.trdCreditCardFlag = TRD > 0 ? true : false ; + + if(flag == 1 && e==3){ + this.mfgCounter[index] = 1; + } + else if(flag == 1 && e!=3){ + this.mfgCounter[index] = 0; + } + let MFG = this.mfgCounter.reduce((sum, val) => sum + +val, 0); + this.mfgCreditCardFlag = MFG > 0 ? true : false ; +} + +selectedPaymentTerms(items,e,flag){ + if(flag == 2){ + if(e==3){ + // items.controls['trade_product_credit_days_from'].setValidators([Validators.required]); + // items.controls['trade_product_credit_days_to'].setValidators([Validators.required]); + } + else{ + items.controls['trade_product_credit_days_from'].clearValidators(); + items.controls['trade_product_credit_days_from'].setValue(''); + items.controls['trade_product_credit_days_to'].clearValidators(); + items.controls['trade_product_credit_days_to'].setValue(''); + } + items.controls['trade_product_credit_days_from'].updateValueAndValidity(); + items.controls['trade_product_credit_days_to'].updateValueAndValidity(); + } + else if(flag == 1){ + if(e==3){ //items.controls['manufacturing_credit_days_from'].setValidators([Validators.required]); + //items.controls['manufacturing_credit_days_to'].setValidators([Validators.required]); + } + else{ + items.controls['manufacturing_credit_days_from'].clearValidators(); + items.controls['manufacturing_credit_days_from'].setValue(''); + items.controls['manufacturing_credit_days_to'].clearValidators(); + items.controls['manufacturing_credit_days_to'].setValue(''); + } + items.controls['manufacturing_credit_days_from'].updateValueAndValidity(); + items.controls['manufacturing_credit_days_to'].updateValueAndValidity(); + } +} +} \ No newline at end of file diff --git a/src/pages/pd-question/pd-question-client-info/pd-question-client-info.html b/src/pages/pd-question/pd-question-client-info/pd-question-client-info.html deleted file mode 100644 index 598cd4da..00000000 --- a/src/pages/pd-question/pd-question-client-info/pd-question-client-info.html +++ /dev/null @@ -1,105 +0,0 @@ - - - - - {{FormId.form_name}} - - - - - - -
- -
- -
- -
-
-
- - - - -
-
- - - - -
-
- - - - -
-
-
-
- - - {{ pm.name }} - - -
-
- - - - -
-
- - - - -
-
-
-
- - - {{ feq.name }} - - -
-
- - - - -
- -
- -
-
-
- - - - - - - - - - -
-
-
-
- - - - - - -
-
diff --git a/src/pages/pd-question/pd-question-client-info/pd-question-client-info.scss b/src/pages/pd-question/pd-question-client-info/pd-question-client-info.scss deleted file mode 100644 index ed2d0d66..00000000 --- a/src/pages/pd-question/pd-question-client-info/pd-question-client-info.scss +++ /dev/null @@ -1,3 +0,0 @@ -page-pd-question-client-info { - -} diff --git a/src/pages/pd-question/pd-question-client-info/pd-question-client-info.ts b/src/pages/pd-question/pd-question-client-info/pd-question-client-info.ts deleted file mode 100644 index 04790e72..00000000 --- a/src/pages/pd-question/pd-question-client-info/pd-question-client-info.ts +++ /dev/null @@ -1,166 +0,0 @@ -import { Component } from '@angular/core'; -import { IonicPage, NavController, NavParams } from 'ionic-angular'; -import { QuestionCategoryProvider } from '../../../providers/question-category/question-category'; -import { AwsServiceProvider } from '../../../providers/aws-service/aws-service'; -import { ToastProvider } from '../../../providers/common-provider/toast'; -import { FormGroup, FormBuilder, FormArray } from '@angular/forms'; - -/** - * Generated class for the PdQuestionClientInfoPage page. - * - * See https://ionicframework.com/docs/components/#navigation for more info on - * Ionic pages and navigation. - */ - - -@Component({ - selector: 'page-pd-question-client-info', - templateUrl: 'pd-question-client-info.html', -}) -export class PdQuestionClientInfoPage { - - users: any; - paymentModeTextBox: any; - m_paymentModeType: any; - m_freqOfPurchase: any; - FormId: any; - pdDetails: any; - clientForms:FormGroup; - clientDataArray:FormArray; - apiLoadFinish:boolean = false; - constructor(public navCtrl: NavController, public navParams: NavParams,public qustCat:QuestionCategoryProvider,public aws:AwsServiceProvider,public toast:ToastProvider,public fb:FormBuilder) { - this.pdDetails = this.navParams.get('pdDetails'); - this.FormId = this.navParams.get('FormId'); - this.users = this.aws.getlocale(); - this.clientForms = this.fb.group({ - clientArray:this.fb.array([]) - }); - this.getClientDetails(); - this.getdropdown(); - } - - ionViewDidLoad() { - console.log('ionViewDidLoad PdQuestionClientInfoPage'); - } - - createClientItem() - { - return this.fb.group( - { - client_name: [''], - contact_person: [''], - mobile_number: [''], - payment_mode: [''], - per_of_immediate_advance_payment:[''], - credit_period:[''], - frequency_of_purchase: [''], - freq_purchase_others_text_value: [''] - }) - } - selectedPM(e) { - this.paymentModeTextBox = e.value; - // this.f.supplier_details.controls.get('payment_mode_value'); - } - public freqPurchaseTextBox: number; - selectedFreqPurchase(e){ - this.freqPurchaseTextBox = e.value; - } - getdropdown() - { - this.qustCat.getcommondrop('FREQUENCY').subscribe( - data => { - this.m_freqOfPurchase = data['records'].filter(data => data.isactive == 1); - }, - error => { - // this.notifier.notify('warning', 'No Category Records Found.!'); - // this.m_assets_type = "No Category Records Found."; - } - ) - this.qustCat.getcommondrop('PAYMENTMODE').subscribe( - data => { - this.m_paymentModeType = data['records'].filter(data => data.isactive == 1); - }, - error => { - // this.notifier.notify('warning', 'No Category Records Found.!'); - // this.m_assets_type = "No Category Records Found."; - } - ) - } - addClientDetails() - { - this.clientDataArray = this.clientForms.get('clientArray') as FormArray; - this.clientDataArray.push(this.createClientItem()); - } - removeClientDetails(i) - { - - if(this.clientDataArray.length==1) - { - this.clientForms.controls['clientArray'].reset(); - }else{ - this.clientDataArray = this.clientForms.get('clientArray') as FormArray; - this.clientDataArray.removeAt(i); - } - } - - saveclientDetails(answerData) -{ - let records:any ={}; - - records.pdid = this.pdDetails.pd_id; - records.formid = this.FormId.form_id; - records.fk_createdby = this.users; - - records.client_details = answerData.clientArray; - console.log('data',records); - this.qustCat.saveForm(records).subscribe(res=> - { - if(res['dataStatus']==true) - { - this.toast.pdTriggerappmessage('Record Saved Successfully.!'); - this.navCtrl.pop(); - } - }); - - -} - getClientDetails() - { - let records = {'pd_id':this.pdDetails.pd_id,'pd_form_id':this.FormId.form_id} - let clientData:any = []; - this.qustCat.retiverForm(records).subscribe( - data => { - if(data['dataStatus']==true) - { - let clientDetails = data['records']; - console.log(clientDetails); - clientData = Object.keys(data['records'].client_details).map(function(key) { - - return clientDetails.client_details[key]; - }); - this.clientDataArray = this.clientForms.get('clientArray') as FormArray; - - if(clientData.length ==0) - { - - this.clientDataArray.push(this.createClientItem()); - }else - { - // console.log('else'); - clientData.forEach(datas=> - { - this.clientDataArray.push(this.createClientItem()); - }) - - this.clientForms.controls['clientArray'].setValue(clientData); - this.apiLoadFinish = true; - } - }else{ - - this.addClientDetails(); - this.apiLoadFinish = true; - } - } -); - } -} diff --git a/src/pages/pd-question/pd-question-stock-info/pd-question-stock-info.html b/src/pages/pd-question/pd-question-stock-info/pd-question-stock-info.html deleted file mode 100644 index 3c824573..00000000 --- a/src/pages/pd-question/pd-question-stock-info/pd-question-stock-info.html +++ /dev/null @@ -1,137 +0,0 @@ - - - - - {{FormId.form_name}} - - - - - - - - - - - -
- - - - -

Raw Materials

-
-
-
- - - - - - - Yes - No - - -
- - - - - - {{uom.name}} - - - - - - - - - - - - - - -
- - - - - - - - - - -
-
-
-
-
- - -

Finished Goods

-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
- -
-
- - Remarks - - -
-
-
- - - - - - -
- - -
diff --git a/src/pages/pd-question/pd-question-stock-info/pd-question-stock-info.scss b/src/pages/pd-question/pd-question-stock-info/pd-question-stock-info.scss deleted file mode 100644 index 8800716a..00000000 --- a/src/pages/pd-question/pd-question-stock-info/pd-question-stock-info.scss +++ /dev/null @@ -1,3 +0,0 @@ -page-pd-question-stock-info { - -} diff --git a/src/pages/pd-question/pd-question-stock-info/pd-question-stock-info.ts b/src/pages/pd-question/pd-question-stock-info/pd-question-stock-info.ts deleted file mode 100644 index 8dc30cb7..00000000 --- a/src/pages/pd-question/pd-question-stock-info/pd-question-stock-info.ts +++ /dev/null @@ -1,177 +0,0 @@ -import { Component } from '@angular/core'; -import { IonicPage, NavController, NavParams } from 'ionic-angular'; -import { QuestionCategoryProvider } from '../../../providers/question-category/question-category'; -import { AwsServiceProvider } from '../../../providers/aws-service/aws-service'; -import { ToastProvider } from '../../../providers/common-provider/toast'; -import { FormArray, FormGroup, FormBuilder } from '@angular/forms'; - -/** - * Generated class for the PdQuestionStockInfoPage page. - * - * See https://ionicframework.com/docs/components/#navigation for more info on - * Ionic pages and navigation. - */ - - -@Component({ - selector: 'page-pd-question-stock-info', - templateUrl: 'pd-question-stock-info.html', -}) -export class PdQuestionStockInfoPage { - - uomData: any; - rawmaterial: any; - users: any; - FormId: any; - pdDetails: any; - stockForm: FormGroup; - constructor(public navCtrl: NavController, public navParams: NavParams, public qustCat: QuestionCategoryProvider, public aws: AwsServiceProvider, public toast: ToastProvider, public fb: FormBuilder) { - this.pdDetails = this.navParams.get('pdDetails'); - this.FormId = this.navParams.get('FormId'); - this.users = this.aws.getlocale(); - this.stockForm = this.fb.group({ - stock_remarks: [''], - raw_materials: this.fb.array([]), - finished_goods: this.fb.array([]) - }); - this.getStockDetails(); - - this.qustCat.retiverForm({pd_id:this.pdDetails.pd_id,pd_form_id:'1'}).subscribe(value => { - // console.log('Raw material Name',value.records.main_raw_materials); - - - // const faControl = (this.stockForm.controls['raw_materials']).at(1); - - const control = (this.stockForm.controls['raw_materials']).at(0); - console.log(control); - - // this.stockForm.controls['raw_materials'].setValue(value.records.main_raw_materials); - if (value['dataStatus'] == true) { - this.rawmaterial = value['records'].main_raw_materials; - }else{ this.rawmaterial = ''; } - }) - this.getdropdown(); - } - - - ionViewDidLoad() { - console.log('ionViewDidLoad PdQuestionStockInfoPage'); - } - - - getdropdown() - { - this.qustCat.getcommondrop('UOM').subscribe(data => { - - if(data['dataStatus']==true){ - - this.uomData = data['records'].filter(uom=>uom.isactive==1); - - } - }); - } - createRawmaterial() { - return this.fb.group({ - raw_name: [''], - stock_observed:[''], - raw_quantity: [''], - raw_uom: [''], - other_uom : [''], - raw_value: [''], - rawmaterial_value: [''], - is_sufficiant_raw: [''], - }); - } - createGoods() { - return this.fb.group({ - goods_name: [''], - goods_quantity: [''], - goods_value: [''], - finished_goods_value: [''], - is_sufficiant_goods: [''], - }); - } - addRawMaterials() { - const control = this.stockForm.controls['raw_materials']; - control.push(this.createRawmaterial()); - } - deleteRawMaterials(index) { - const control = this.stockForm.controls['raw_materials']; - if(control.length==1) - { - this.stockForm.controls['raw_materials'].reset(); - }else{ - control.removeAt(index); - } - } - addGoods() { - const control = this.stockForm.controls['finished_goods']; - - control.push(this.createGoods()); - } - deleteGoods(index) { - const control = this.stockForm.controls['finished_goods']; - if(control.length==1) - { - this.stockForm.controls['finished_goods'].reset(); - }else{ - control.removeAt(index); - } - } - - - submitDetails(answerData) { - - let records: any = {}; - records.pdid = this.pdDetails.pd_id; - records.formid = this.FormId.form_id; - records.fk_createdby = this.users; - records.raw_materials = answerData.raw_materials; - records.stock_remarks = answerData.stock_remarks; - records.finished_goods = answerData.finished_goods; - console.log('data', records); - this.qustCat.saveForm(records).subscribe(data => { - this.navCtrl.pop(); - this.toast.pdTriggerappmessage('Record Saved Successfully.!'); - }); - } - - getStockDetails() { - let records = { 'pd_id': this.pdDetails.pd_id, 'pd_form_id': this.FormId.form_id }; - - this.qustCat.retiverForm(records).subscribe(value => { - console.log('value', value); - const rawMaterial = this.stockForm.controls['raw_materials']; - const finishedGoods = this.stockForm.controls['finished_goods']; - if (value['dataStatus'] == true) { - let stockDetails = value['records']; - let result = Object.keys(stockDetails.raw_materials).map(function (key) { - return stockDetails.raw_materials[key]; - }); - let result_Goods = Object.keys(stockDetails.finished_goods).map(function (key) { - return stockDetails.finished_goods[key]; - }); - this.stockForm.controls['stock_remarks'].setValue(stockDetails.stock_remarks); - if (result.length > 0) { - result.forEach(val => { - rawMaterial.push(this.createRawmaterial()); - }); - this.stockForm.controls['raw_materials'].setValue(result); - } else { - rawMaterial.push(this.createRawmaterial()); - } - if (result_Goods.length > 0) { - result_Goods.forEach(val => { - finishedGoods.push(this.createGoods()); - }); - this.stockForm.controls['finished_goods'].setValue(result_Goods); - } else { - finishedGoods.push(this.createGoods()); - } - } else { - this.addRawMaterials(); - this.addGoods(); - } - }) - } -} diff --git a/src/pages/pd-question/pd-question-supplier-info/pd-question-supplier-info.html b/src/pages/pd-question/pd-question-supplier-info/pd-question-supplier-info.html deleted file mode 100755 index 7c6e7435..00000000 --- a/src/pages/pd-question/pd-question-supplier-info/pd-question-supplier-info.html +++ /dev/null @@ -1,119 +0,0 @@ - - - - - Supplier Info Category - - - - - - - - - -

Supplier Details

-
-
-
- What are the main Raw materials?(MEG Only) - - - You must Include Raw Material Details. - -
-
-
-
- -
- - -
-
-
- - - - -
-
- - - - -
-
- - - - -
-
-
-
- - - {{ pm.name }} - - -
-
- % of immediate / Advance Payment Purchase to Total Purchase? - - - - -
-
- - - - -
-
-
-
- - - {{ feq.name }} - - -
-
- - - - -
- - - - - - - - - - - - -
-
- -
-
-
- -
-
- - - - - -
-
-
diff --git a/src/pages/pd-question/pd-question-supplier-info/pd-question-supplier-info.scss b/src/pages/pd-question/pd-question-supplier-info/pd-question-supplier-info.scss deleted file mode 100755 index f9743770..00000000 --- a/src/pages/pd-question/pd-question-supplier-info/pd-question-supplier-info.scss +++ /dev/null @@ -1,3 +0,0 @@ -page-pd-question-supplier-info { - -} diff --git a/src/pages/pd-question/pd-question-supplier-info/pd-question-supplier-info.ts b/src/pages/pd-question/pd-question-supplier-info/pd-question-supplier-info.ts deleted file mode 100755 index 5b8c90cb..00000000 --- a/src/pages/pd-question/pd-question-supplier-info/pd-question-supplier-info.ts +++ /dev/null @@ -1,194 +0,0 @@ -import { Component } from '@angular/core'; -import { IonicPage, NavController, NavParams } from 'ionic-angular'; -import { FormBuilder, FormGroup, FormArray } from '@angular/forms'; -import { AwsServiceProvider } from '../../../providers/aws-service/aws-service'; -import { QuestionCategoryProvider } from '../../../providers/question-category/question-category'; -import { PdQuestionCategoryPage } from '../../pd-question-category/pd-question-category'; -import { ToastProvider } from '../../../providers/common-provider/toast'; - -/** - * Generated class for the PdQuestionSupplierInfoPage page. - * - * See https://ionicframework.com/docs/components/#navigation for more info on - * Ionic pages and navigation. - */ - - -@Component({ - selector: 'page-pd-question-supplier-info', - templateUrl: 'pd-question-supplier-info.html', -}) -export class PdQuestionSupplierInfoPage { - users: any; - pdDetails: any; - questionDetails: any; - supplierInfoForm: FormGroup; - supplierDetails: any; - supplierArray:FormArray; - m_paymentModeType:any; - - m_freqOfPurchase:any; - constructor(public navCtrl: NavController, public navParams: NavParams,public fb:FormBuilder,public aws:AwsServiceProvider,public qustCat:QuestionCategoryProvider,public toast:ToastProvider) { - this.questionDetails = this.navParams.get('questionDetails'); - this.pdDetails = this.navParams.get('pdDetails'); - this.users = this.aws.getlocale(); - - this.supplierInfoForm = this.fb.group({ - - main_raw_materials: [null], - supplier_details: this.fb.array([]) - }); - this.getSupplierForm(); - - this.getdropList(); - } - - ionViewDidLoad() { - console.log('ionViewDidLoad PdQuestionSupplierInfoPage'); - } - - getdropList() - { - this.m_paymentModeType = [ - { - 'id': "1", - 'name': 'Immediate Or Advanced Payment' - }, - { - 'id': "2", - 'name': 'Credit' - }, - { - 'id': "3", - 'name': 'Combination of Both' - }, - ]; - this.m_freqOfPurchase = [ - { - 'id': "1", - 'name': 'Daily' - }, - { - 'id': "2", - 'name': 'Weekly' - }, - { - 'id': "3", - 'name': 'Monthly' - }, - { - 'id': "4", - 'name': 'Every 3 months' - }, - { - 'id': "5", - 'name': 'Half yearly' - }, - { - 'id': "6", - 'name': 'Yearly' - }, - { - 'id': "7", - 'name': 'As and when required' - }, - { - 'id': "8", - 'name': 'Others' - } - ]; - } - public paymentModeTextBox: number; - selectedPM(e) { - this.paymentModeTextBox = e.value; - // this.f.supplier_details.controls.get('payment_mode_value'); - } - - public freqPurchaseTextBox: number; - selectedFreqPurchase(e){ - this.freqPurchaseTextBox = e.value; - } - initDetails() { - return this.fb.group({ - supplier_name: [null], - contact_person: [null], - mobile_number: [null], - payment_mode: [null], - per_of_immediate_advance_payment:[null], - credit_period:[null], - frequency_of_purchase: [null], - freq_purchase_others_text_value: [null] - }); - } - - addSupplierDetails() { - this.supplierArray = this.supplierInfoForm.get('supplier_details') as FormArray; - // const control = ; - this.supplierArray.push(this.initDetails()); - } - - removeLanguage(i: number) { - this.supplierArray = this.supplierInfoForm.get('supplier_details') as FormArray; - - this.supplierArray.removeAt(i); - } - -saveSupplierInfo(answerData) -{ - let records:any ={}; - - records.pdid = this.pdDetails.pd_id; - records.formid = '338'; - records.fk_createdby = this.users; - records.main_raw_materials = answerData.main_raw_materials; - records.supplier_details = answerData.supplier_details; - console.log('data',records); - this.qustCat.saveForm(records).subscribe(res=> - { - if(res['dataStatus']==true) - { - this.toast.pdTriggerappmessage('Record Saved Successfully.!'); - this.navCtrl.pop(); - } - }); - - -} - -getSupplierForm() -{ - let records = {'pd_id':this.pdDetails.pd_id,'pd_form_id':'338'}; - - this.qustCat.retiverForm(records).subscribe(res=> - { - if(res['dataStatus']==true) - { - this.supplierDetails = res['records']; - var supplierArray = Object.keys(res['records'].supplier_details - ).map(function(key) { - //console.log(res); - return res['records'].supplier_details - [key]; - - }); - this.supplierArray = this.supplierInfoForm.get('supplier_details') as FormArray; - this.supplierInfoForm.controls['main_raw_materials'].setValue(this.supplierDetails.main_raw_materials); - if(supplierArray.length ==0) - { - - this.supplierArray.push(this.initDetails()); - }else - { - supplierArray.forEach(datas=> - { - this.supplierArray.push(this.initDetails()); - }) - } - this.supplierInfoForm.controls['supplier_details'].setValue(supplierArray); - }else{ - this.addSupplierDetails(); - } - }) - -} -} diff --git a/src/providers/question-category/question-category.ts b/src/providers/question-category/question-category.ts index 9e0a24ab..d5bf5ab0 100755 --- a/src/providers/question-category/question-category.ts +++ b/src/providers/question-category/question-category.ts @@ -94,10 +94,19 @@ getAssetsWithLoanFromBusiness(pdid:any){ } -getTypeofActivityForSuppliedInfoForm(pd_id: any){ - return this.http.post(this.apiurl+"getTypeOfActivetyFromBusinessForm", {"records": { "pd_id" : pd_id }}); +getTypeofActivityForSuppliedInfoForm(pd_id: any,company_id:any){ + return this.http.post(this.apiurl+"getTypeOfActivetyFromBusinessForm", {"records": { "pd_id" : pd_id,"company_id":company_id }}); } +/** For Stock Details + * To Get The Products With TypeofActivity From Business + **/ +stockFormAccess(pdid: any,companyid: any) { + // { "pd_id":"104","company_id":"1"} + return this.http.post(this.apiurl + "getProductsFromBusiness", {"pd_id" : pdid ,"company_id":companyid }); +} + + /*****Save Images */ savePDImages(imagesDetails)