/*
  MIT License http://www.opensource.org/licenses/mit-license.php
  Author Tobias Koppers @sokra
*/

/*
 * Tine 2.0
 *
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Christian Feitl <c.feitl@metaways.de>
 * @copyright   Copyright (c) 2022 Metaways Infosystems GmbH (http://www.metaways.de)
 */

/*
 * Tine 2.0
 *
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Cornelius Weiss <c.weiss@metaways.de>
 * @copyright   Copyright (c) 2022 Metaways Infosystems GmbH (http://www.metaways.de)
 */

/*
 * Tine 2.0
 *
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Cornelius Weiß <c.weiss@metaways.de>
 * @copyright   Copyright (c) 2020 Metaways Infosystems GmbH (http://www.metaways.de)
 */

/*
 * Tine 2.0
 * 
 * @package     Crm
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Alexander Stintzing <alex@stintzing.net>
 * @copyright   Copyright (c) 2009-2012 Metaways Infosystems GmbH (http://www.metaways.de)
 *
 */

/*
 * Tine 2.0
 * 
 * @package     Crm
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Cornelius Weiss <c.weiss@metaways.de>
 * @copyright   Copyright (c) 2009 Metaways Infosystems GmbH (http://www.metaways.de)
 *
 */

/*
 * Tine 2.0
 * 
 * @package     Crm
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Cornelius Weiss <c.weiss@metaways.de>
 * @copyright   Copyright (c) 2009-2011 Metaways Infosystems GmbH (http://www.metaways.de)
 *
 */

/*
 * Tine 2.0
 * 
 * @package     Crm
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Philipp Schuele <p.schuele@metaways.de>
 * @copyright   Copyright (c) 2007-2009 Metaways Infosystems GmbH (http://www.metaways.de)
 *
 */

/*
 * Tine 2.0
 * 
 * @package     Crm
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Philipp Schuele <p.schuele@metaways.de>
 * @copyright   Copyright (c) 2007-2010 Metaways Infosystems GmbH (http://www.metaways.de)
 *
 */

/*
 * Tine 2.0
 * 
 * @package     Crm
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Philipp Schuele <p.schuele@metaways.de>
 * @copyright   Copyright (c) 2009 Metaways Infosystems GmbH (http://www.metaways.de)
 *
 * TODO         add to extdoc
 */

/*
 * Tine 2.0
 * 
 * @package     Crm
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Philipp Schuele <p.schuele@metaways.de>
 * @copyright   Copyright (c) 2009-2015 Metaways Infosystems GmbH (http://www.metaways.de)
 *
 */

/*
 * Tine 2.0
 * 
 * @package     Crm
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Philipp Schüle <p.schuele@metaways.de>
 * @copyright   Copyright (c) 2007-2011 Metaways Infosystems GmbH (http://www.metaways.de)
 *
 */

/*
 * Tine 2.0
 * 
 * @package     Crm
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Philipp Schüle <p.schuele@metaways.de>
 * @copyright   Copyright (c) 2009-2011 Metaways Infosystems GmbH (http://www.metaways.de)
 *
 * TODO         use Tine.widgets.grid.LinkGridPanel
 */

/*
 * Tine 2.0
 * 
 * @package     Crm
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Philipp Schüle <p.schuele@metaways.de>
 * @copyright   Copyright (c) 2009-2022 Metaways Infosystems GmbH (http://www.metaways.de)
 *
 * TODO         use Tine.widgets.grid.LinkGridPanel
 */

/*
 * Tine 2.0
 * Crm combo box and store
 * 
 * @package     Crm
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Alexander Stintzing <alex@stintzing.net>
 * @copyright   Copyright (c) 2007-2011 Metaways Infosystems GmbH (http://www.metaways.de)
 *
 */

/* 
 * Tine 2.0
 * 
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Michael Spahn <kontakt@michaelspahn.de>
 * @copyright   Copyright (c) 2015 Metaways Infosystems GmbH (http://www.metaways.de)
 */

/* ["default"] */

/* ["default"].locals */

/* asset import */

/* binding */

/* default */

/* default.locals */

/* harmony default export */

/* harmony export */

/* harmony import */

/* istanbul ignore if  */

/* istanbul ignore next  */

/* pkg: Crm FAT Client (css/Crm-FAT.css)*/

/* pkg: Crm FAT Client (js/Crm-FAT.js)*/

/*#__PURE__*/

/**
   * @cfg {Record} foreignRecordClass needed for explicit defined filters
   */

/**
   * @cfg {String} ownField for explicit filterRow
   */

/**
   * @cfg {bool} autoExpand Autoexpand comboBox on focus.
   */

/**
   * @cfg {bool} blurOnSelect blurs combobox when item gets selected
   */

/**
   * @private
   */

/**
   * @return Ext.grid.ColumnModel
   * @private
   */

/**
   * @see Tine.widgets.dialog.AddToRecordPanel::getFormItems()
   */

/**
   * @see Tine.widgets.dialog.AddToRecordPanel::isValid()
   */

/**
   * @type Array
   * @property otherActions
   */

/**
   * @type Ext.Menu
   * @property contextMenu
   */

/**
   * @type function
   * @property recordEditDialogOpener
   */

/**
   * Return CSS class to apply to rows depending upon due status
   *
   * @param {Tine.Tasks.Model.Task} record
   * @param {Integer} index
   * @return {String}
   */

/**
   * The record currently being edited
   * 
   * @type Tine.Crm.Model.Lead
   * @property record
   */

/**
   * auto hook text i18n._('New Lead')
   */

/**
   * default panel w.o. data
   * 
   * @return {Ext.ux.display.DisplayPanel}
   * 
   * TODO add something useful here
   */

/**
   * dependend tasks grid
   * 
   * @type dependentTasksPanel
   * @property tasksGrid
   */

/**
   * eval grants
   * @cfg {Boolean} evalGrants
   */

/**
   * executed after record got updated from proxy
   * 
   * @private
   */

/**
   * generic apply changes handler
   * @param {Boolean} closeWindow
   */

/**
   * get panel for multi selection aggregates/information
   * 
   * @return {Ext.Panel}
   */

/**
   * getAdditionalData
   * collects additional data (start/end dates, linked contacts, ...)
   */

/**
   * getRelationData
   * get the record relation data (switch relation and related record)
   * 
   * @param   Object record with relation data
   * @return  Object relation with record data
   */

/**
   * grid config
   * @private
   */

/**
   * grid specific
   * @private
   */

/**
   * ids of lead states that end a lead (needed to determine grid row class)
   */

/**
   * ignore these models in relation grid
   * @type {Array}
   */

/**
   * init actions and bars
   */

/**
   * init other actions and tbar (change contact type and contact search combo
   */

/**
   * init template
   * @private
   */

/**
   * inits this cmp
   * @private
   */

/**
   * inits this component
   */

/**
   * linked contacts grid
   * 
   * @type Tine.Crm.Contact.GridPanel
   * @property contactGrid
   */

/**
   * main lead details panel
   * 
   * @return {Ext.ux.display.DisplayPanel}
   * 
   * TODO add tasks / products?
   * TODO add contact icons?
   */

/**
   * mute first alert
   *
   * @param {} button
   * @param {} e
   */

/**
   * onclick handler for changeContactType
   */

/**
   * override default onSelect
   * 
   * TODO add some logic to determine if contact is customer or partner
   */

/**
   * record class
   * @cfg {Tine.Addressbook.Model.Contact} recordClass
   */

/**
   * record class
   * @cfg {Tine.Crm.Model.Lead} recordClass
   */

/**
   * record class
   * @cfg {Tine.Sales.Model.Product} recordClass
   */

/**
   * render customer contact
   * 
   * @param {Array} value
   * @return {String}
   */

/**
   * render partner contact
   * 
   * @param {Array} value
   * @return {String}
   */

/**
   * render responsible contact
   * 
   * @param {Array} value
   * @return {String}
   * 
   * TODO use another renderer (with email, phone, ...) here?
   */

/**
   * renders contact names
   * 
   * @param {String} type
   * @return {String}
   * 
   * TODO add mail link
   * TODO all labels should have the same width
   */

/**
   * returns cm
   * 
   * @return Ext.grid.ColumnModel
   * @private
   */

/**
   * returns dialog
   * 
   * NOTE: when this method gets called, all initalisation is done.
   * 
   * @return {Object}
   * @private
   */

/**
   * returns view row class (scope is this.grid.view)
   */

/**
   * show default panel
   * 
   * @param {Mixed} body
   */

/**
   * show template for multiple rows
   * 
   * @param {Ext.grid.RowSelectionModel} sm
   * @param {Mixed} body
   */

/**
   * split the relations array in contacts and switch related_record and relation objects
   * 
   * @return {Array}
   */

/**
   * store to hold all contacts
   * 
   * @type Ext.data.Store
   * @property store
   */

/**
   * store to hold all contacts of grid
   * 
   * @type Ext.data.Store
   * @property contactsStore
   */

/**
   * update event handler for related contacts
   * 
   * TODO use generic function?
   */

/**
   * update lead details panel
   * 
   * @param {Tine.Tinebase.data.Record} record
   * @param {Mixed} body
   */

/**
 * @namespace   Tine.Crm
 * @class       Tine.Crm.AddToLeadPanel
 * @extends     Tine.widgets.dialog.AddToRecordPanel
 * @author      Alexander Stintzing <alex@stintzing.net>
 */

/**
 * @namespace   Tine.Crm
 * @class       Tine.Crm.AddressbookGridPanelHook
 * 
 * <p>Crm Addressbook Hook</p>
 * <p>
 * </p>
 * 
 * @author      Cornelius Weiss <c.weiss@metaways.de>
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * 
 * @constructor
 */

/**
 * @namespace   Tine.Crm
 * @class       Tine.Crm.Application
 * @extends     Tine.Tinebase.Application
 * Crm Application Object <br>
 * 
 * @author      Cornelius Weiss <c.weiss@metaways.de>
 */

/**
 * @namespace   Tine.Crm
 * @class       Tine.Crm.LeadEditDialog
 * @extends     Tine.widgets.dialog.EditDialog
 * 
 * <p>Lead Edit Dialog</p>
 * <p>
 * TODO         simplify relation handling (move init of stores to relation grids and get data from there later?)
 * TODO         make marking of invalid fields work again
 * TODO         add export button
 * </p>
 * 
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * 
 * @param       {Object} config
 * @constructor
 * Create a new Tine.Crm.LeadEditDialog
 */

/**
 * @namespace   Tine.Crm
 * @class       Tine.Crm.LeadGridDetailsPanel
 * @extends     Tine.widgets.grid.DetailsPanel
 * 
 * <p>Lead Grid Details Panel</p>
 * <p>
 * </p>
 * 
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Philipp Schuele <p.schuele@metaways.de>
 * @copyright   Copyright (c) 2009 Metaways Infosystems GmbH (http://www.metaways.de)
 */

/**
 * @namespace   Tine.Crm.Contact
 * @class       Tine.Crm.Contact.Combo
 * @extends     Tine.Addressbook.SearchCombo
 * 
 * Lead Dialog Contact Search Combo
 * 
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Philipp Schuele <p.schuele@metaways.de>
 * @copyright   Copyright (c) 2007-2009 Metaways Infosystems GmbH (http://www.metaways.de)
 */

/**
 * @namespace   Tine.Crm.Contact
 * @class       Tine.Crm.Contact.GridPanel
 * @extends     Ext.grid.EditorGridPanel
 * 
 * Lead Dialog Contact Grid Panel
 * 
 * <p>
 * </p>
 * 
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Philipp Schuele <p.schuele@metaways.de>
 * @copyright   Copyright (c) 2009 Metaways Infosystems GmbH (http://www.metaways.de)
 */

/**
 * @namespace   Tine.Crm.Contact
 * @class       Tine.Crm.Contact.TypeComboBox
 * @extends     Ext.form.ComboBox
 * 
 * Contact type selection combobox
 * 
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Philipp Schuele <p.schuele@metaways.de>
 * @copyright   Copyright (c) 2007-2009 Metaways Infosystems GmbH (http://www.metaways.de)
 */

/**
 * @namespace   Tine.Crm.LinkGridPanel
 * 
 * TODO         move change contact type functions
 */

/**
 * @namespace   Tine.Crm.Product
 * @class       Tine.Crm.Product.GridPanel
 * @extends     Ext.grid.EditorGridPanel
 * 
 * Lead Dialog Products Grid Panel
 * 
 * <p>
 * TODO         allow multiple relations with 1 product or add product quantity?
 * TODO         check if we need edit/add actions again
 * TODO         make resizing work correctly
 * </p>
 * 
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Philipp Schuele <p.schuele@metaways.de>
 * @copyright   Copyright (c) 2009 Metaways Infosystems GmbH (http://www.metaways.de)
 */

/**
 * @namespace Tine.Crm
 * @class Tine.Crm.FilterPanel
 * @extends Tine.widgets.persistentfilter.PickerPanel
 * Crm Filter Panel<br>
 * 
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Philipp Schuele <p.schuele@metaways.de>
 * @copyright   Copyright (c) 2007-2009 Metaways Infosystems GmbH (http://www.metaways.de)
 */

/**
 * @namespace Tine.Crm
 * @class Tine.Crm.MainScreen
 * @extends Tine.widgets.MainScreen
 * MainScreen of the Crm Application <br>
 * 
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Philipp Schuele <p.schuele@metaways.de>
 * @copyright   Copyright (c) 2007-2009 Metaways Infosystems GmbH (http://www.metaways.de)
 * @constructor
 * Constructs mainscreen of the crm application
 */

/**
 * @namespace Tine.Crm
 * @class Tine.Crm.TreePanel
 * @extends Tine.widgets.container.TreePanel
 * Left Crm Panel including Tree<br>
 * 
 * TODO add d&d support to tree
 * 
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Philipp Schuele <p.schuele@metaways.de>
 * @copyright   Copyright (c) 2007-2009 Metaways Infosystems GmbH (http://www.metaways.de)
 */

/**
 * @namespace Tine.Crm
 * @class Tine.Crm.leadBackend
 * @extends Tine.Tinebase.data.RecordProxy
 * 
 * Lead Backend
 */

/**
 * @namespace Tine.Crm.Model
 * 
 * get default data for a new lead
 *  
 * @return {Object} default data
 * @static
 */

/**
 * @namespace Tine.Crm.Model
 * @class Tine.Crm.Model.Lead
 * @extends Tine.Tinebase.data.Record
 * 
 * Lead Record Definition
 */

/**
 * Crm Edit Popup
 * 
 * @param   {Object} config
 * @return  {Ext.ux.Window}
 */

/**
 * Crm admin settings popup
 * 
 * @param   {Object} config
 * @return  {Ext.ux.Window}
 */

/**
 * Lead grid panel
 * 
 * @namespace   Tine.Crm
 * @class       Tine.Crm.LeadGridContactFilter
 * @extends     Tine.widgets.grid.FilterModel
 * 
 * <p>Contact Filter for Lead Grid Panel</p>
 * 
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Cornelius Weiss <c.weiss@metaways.de>
 * @copyright   Copyright (c) 2009 Metaways Infosystems GmbH (http://www.metaways.de)
 * 
 * @param       {Object} config
 * @constructor
 * Create a new Tine.Crm.LeadGridContactFilter
 */

/**
 * Lead grid panel
 * 
 * @namespace   Tine.Crm
 * @class       Tine.Crm.LeadGridPanel
 * @extends     Tine.widgets.grid.GridPanel
 * 
 * <p>Lead Grid Panel</p>
 * <p><pre>
 * TODO         add products to grid?
 * </pre></p>
 * 
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Philipp Schuele <p.schuele@metaways.de>
 * @copyright   Copyright (c) 2007-2010 Metaways Infosystems GmbH (http://www.metaways.de)
 * 
 * @param       {Object} config
 * @constructor
 * Create a new Tine.Crm.LeadGridPanel
 */

/**
 * Lead selection combo box
 * 
 * @namespace   Tine.Crm
 * @class       Tine.Crm.SearchCombo
 * @extends     Tine.Tinebase.widgets.form.RecordPickerComboBox
 * 
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Alexander Stintzing <alex@stintzing.net>
 * @copyright   Copyright (c) 2007-2012 Metaways Infosystems GmbH (http://www.metaways.de)
 * 
 * @param       {Object} config
 * @constructor
 * Create a new Tine.Crm.SearchCombo
 */

/**
 * Render country name by it's iso code
 *
 * @namespace   Tine.Addressbook
 * @author      Michael Spahn <m.spahn@metaways.de>
 * @singleton
 */

/**
 * Render given MailAddresss
 *
 * @namespace   Tine.Addressbook
 * @author      Michael Spahn <m.spahn@metaways.de>
 * @singleton
 */

/**
 * Render given URL as html
 *
 * @namespace   Tine.Addressbook
 * @author      Michael Spahn <m.spahn@metaways.de>
 * @singleton
 */

/**
 * Render given addresss
 *
 * You need to pass the record and a config to use this renderer.
 * The config contains a mapping, which fields from the record should have which place in the template.
 * Undefined fields won't be rendered, this keeps it well reusable for all address like purposes.
 *
 * @namespace   Tine.Addressbook
 * @author      Michael Spahn <m.spahn@metaways.de>
 * @singleton
 */

/**
 * Render given image
 *
 * @namespace   Tine.Addressbook
 * @author      Michael Spahn <m.spahn@metaways.de>
 * @singleton
 */

/**
 * Render preferred addresss
 *
 * give the preferred address from contact. (street, postalcode and locality)
 * @namespace   Tine.Addressbook
 * @author      Christian Feitl <c.feitl@metaways.de>
 */

/**
 * Tine 2.0
 *
 * @package     Tasks
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Cornelius Weiss <c.weiss@metaways.de>
 * @copyright   Copyright (c) 2023 Metaways Infosystems GmbH (http://www.metaways.de)
 */

/**
 * Tine 2.0
 * 
 * @package     Crm
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Philipp Schuele <p.schuele@metaways.de>
 * @copyright   Copyright (c) 2009-2015 Metaways Infosystems GmbH (http://www.metaways.de)
 *
 */

/**
 * admin settings panel
 * 
 * @namespace   Tine.Crm
 * @class       Tine.Crm.AdminPanel
 * @extends     Tine.widgets.dialog.EditDialog
 * 
 * <p>Crm Admin Panel</p>
 * <p><pre>
 * TODO         generalize this
 * TODO         revert/rollback changes onCancel
 * </pre></p>
 * 
 * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
 * @author      Philipp Schuele <p.schuele@metaways.de>
 * @copyright   Copyright (c) 2009-2015 Metaways Infosystems GmbH (http://www.metaways.de)
 * 
 * @param       {Object} config
 * @constructor
 * Create a new Tine.Crm.AdminPanel
 */

/**
 * contact column renderer
 * 
 * @param       {String} data
 * @param       {String} type (CUSTOMER|PARTNER)
 * @return      {String}
 * 
 * @namespace   Tine.Crm
 */

/**
 * contact type renderer function
 * 
 * @param   string type
 * @return  contact type icon
 */

/**
 * get filtermodel of lead model
 * 
 * @namespace Tine.Crm.Model
 * @static
 * @return {Array} filterModel definition
 */

/**
 * init ext grid panel
 * 
 * TODO         add grants for linked entries to disable EDIT?
 */

/**
 * init store
 * 
 */

/**
 * list type renderer
 *
 * @private
 * @return {String} HTML
 */

/**
 * returns ids of ended lead states
 */

/**
 * simple task panel to be used in editDialogs like projects, crm, ...
 *
 * @TODO support default data like container_id
 */

/***/

// @todo use the user/config ?

// @todo: Wouldn't it be cool, if this could be managed by the modelconfig as well?

// According to config, resolve the given fields from record

// CONCATENATED MODULE: ./ux/form/FieldTriggerPlugin.js

// Country code to country name

// Don't show item if it's a archived source!

// EXPORTS

// EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js

// Exports

// For old IE

// If url is already wrapped in quotes, remove them

// Module

// See https://drafts.csswg.org/css-values-3/#urls

// Should url be wrapped?

// Special case to return head of iframe instead of iframe itself

// TODO hardcode separator or get it from locale?

// TODO perhaps we could add an icon/button (i.e. edit-find.png) here

// This will throw an exception if access to iframe is blocked

// When focus changed

// When loading

// add contact type to "add" action

// add new product to store

// add remark values

// always set a default

// call delegates

// check if already in

// check if already in?

// create delegates

// custom keyFieldRecord

// define piechart stores

// do not do recursion!

// doubleclick handler

// drag n drop

// due to cross-origin restrictions

// end of getFormItems

// end of return

// focus+select new record

// get correct relation type from data (contact) array and show first matching record (org_name + n_fileas)

// get correct relation type from relations (contact) array

// i18n._('Probability')

// i18n._('X Lead')

// i18n._('read-only')

// import a list of modules into the list

// init properties

// init store stuff

// init toolbars and ctx menut / add actions

// istanbul ignore if

// istanbul ignore next

// load contacts/products into link grid (only first time this function gets called/store is empty)

// newLinkObject.relation = relations[i];

// ngettext('Lead', 'Leads', n);

// ngettext('lead list', 'lead lists', n); gettext('lead lists');

// on rowcontextmenu handler

// on selectionchange handler

// preserve space for triggers

// private

// problems with relations here

// remove contact relations to prevent cyclic relation structure

// return the list of modules as css string

// save record data

// set the relation type

// the relation object           

// this creates a circular structure which could not be converted to json!

// unset record id for new records

//private

//this.initActions = Tine.Crm.LinkGridPanel.initActions.createDelegate(this);

//this.onUpdate = Tine.Crm.LinkGridPanel.onUpdate.createDelegate(this);
