/* ************************************************************************* * The contents of this file are subject to the Openbravo Public License * Version 1.1 (the "License"), being the Mozilla Public License * Version 1.1 with a permitted attribution clause; you may not use this * file except in compliance with the License. You may obtain a copy of * the License at http://www.openbravo.com/legal/license.html * Software distributed under the License is distribfuted on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * The Original Code is Openbravo ERP. * The Initial Developer of the Original Code is Openbravo SLU * All portions are Copyright (C) 2010-2013 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ */ isc.ClassFactory.defineClass('OBMyCustomView', isc.VLayout); isc.OBMyCustomView.addProperties({ initWidget: function (properties) { this.buildStructure(); this.Super('initWidget', arguments); }, buildStructure: function () { var length, i, fld; this.createMainParts(); this.dataSource.view = this; this.viewGrid.fetchData(this.viewGrid.getCriteria()); }, // ** {{{ createMainParts }}} ** // Creates the main layout components of this view. createMainParts: function () { var me = this, completeFieldsWithoutImages, fieldsWithoutImages; if (this.tabId && this.tabId.length > 0) { this.formGridLayout = isc.HLayout.create({ canFocus: true, width: '100%', height: '100%', overflow: 'visible', view: this }); this.viewGrid.setDataSource(this.dataSource, this.viewGrid.fields); if (this.viewGrid) { this.viewGrid.setWidth('100%'); this.formGridLayout.addMember(this.viewGrid); } this.addMember(this.formGridLayout); } }, // TODO: consider caching the prepared fields on // class level, the question is if it is faster // as then a clone action needs to be done prepareFields: function () { this.gridFields = this.prepareGridFields(this.fields); }, prepareGridFields: function (fields) { var result = [], i, length = fields.length, fld, type, expandFieldNames, hoverFunction, yesNoFormatFunction; for (i = 0; i < length; i++) { fld = fields[i]; if (!fld.gridProps) { continue; } fld = isc.shallowClone(fields[i]); //isc.addProperties(fld, fld.gridProps); type = isc.SimpleType.getType(fld.type); if (type && fld && type.editorType && !fld.editorType) { fld.editorType = type.editorType; } if (type && fld && type.filterEditorType && !fld.filterEditorType) { fld.filterEditorType = type.filterEditorType; } result.push(fld); } this.autoExpandFieldNames = []; length = result.length; for (i = 0; i < length; i++) { if (result[i].autoExpand) { this.autoExpandFieldNames.push(result[i].name); } } return result; } }); datasourceCreate = function (dsProperties) { var i, length, flds; // set some default properties if (!dsProperties.operationBindings) { dsProperties.operationBindings = [{ operationType: 'fetch', dataProtocol: 'postParams', requestProperties: { httpMethod: 'POST' } }, { operationType: 'add', dataProtocol: 'postMessage' }, { operationType: 'remove', dataProtocol: 'postParams', requestProperties: { httpMethod: 'DELETE' } }, { operationType: 'update', dataProtocol: 'postMessage', requestProperties: { httpMethod: 'PUT' } }]; } dsProperties.recordXPath = dsProperties.recordXPath || '/response/data'; dsProperties.dataFormat = dsProperties.dataFormat || 'json'; dsProperties.titleField = dsProperties.titleField || '_identifier'; if (dsProperties.fields) { flds = dsProperties.fields; length = flds.length; for (i = 0; i < length; i++) { if (!flds[i].type) { flds[i].type = 'text'; } } } // if must be a new datasource then change the id // https://issues.openbravo.com/view.php?id=16581 if (dsProperties._new && dsProperties.ID) { dsProperties.ID = dsProperties.ID + '_' + new Date().getTime(); } if (dsProperties.ID) { var ds = isc.DataSource.getDataSource(dsProperties.ID); if (ds) { return ds; } } if (dsProperties.createClassName) { return isc[dsProperties.createClassName].create(dsProperties); } return isc.OBRestDataSource.create(dsProperties); }; isc.ClassFactory.defineClass('OBMyCustomWindow', isc.VLayout); isc.OBMyCustomWindow.addProperties({ initWidget: function () { this.windowLayout = isc.VLayout.create({ width: '100%', // is set by its content height: '100%', overflow: 'visible' }); this.addChild(this.windowLayout); this.viewProperties.standardWindow = this; this.viewProperties.isRootView = true; this.view = isc.OBMyCustomView.create(this.viewProperties); this.windowLayout.addMember(this.view); this.Super('initWidget', arguments); } }); /*jslint*/ //OB.Layout.ViewManager.loadedWindowClassName = '_123_1380804570692'; isc.ClassFactory.defineClass('_123_1380804570692', isc.OBMyCustomWindow).addProperties({ width: '100%', height: '100%', windowId: '123', multiDocumentEnabled: false, viewProperties: { windowId: '123', standardWindow: this.standardWindow, tabTitle: 'Business Partner', entity: 'BusinessPartner', isDeleteableTable: true, tabId: '220', moduleId: '0', mapping250: '/BusinessPartner/BusinessPartner', standardProperties: { inpTabId: '220', inpwindowId: '123', inpTableId: '291', inpkeyColumnId: 'C_BPartner_ID', keyProperty: 'id', inpKeyName: 'inpcBpartnerId', keyColumnName: 'C_BPartner_ID', keyPropertyType: '_id_13' }, showParentButtons: true, buttonsHaveSessionLogic: false, fields: [{ name: 'organization', title: 'Organization', required: true, updatable: false, sessionProperty: true, hasDefaultValue: true, columnName: 'AD_Org_ID', inpColumnName: 'inpadOrgId', refColumnName: 'AD_Org_ID', targetEntity: 'Organization', gridProps: { sort: 1, autoExpand: true, editorProps: { displayField: null, valueField: null }, displaylength: 44, fkField: true, showHover: true }, type: '_id_19' }, { name: 'searchKey', title: 'Search Key', required: true, sessionProperty: true, columnName: 'Value', inpColumnName: 'inpvalue', firstFocusedField: true, "length": 40, gridProps: { sort: 2, autoExpand: true, showHover: true, length: 40, displaylength: 24 }, type: '_id_10' }, { name: 'name', title: 'Commercial Name', required: true, columnName: 'Name', inpColumnName: 'inpname', "length": 60, gridProps: { sort: 3, autoExpand: true, showHover: true, length: 60, displaylength: 60 }, type: '_id_10' }, { name: 'taxID', title: 'Tax ID', columnName: 'TaxID', inpColumnName: 'inptaxid', "length": 20, gridProps: { sort: 4, autoExpand: true, showHover: true, length: 20, displaylength: 12 }, type: '_id_10' }, { name: 'businessPartnerCategory', title: 'Business Partner Category', required: true, hasDefaultValue: true, columnName: 'C_BP_Group_ID', inpColumnName: 'inpcBpGroupId', refColumnName: 'C_BP_Group_ID', targetEntity: 'BusinessPartnerCategory', gridProps: { sort: 5, autoExpand: true, editorProps: { displayField: null, valueField: null }, displaylength: 44, fkField: true, showHover: true }, type: '_id_19' }, { name: 'name2', title: 'Fiscal Name', columnName: 'Name2', inpColumnName: 'inpname2', "length": 60, gridProps: { sort: 6, autoExpand: true, showIf: 'false', showHover: true, length: 60, displaylength: 60 }, type: '_id_10' }, { name: 'description', title: 'Description', columnName: 'Description', inpColumnName: 'inpdescription', "length": 255, gridProps: { sort: 7, autoExpand: true, showIf: 'false', showHover: true, length: 255, displaylength: 60 }, type: '_id_10' }, { name: 'uRL', title: 'URL', columnName: 'URL', inpColumnName: 'inpurl', gridProps: { sort: 8, showIf: 'false', showHover: true, length: 120, displaylength: 60 }, type: '_id_800101' }, { name: 'referenceNo', title: 'Reference No.', columnName: 'ReferenceNo', inpColumnName: 'inpreferenceno', "length": 40, gridProps: { sort: 10, autoExpand: true, showIf: 'false', showHover: true, length: 40, displaylength: 11 }, type: '_id_10' }, { name: 'consumptionDays', title: 'Consumption Days', hasDefaultValue: true, columnName: 'Last_Days', inpColumnName: 'inplastDays', gridProps: { sort: 12, showIf: 'false', filterOnKeypress: false }, type: '_id_11' }, { name: 'obreBpGender', title: 'Gender', columnName: 'EM_Obre_Bp_Gender', inpColumnName: 'inpemObreBpGender', gridProps: { sort: 14, showIf: 'false', showHover: true, length: 60, displaylength: 60, filterOnKeypress: false }, type: '_id_EF6F03D306A54DEBB06C341706DCBCC0' }, { name: 'active', title: 'Active', hasDefaultValue: true, columnName: 'IsActive', inpColumnName: 'inpisactive', "width": 1, "overflow": "visible", gridProps: { sort: 15, showIf: 'false', editorProps: { showTitle: false, showLabel: false }, canGroupBy: false, width: '*', autoFitWidth: false, yesNo: true }, type: '_id_20' }, { name: 'customer', title: 'Customer', hasDefaultValue: true, columnName: 'IsCustomer', inpColumnName: 'inpiscustomer', showIf: function (item, value, form, currentValues, context) { return (false); }, "width": 1, "overflow": "visible", gridProps: { sort: 9, showIf: 'false', editorProps: { showTitle: false, showLabel: false }, canGroupBy: false, width: '*', autoFitWidth: false, yesNo: true }, type: '_id_20' }, { name: 'vendor', title: 'Vendor', columnName: 'IsVendor', inpColumnName: 'inpisvendor', showIf: function (item, value, form, currentValues, context) { return (false); }, "width": 1, "overflow": "visible", gridProps: { sort: 11, showIf: 'false', editorProps: { showTitle: false, showLabel: false }, canGroupBy: false, width: '*', autoFitWidth: false, yesNo: true }, type: '_id_20' }, { name: 'employee', title: 'Employee', columnName: 'IsEmployee', inpColumnName: 'inpisemployee', showIf: function (item, value, form, currentValues, context) { return (false); }, "width": 1, "overflow": "visible", gridProps: { sort: 13, showIf: 'false', editorProps: { showTitle: false, showLabel: false }, canGroupBy: false, width: '*', autoFitWidth: false, yesNo: true }, type: '_id_20' }, { name: '1000100001', title: 'Audit', personalizable: false, defaultValue: 'Audit', itemIds: ['creationDate', 'createdBy', 'updated', 'updatedBy'], type: 'OBAuditSectionItem' }, { name: 'creationDate', title: 'Creation Date', disabled: true, updatable: false, personalizable: false, gridProps: { sort: 990, cellAlign: 'left', showIf: 'false' }, type: '_id_16' }, { name: 'createdBy', title: 'Created By', disabled: true, updatable: false, personalizable: false, targetEntity: 'User', displayField: 'createdBy$_identifier', gridProps: { sort: 990, cellAlign: 'left', showIf: 'false' }, type: '_id_30' }, { name: 'updated', title: 'Updated', disabled: true, updatable: false, personalizable: false, gridProps: { sort: 990, cellAlign: 'left', showIf: 'false' }, type: '_id_16' }, { name: 'updatedBy', title: 'Updated By', disabled: true, updatable: false, personalizable: false, targetEntity: 'User', displayField: 'updatedBy$_identifier', gridProps: { sort: 990, cellAlign: 'left', showIf: 'false' }, type: '_id_30' }, { name: '_notes_', personalizable: false, type: 'OBNoteSectionItem' }, { name: '_notes_Canvas', personalizable: false, type: 'OBNoteCanvasItem' }, { name: '_linkedItems_', personalizable: false, type: 'OBLinkedItemSectionItem' }, { name: '_linkedItems_Canvas', personalizable: false, type: 'OBLinkedItemCanvasItem' }, { name: '_attachments_', personalizable: false, type: 'OBAttachmentsSectionItem' }, { name: '_attachments_Canvas', personalizable: false, type: 'OBAttachmentCanvasItem' } ], statusBarFields: [], initialPropertyToColumns: [{ property: 'isofiscalcode', inpColumn: 'inpisofiscalcode', dbColumn: 'Isofiscalcode', type: '_id_10' }, { property: 'fiscalcode', inpColumn: 'inpfiscalcode', dbColumn: 'Fiscalcode', type: '_id_10' }, { property: 'language', inpColumn: 'inpadLanguage', dbColumn: 'AD_Language', type: '_id_106' }, { property: 'summaryLevel', inpColumn: 'inpissummary', dbColumn: 'IsSummary', type: '_id_20' }, { property: 'valuation', inpColumn: 'inprating', dbColumn: 'Rating', type: '_id_10' }, { property: 'greeting', inpColumn: 'inpcGreetingId', dbColumn: 'C_Greeting_ID', type: '_id_19' }, { property: 'acquisitionCost', inpColumn: 'inpacqusitioncost', dbColumn: 'AcqusitionCost', type: '_id_12' }, { property: 'potentialCustomer', inpColumn: 'inpisprospect', dbColumn: 'IsProspect', type: '_id_20' }, { property: 'lifetimeRevenueToDate', inpColumn: 'inpactuallifetimevalue', dbColumn: 'ActualLifeTimeValue', type: '_id_12' }, { property: 'dateOfFirstSale', inpColumn: 'inpfirstsale', dbColumn: 'FirstSale', type: '_id_15' }, { property: 'noOfEmployees', inpColumn: 'inpnumberemployees', dbColumn: 'NumberEmployees', type: '_id_11' }, { property: 'expectedLifetimeRevenue', inpColumn: 'inppotentiallifetimevalue', dbColumn: 'PotentialLifeTimeValue', type: '_id_12' }, { property: 'volumeOfSales', inpColumn: 'inpsalesvolume', dbColumn: 'SalesVolume', type: '_id_12' }, { property: 'share', inpColumn: 'inpshareofcustomer', dbColumn: 'ShareOfCustomer', type: '_id_11' }, { property: 'invoiceTerms', inpColumn: 'inpinvoicerule', dbColumn: 'InvoiceRule', type: '_id_150' }, { property: 'operator', inpColumn: 'inpisworker', dbColumn: 'Isworker', type: '_id_20' }, { property: 'invoiceGrouping', inpColumn: 'inpinvoicegrouping', dbColumn: 'Invoicegrouping', type: '_id_800026' }, { property: 'client', inpColumn: 'inpadClientId', dbColumn: 'AD_Client_ID', sessionProperty: true, type: '_id_19' }, { property: 'id', inpColumn: 'inpcBpartnerId', dbColumn: 'C_BPartner_ID', sessionProperty: true, type: '_id_13' }, { property: 'dUNS', inpColumn: 'inpduns', dbColumn: 'DUNS', type: '_id_10' }, { property: 'nAICSSIC', inpColumn: 'inpnaics', dbColumn: 'NAICS', type: '_id_10' }, { property: 'oneTimeTransaction', inpColumn: 'inpisonetime', dbColumn: 'IsOneTime', type: '_id_20' }, { property: 'creditUsed', inpColumn: 'inpsoCreditused', dbColumn: 'SO_CreditUsed', type: '_id_12' }, { property: 'forcedOrg', inpColumn: 'inpadForcedOrgId', dbColumn: 'AD_Forced_Org_ID', type: '_id_276' }, { property: 'pricesShownInOrder', inpColumn: 'inpshowpriceinorder', dbColumn: 'ShowPriceInOrder', type: '_id_20' }, { property: 'uPCEAN', inpColumn: 'inpupc', dbColumn: 'UPC', type: '_id_10' }, { property: 'creditStatus', inpColumn: 'inpsocreditstatus', dbColumn: 'SOCreditStatus', type: '_id_289' }, { property: 'id', inpColumn: 'C_BPartner_ID', dbColumn: 'C_BPartner_ID', sessionProperty: true, type: '_id_13' }], hasChildTabs: false, initWidget: function () { this.prepareFields(); this.dataSource = datasourceCreate({ createClassName: 'OBViewDataSource', dataURL: 'org.openbravo.service.datasource/BusinessPartner', requestProperties: { params: { _className: 'OBViewDataSource', Constants_FIELDSEPARATOR: '$', Constants_IDENTIFIER: '_identifier' } }, fields: [{ name: 'id', type: '_id_13', primaryKey: true }, { name: 'client', type: '_id_19' }, { name: 'client$_identifier' }, { name: 'organization', type: '_id_19' }, { name: 'organization$_identifier' }, { name: 'active', type: '_id_20' }, { name: 'creationDate', type: '_id_16' }, { name: 'createdBy', type: '_id_30' }, { name: 'createdBy$_identifier' }, { name: 'updated', type: '_id_16' }, { name: 'updatedBy', type: '_id_30' }, { name: 'updatedBy$_identifier' }, { name: 'searchKey', type: '_id_10' }, { name: 'name', type: '_id_10' }, { name: 'name2', type: '_id_10' }, { name: 'description', type: '_id_10' }, { name: 'summaryLevel', type: '_id_20' }, { name: 'businessPartnerCategory', type: '_id_19' }, { name: 'businessPartnerCategory$_identifier' }, { name: 'oneTimeTransaction', type: '_id_20' }, { name: 'potentialCustomer', type: '_id_20' }, { name: 'vendor', type: '_id_20' }, { name: 'customer', type: '_id_20' }, { name: 'employee', type: '_id_20' }, { name: 'isSalesRepresentative', type: '_id_20' }, { name: 'referenceNo', type: '_id_10' }, { name: 'dUNS', type: '_id_10' }, { name: 'uRL', type: '_id_800101' }, { name: 'language', type: '_id_106' }, { name: 'language$_identifier' }, { name: 'taxID', type: '_id_10' }, { name: 'taxExempt', type: '_id_20' }, { name: 'invoiceSchedule', type: '_id_19' }, { name: 'invoiceSchedule$_identifier' }, { name: 'valuation', type: '_id_10' }, { name: 'volumeOfSales', type: '_id_12' }, { name: 'noOfEmployees', type: '_id_11' }, { name: 'nAICSSIC', type: '_id_10' }, { name: 'dateOfFirstSale', type: '_id_15' }, { name: 'acquisitionCost', type: '_id_12' }, { name: 'expectedLifetimeRevenue', type: '_id_12' }, { name: 'lifetimeRevenueToDate', type: '_id_12' }, { name: 'share', type: '_id_11' }, { name: 'formOfPayment', type: '_id_195', valueMap: { '5': 'Bank Deposit', 'R': 'Bank Remittance', 'B': 'Cash', 'C': 'Cash on Delivery', '2': 'Check', 'K': 'Credit Card', '4': 'Money Order', 'P': 'On Credit', '3': 'Promissory Note', '1': 'Wire Transfer', 'W': 'Withholding' } }, { name: 'creditLimit', type: '_id_12' }, { name: 'creditUsed', type: '_id_12' }, { name: 'paymentTerms', type: '_id_19' }, { name: 'paymentTerms$_identifier' }, { name: 'priceList', type: '_id_166' }, { name: 'priceList$_identifier' }, { name: 'printDiscount', type: '_id_20' }, { name: 'orderDescription', type: '_id_10' }, { name: 'orderReference', type: '_id_10' }, { name: 'pOFormOfPayment', type: '_id_195', valueMap: { '5': 'Bank Deposit', 'R': 'Bank Remittance', 'B': 'Cash', 'C': 'Cash on Delivery', '2': 'Check', 'K': 'Credit Card', '4': 'Money Order', 'P': 'On Credit', '3': 'Promissory Note', '1': 'Wire Transfer', 'W': 'Withholding' } }, { name: 'purchasePricelist', type: '_id_800031' }, { name: 'purchasePricelist$_identifier' }, { name: 'pOPaymentTerms', type: '_id_227' }, { name: 'pOPaymentTerms$_identifier' }, { name: 'numberOfCopies', type: '_id_11' }, { name: 'greeting', type: '_id_19' }, { name: 'greeting$_identifier' }, { name: 'invoiceTerms', type: '_id_150', valueMap: { 'D': 'After Delivery', 'O': 'After Order Delivered', 'S': 'Customer Schedule After Delivery', 'N': 'Do Not Invoice', 'I': 'Immediate' } }, { name: 'deliveryTerms', type: '_id_151', valueMap: { 'R': 'After Receipt', 'A': 'Availability', 'L': 'Complete Line', 'O': 'Complete Order' } }, { name: 'deliveryMethod', type: '_id_152', valueMap: { 'D': 'Delivery', 'P': 'Pickup', 'S': 'Shipper' } }, { name: 'salesRepresentative', type: '_id_187' }, { name: 'salesRepresentative$_identifier' }, { name: 'partnerParent', type: '_id_13' }, { name: 'creditStatus', type: '_id_289', valueMap: { 'H': 'Credit Hold', 'O': 'Credit OK', 'S': 'Credit Stop', 'W': 'Credit Watch', 'X': 'No Credit Check' } }, { name: 'forcedOrg', type: '_id_276' }, { name: 'forcedOrg$_identifier' }, { name: 'pricesShownInOrder', type: '_id_20' }, { name: 'invoiceGrouping', type: '_id_800026', valueMap: { '000000000000000': 'By customer', '000000000010000': 'By project', '000010000000000': 'By ship location' } }, { name: 'maturityDate1', type: '_id_11' }, { name: 'maturityDate2', type: '_id_11' }, { name: 'maturityDate3', type: '_id_11' }, { name: 'operator', type: '_id_20' }, { name: 'uPCEAN', type: '_id_10' }, { name: 'salaryCategory', type: '_id_19' }, { name: 'salaryCategory$_identifier' }, { name: 'invoicePrintformat', type: '_id_800007', valueMap: { '1': 'Detail', '3': 'Product detail', '2': 'Total' } }, { name: 'consumptionDays', type: '_id_11' }, { name: 'bankAccount', type: '_id_800046' }, { name: 'bankAccount$_identifier' }, { name: 'taxCategory', type: '_id_800090' }, { name: 'taxCategory$_identifier' }, { name: 'pOMaturityDate1', type: '_id_11' }, { name: 'pOMaturityDate2', type: '_id_11' }, { name: 'pOMaturityDate3', type: '_id_11' }, { name: 'transactionalBankAccount', type: '_id_800046' }, { name: 'transactionalBankAccount$_identifier' }, { name: 'sOBPTaxCategory', type: '_id_800090' }, { name: 'sOBPTaxCategory$_identifier' }, { name: 'fiscalcode', type: '_id_10' }, { name: 'isofiscalcode', type: '_id_10' }, { name: 'incotermsPO', type: '_id_D2D4CC1F12434BB69733166A9423F2C6' }, { name: 'incotermsPO$_identifier' }, { name: 'incotermsSO', type: '_id_D2D4CC1F12434BB69733166A9423F2C6' }, { name: 'incotermsSO$_identifier' }, { name: 'paymentMethod', type: '_id_EED0EF97D4A7421687F3B365D009E7A6' }, { name: 'paymentMethod$_identifier' }, { name: 'pOPaymentMethod', type: '_id_EED0EF97D4A7421687F3B365D009E7A6' }, { name: 'pOPaymentMethod$_identifier' }, { name: 'account', type: '_id_DF1CEA94B3564A33AFDB37C07E1CE353' }, { name: 'account$_identifier' }, { name: 'pOFinancialAccount', type: '_id_DF1CEA94B3564A33AFDB37C07E1CE353' }, { name: 'pOFinancialAccount$_identifier' }, { name: 'customerBlocking', type: '_id_20' }, { name: 'vendorBlocking', type: '_id_20' }, { name: 'paymentIn', type: '_id_20' }, { name: 'paymentOut', type: '_id_20' }, { name: 'salesInvoice', type: '_id_20' }, { name: 'purchaseInvoice', type: '_id_20' }, { name: 'salesOrder', type: '_id_20' }, { name: 'purchaseOrder', type: '_id_20' }, { name: 'goodsShipment', type: '_id_20' }, { name: 'goodsReceipt', type: '_id_20' }, { name: 'obreBpGender', type: '_id_EF6F03D306A54DEBB06C341706DCBCC0', valueMap: { 'Female': 'Female', 'Male': 'Male' } }] }) ; this.dataSource.potentiallyShared = true; this.viewGrid = isc.ListGrid.create({ view: this, uiPattern: 'STD', autoFitFieldWidths: true, autoFitWidthApproach: 'title', canAutoFitFields: false, minFieldWidth: 75, width: '100%', height: '100%', showFilterEditor: true, canEdit: true, alternateRecordStyles: true, sortField: 'searchKey', // the this is the view instance fields: this.gridFields }) ; this.Super('initWidget', arguments); } } }); isc._123_1380804570692.create({}).show();