import Controller from '@ember/controller'; import { inject as service } from '@ember/service'; export default Controller.extend({ accountManagement : service(), accountManagementData : service(), businessSegmentData : service(), subBusinessSegmentData : service(), idTypeData : service(), addressTypeData : service(), countryData : service(), villageData : service(), provinceData : service(), municipalityData : service(), subDistrictData : service(), accountAddressData : service(), contactResourceData : service(), accountContactData : service(), teamAccessData : service(), teamResourceData : service(), accountTeamData : service(), categoryUioData : service(), accountCustomerUioData : service(), vehicleManagementData : service(), accountVehicleData : service(), hoyuSalesOrderApprovalData : service(), accountUnitSalesOrderData : service(), session : service(), errors : service(), didValidate: false, rightActionInProgress: false, businessSegments: Array(), subBusinessSegments: Array(), idTypes: Array(), addressTypes: Array(), countries: Array(), villages: Array(), provinces: Array(), municipalities: Array(), subDistricts: Array(), contactResources: Array(), teamAccesss: Array(), teamResources: Array(), categoryUios: Array(), vehicleManagements: Array(), hoyuSalesOrderApprovals: Array(), formConfig : { sourceSystemNo : { isEditable : true }, partyNumber : { isEditable : true }, prefix : { isEditable : true }, suffix : { isEditable : true }, customerName : { isEditable : true }, tentativeCustomerId : { isEditable : true }, universalCustomerId : { isEditable : true }, businessSegment : { isEditable : true }, subBusinessSegment : { isEditable : true }, termOfPayment : { isEditable : true }, customerTypeDms : { isEditable : true }, customerTypeHms : { isEditable : true }, parentAccount : { isEditable : true }, salesClassification : { isEditable : true }, serviceClassification : { isEditable : true }, sparePartsClassification : { isEditable : true }, uioSales : { isEditable : true }, uioService : { isEditable : true }, lineOfBusiness : { isEditable : true }, load : { isEditable : true }, payload : { isEditable : true }, yearEstablishment : { isEditable : true }, registrationNumber : { isEditable : true }, whyBuyHino : { isEditable : true }, customerSize : { isEditable : true }, idType : { isEditable : true }, governmentIdNo : { isEditable : true }, taxInvoiceType : { isEditable : true }, vatTransactionCode : { isEditable : true }, reasonOfNotServiceInHino : { isEditable : true }, reasonOfNotServiceContractWithHino : { isEditable : true }, reasonOfNotBuyingHinoParts : { isEditable : true }, reasonOfNotSparepartContractWithHino : { isEditable : true }, correspondenceEqualTo : { isEditable : true }, billingEqualTo : { isEditable : true }, chiefMechanic : { isEditable : true }, mechanic : { isEditable : true }, noOfBay : { isEditable : true }, operationDistance : { isEditable : true }, warehouseHead : { isEditable : true }, partsman : { isEditable : true }, customerDmsId : { isEditable : true }, fixedCustomerId : { isEditable : true }, address : { isEditable : true }, kontakUtama : { isEditable : true }, contactPhone : { isEditable : true }, namaDealer : { isEditable : true }, branch : { isEditable : true }, accountAddress : { partyNumber : { isEditable : true }, isPrimary : { isEditable : true }, addressType : { isEditable : true }, country : { isEditable : true }, alamat1 : { isEditable : true }, alamat2 : { isEditable : true }, alamat3 : { isEditable : true }, village : { isEditable : true }, province : { isEditable : true }, municipality : { isEditable : true }, subDistrict : { isEditable : true }, kodePos : { isEditable : true }, governmentIdValue : { isEditable : true }, accountManagement : { isEditable : true }, }, accountContact : { partyId : { isEditable : true }, partyNumber : { isEditable : true }, accountPartyId : { isEditable : true }, accountManagement : { isEditable : true }, contactResource : { isEditable : true }, accountPartyNumber : { isEditable : true }, }, accountTeam : { teamAccess : { isEditable : true }, function : { isEditable : true }, accountManagement : { isEditable : true }, teamResource : { isEditable : true }, }, accountCustomerUio : { partyNumber : { isEditable : true }, hino : { isEditable : true }, mitsubishi : { isEditable : true }, isuzu : { isEditable : true }, ud : { isEditable : true }, toyota : { isEditable : true }, mercedesBenz : { isEditable : true }, others : { isEditable : true }, accountManagement : { isEditable : true }, categoryUio : { isEditable : true }, customerUioName : { isEditable : true }, }, accountVehicle : { accountManagement : { isEditable : true }, vehicleManagement : { isEditable : true }, }, accountUnitSalesOrder : { accountManagement : { isEditable : true }, hoyuSalesOrderApproval : { isEditable : true }, }, }, init() { this._super(...arguments); var businessSegments = this.businessSegmentData.getList(); this.set("businessSegments", businessSegments); var subBusinessSegments = this.subBusinessSegmentData.getList(); this.set("subBusinessSegments", subBusinessSegments); var idTypes = this.idTypeData.getList(); this.set("idTypes", idTypes); var addressTypes = this.addressTypeData.getList(); this.set("addressTypes", addressTypes); var countries = this.countryData.getList(); this.set("countries", countries); var villages = this.villageData.getList(); this.set("villages", villages); var provinces = this.provinceData.getList(); this.set("provinces", provinces); var municipalities = this.municipalityData.getList(); this.set("municipalities", municipalities); var subDistricts = this.subDistrictData.getList(); this.set("subDistricts", subDistricts); var contactResources = this.contactResourceData.getList(); this.set("contactResources", contactResources); var teamAccesss = this.teamAccessData.getList(); this.set("teamAccesss", teamAccesss); var teamResources = this.teamResourceData.getList(); this.set("teamResources", teamResources); var categoryUios = this.categoryUioData.getList(); this.set("categoryUios", categoryUios); var vehicleManagements = this.vehicleManagementData.getList(); this.set("vehicleManagements", vehicleManagements); var hoyuSalesOrderApprovals = this.hoyuSalesOrderApprovalData.getList(); this.set("hoyuSalesOrderApprovals", hoyuSalesOrderApprovals); }, actions: { onChangeCombo(propertyName, itemCollection) { this.set(propertyName, itemCollection); }, async saveAccountManagement() { this.set("rightActionInProgress", true); this.get('model') .validate() .then(async ({ validations }) => { this.set('didValidate', true); if (validations.get('isValid')) { this.set('accountManagement.model.isApprovalData', false); this.accountManagementData.save(this.accountManagement.model).then(response => { if (response != undefined) { this.transitionToRoute('account-management.detail', response.id); } }) .catch((e) => { this.set("rightActionInProgress", false); this.set('errorMessages', this.errors.getErrorMessages(e)); }); } else { this.set("rightActionInProgress", false); } }); }, addRowData(modal_type) { if (modal_type == "account-address") { let data = this.accountAddressData.createRecord(); this.accountManagement.addRow(data, "accountAddress"); } if (modal_type == "account-contact") { let data = this.accountContactData.createRecord(); this.accountManagement.addRow(data, "accountContact"); } if (modal_type == "account-team") { let data = this.accountTeamData.createRecord(); this.accountManagement.addRow(data, "accountTeam"); } if (modal_type == "account-customer-uio") { let data = this.accountCustomerUioData.createRecord(); this.accountManagement.addRow(data, "accountCustomerUio"); } if (modal_type == "account-vehicle") { let data = this.accountVehicleData.createRecord(); this.accountManagement.addRow(data, "accountVehicle"); } if (modal_type == "account-unit-sales-order") { let data = this.accountUnitSalesOrderData.createRecord(); this.accountManagement.addRow(data, "accountUnitSalesOrder"); } }, deleteRowData(modal_type, data) { if (modal_type == "account-address") { this.accountManagement.deleteRow(data, "accountAddress"); } if (modal_type == "account-contact") { this.accountManagement.deleteRow(data, "accountContact"); } if (modal_type == "account-team") { this.accountManagement.deleteRow(data, "accountTeam"); } if (modal_type == "account-customer-uio") { this.accountManagement.deleteRow(data, "accountCustomerUio"); } if (modal_type == "account-vehicle") { this.accountManagement.deleteRow(data, "accountVehicle"); } if (modal_type == "account-unit-sales-order") { this.accountManagement.deleteRow(data, "accountUnitSalesOrder"); } }, }, });