--- /dev/null
+/*
+Copyright (c) Igor Barma, Alexandre Desoubeaux, Christian Martel, Eric Brun, Mathieu Amblard, Gwenael Gevet, Pierre Guillot, 2012
+ * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Alexandre Lefevre, Marc Salvat 2014-2016
+ * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Marc Salvat, Marc Suarez, Harifetra Ramamonjy 2017
+For licensing, see README.txt or http://www.pentilanero.com (Cecill-C or AGPL or LGPL)
+*/
+Ext.ns("EntSavoie");
+//carnetDAdressesportlet
+EntSavoie.carnetDAdresses = function(config) {
+ Ext.apply(this, config);
+ this.COUNT_FOR_LIST_WARNING = 2000;
+
+ // Ajoute le texte des erreurs
+ Ext.QuickTips.init();
+ // turn on validation errors beside the field globally
+ Ext.form.Field.prototype.msgTarget = 'side';
+
+
+ // contient l'id de la liste courante affichee
+ this.currentSelectedList = null;
+
+ // contient le record du contact en cours
+ this.currentSelectedContactRecord = null;
+
+ // var tmp utilise lors de la suppression d'une liste
+ this.listToDelete = null;
+ this.recsToDelete = null;
+
+ //LES LISTES
+ this.searchListValue = "";
+ this.searchListFilter = this.searchListFilter || new Ext.form.TextField({
+ emptyText: this.i18n.carnetDAdresses.searchListFilter.emptyText,
+ clearCls: "clear-recherche"
+ });
+
+ this.listeRecordCreator = Ext.data.Record.create(["id", "name", "type", "orgId", "roleId", "listId", "parentList", "childrenList", "groupId", "grouping"]);
+
+ this._listes_store = this._listes_store || new Ext.data.GroupingStore({
+ // load using HTTP
+ url: this.renderURLAjax+"&jspPage=/listes.jsp",
+ // the return will be XML, so lets set up a reader
+ reader: new Ext.data.XmlReader({
+ record: "liste",
+ id: "id"
+ }, ["id","name", "type", "orgId", "roleId", "listId", "parentList", "childrenList", "groupId", "grouping"]),
+ groupField: "groupId",
+ sortInfo:{field: 'name', direction: "ASC"}
+ });
+
+ this.listGridGroupingView = this.listGridGroupingView || new Ext.grid.GroupingView({
+ startCollapsed: true,
+ forceFit:false,
+ groupTextTpl: '{[values.rs[0].get("grouping")]}'
+ });
+
+ this.deleteListBtn = this.deleteListBtn || new Ext.Button ({
+ tooltip: this.i18n.carnetDAdresses.deleteListBtn.tooltip,
+ iconCls: 'grid-delete',
+ handler: this.onDeleteList,
+ disabled: true,
+ scope: this
+ });
+
+ this.addListBtn = this.addListBtn || new Ext.Button ({
+ tooltip: this.i18n.carnetDAdresses.addListBtn.tooltip,
+ iconCls: 'grid-add',
+ scope: this,
+ handler: this.onAddList
+ });
+
+ this.editListButton = this.editListButton || new Ext.Button({
+ tooltip: this.i18n.carnetDAdresses.editListButton.tooltip,
+ iconCls: 'edit',
+ handler: this.onEditList,
+ disabled: true,
+ scope: this
+ });
+
+ this.addListItem = this.addListItem || new Ext.menu.Item({
+ text: this.i18n.carnetDAdresses.rightClicListMenu.addListItem.text,
+ handler: this.onAddList,
+ iconCls: 'grid-add',
+ scope: this
+ });
+
+ this.deleteListItem = this.deleteListItem || new Ext.menu.Item({
+ text: this.i18n.carnetDAdresses.rightClicListMenu.deleteListItem.text,
+ handler: this.onDeleteList,
+ iconCls: 'grid-delete',
+ scope: this
+ });
+
+ this.editListItem = this.editListItem || new Ext.menu.Item({
+ text: this.i18n.carnetDAdresses.rightClicListMenu.editListItem.text,
+ handler: this.onEditList,
+ iconCls: 'edit',
+ scope: this
+ });
+
+ this.sendListItem = this.sendListItem || new Ext.menu.Item({
+ text: this.i18n.carnetDAdresses.rightClicListMenu.sendListItem.text,
+ handler: this.onSendMessage,
+ iconCls: 'sendMsg',
+ scope: this
+ });
+
+ // Menu clic droit sur la grille des listes
+ this.rightClicListMenu = this.rightClicListMenu || new Ext.menu.Menu({
+ cls: "carnetDAdresses-portlet",
+ items: [
+ this.addListItem,
+ this.deleteListItem,
+ this.editListItem,
+ this.sendListItem
+ ]
+ });
+
+ this._listes_grid = this._listes_grid || new Ext.grid.GridPanel({
+ store: this._listes_store,
+ region: "west",
+ enableDragDrop: true,
+ ddGroup: "addFicheToListe",
+ ddText: this.i18n.carnetDAdresses._listes_grid.ddText,
+ autoExpandColumn: 'nom',
+ columns: [
+ {
+ header: "",
+ width: 20,
+ id:'nom',
+ dataIndex: 'name',
+ sortable: false,
+ groupable: false,
+ renderer: {
+ fn: function(value, metaData, record, rowIndex, colIndex, store) {
+ var result = "<span ext:qtip='" + record.get("name") + "'>" + record.get("name") + "</div>";
+
+ if(record.get("type") == "search" && record.get("groupId") == 10){
+ result += " <i style='color: gray;'> (Groupe) </i>";
+ }
+
+ return result;
+ },
+ scope: this
+ }
+ },
+ {header: "Listes", width: 400, dataIndex: 'groupId', sortable: false, hidden:true}
+ ],
+ view: this.listGridGroupingView,
+ hideHeaders: true,
+ width:220,
+ tbar: [this.searchListFilter],
+ bbar: [this.addListBtn, '-', this.deleteListBtn, '-', this.editListButton],
+ title: this.i18n.carnetDAdresses._listes_grid.title,
+ listeners: {
+ render: function(grid){
+ grid.scope.onRenderListGrid(grid);
+ }
+ },
+ scope: this
+ });
+
+
+ //LES CONTACTS
+ this.listId = null;
+ this.orgId = null;
+ this.roleId = null;
+ this.type = null;
+ this.parentList = null;
+ this.childrenList = null;
+
+ // objet permettant de creer un record de contact
+ this.contactRecordCreator = Ext.data.Record.create(["nom",
+ "prenom",
+ "statut",
+ "id",
+ "type",
+ "parentList",
+ "childrenList",
+ "relUserId"
+ ]);
+
+ this._content_store = new Ext.data.Store({
+ // load using HTTP
+ url: this.renderURLAjax+"&jspPage=/list_content.jsp",
+
+ // the return will be XML, so lets set up a reader
+ reader: new Ext.data.XmlReader({
+ totalProperty: 'total',
+ record: "fiche",
+ id: "id"
+ }, ["nom", "prenom", "statut", "id", "type", "parentList", "childrenList", "relUserId", "urlImage"]),
+ remoteSort: true,
+ sortInfo:{field: 'name', direction: "ASC"}
+ });
+
+ this.searchMemberValue="";
+ this.searchMemberFilter = this.searchMemberFilter || new Ext.form.TextField({
+ emptyText: this.i18n.carnetDAdresses.searchMemberFilter.emptyText,
+ clearCls: "clear-recherche"
+ });
+
+ this.memberPaggingTB = this.memberPaggingTB || new Ext.PagingToolbar({
+ pageSize: 35,
+ cls: 'no-border-paging-toolbar',
+ store: this._content_store,
+ displayInfo: false,
+ displayMsg: '',
+ emptyMsg: "",
+ items:[]
+ });
+
+ this.addContactButton = this.addContactButton || new Ext.Button({
+ tooltip: this.i18n.carnetDAdresses.addContactButton.tooltip,
+ iconCls: 'grid-add',
+ handler: this.onAddContact,
+ scope: this
+ });
+
+ this.removeContactButton = this.removeContactButton || new Ext.Button({
+ tooltip: this.i18n.carnetDAdresses.removeContactButton.tooltip,
+ iconCls: 'grid-delete',
+ handler: this.onDeleteContact,
+ scope: this
+ });
+
+ this.addContactItem = this.addContactItem || new Ext.menu.Item({
+ text: this.i18n.carnetDAdresses.rightClicContactMenu.addContactItem.text,
+ handler: this.onAddContact,
+ iconCls: 'grid-add',
+ scope: this
+ });
+
+ this.deleteContactItem = this.deleteContactItem || new Ext.menu.Item({
+ text: this.i18n.carnetDAdresses.rightClicContactMenu.deleteContactItem.text,
+ handler: this.onDeleteContact,
+ iconCls: 'grid-delete',
+ scope: this
+ });
+
+ this.sendContactItem = this.sendContactItem || new Ext.menu.Item({
+ text: this.i18n.carnetDAdresses.rightClicContactMenu.sendContactItem.text,
+ handler: this.onSendMessage,
+ iconCls: 'sendMsg',
+ scope: this
+ });
+
+ // Menu clic droit sur la grille des contacts
+ this.rightClicContactMenu = this.rightClicContactMenu || new Ext.menu.Menu({
+ cls: "carnetDAdresses-portlet",
+ items: [
+ this.addContactItem,
+ this.deleteContactItem,
+ this.sendContactItem
+ ]
+ });
+
+ this._content_grid = this._content_grid || new Ext.grid.GridPanel({
+ border: false,
+ region: "center",
+ style: "border-top: solid 1px #99BBE8;border-bottom: solid 1px #99BBE8;",
+ enableDragDrop: true,
+ ddGroup: "addFicheToListe",
+ ddText: this.i18n.carnetDAdresses._content_grid.ddText,
+ viewConfig: {
+ getRowClass: function(record, index) {
+ var tu = record.get("type");
+ if (tu == "fiche") {
+ return 'entry-fiche-row';
+ } else {
+ return 'entry-user-row';
+ }
+ }
+ },
+ autoExpandColumn: 'nom',
+ store: this._content_store,
+ columns: [
+ {header: this.i18n.carnetDAdresses._content_grid.columns.nom, width: 150, dataIndex: 'nom', id: 'nom', sortable: true},
+ {header: this.i18n.carnetDAdresses._content_grid.columns.prenom, width: 130, dataIndex: 'prenom', sortable: true},
+ {header: this.i18n.carnetDAdresses._content_grid.columns.statut, width: 250, dataIndex: 'statut', sortable: true}
+ ],
+ tbar: [this.searchMemberFilter],
+ bbar: [this.addContactButton,
+ '-',
+ this.removeContactButton,
+ '-',
+ this.memberPaggingTB],
+ title: this.i18n.carnetDAdresses._content_grid.title,
+ listeners: {
+ render: function(grid){
+ grid.scope.onRenderContentGrid(grid);
+ }
+ },
+ scope: this
+ });
+
+
+ //ADDCONTACT POPUP
+ //1° onglet add contact popup
+ this.addContactPopUpBtn = this.addContactPopUpBtn || new Ext.Button ({
+ text: this.i18n.carnetDAdresses.addContactPopUpBtn.text,
+ handler: this.onAddContactAction,
+ scope:this,
+ formBind:true
+ });
+
+ this.cancelAddContactPopUpBtn = this.cancelAddContactPopUpBtn || new Ext.Button ({
+ text: this.i18n.carnetDAdresses.cancelAddContactPopUpBtn.text,
+ scope:this,
+ handler: this.onAddContactCancel
+ });
+
+ this.nameField = this.nameField || new Ext.form.TextField({
+ fieldLabel: this.i18n.carnetDAdresses.nameField.fieldLabel,
+ name: 'nom',
+ allowBlank:false
+ });
+
+ this.firstNameField = this.firstNameField || new Ext.form.TextField({
+ fieldLabel: this.i18n.carnetDAdresses.firstNameField.fieldLabel,
+ name: 'prenom',
+ allowBlank:false
+ });
+
+ this.courrielField = this.courrielField || new Ext.form.TextField({
+ fieldLabel: this.i18n.carnetDAdresses.courrielField.fieldLabel,
+ name: 'email',
+ vtype:'email',
+ allowBlank:false
+ });
+
+ this.organisationField = this.organisationField || new Ext.form.TextField({
+ fieldLabel: this.i18n.carnetDAdresses.organisationField.fieldLabel,
+ name: 'organisation'
+ });
+
+
+ //2° onglet add contact popup
+ this.phoneField = this.phoneField || new Ext.form.TextField({
+ fieldLabel: this.i18n.carnetDAdresses.phoneField.fieldLabel,
+ name: 'phone'
+ });
+
+ this.mobileField = this.mobileField || new Ext.form.TextField({
+ fieldLabel: this.i18n.carnetDAdresses.mobileField.fieldLabel,
+ name: 'mobile'
+ });
+
+ this.faxField = this.faxField || new Ext.form.TextField({
+ fieldLabel: this.i18n.carnetDAdresses.faxField.fieldLabel,
+ name: 'fax'
+ });
+
+ this.addressField = this.addressField || new Ext.form.TextArea({
+ fieldLabel: this.i18n.carnetDAdresses.addressField.fieldLabel,
+ name: 'adresse'
+ });
+
+ this.cityField = this.cityField || new Ext.form.TextField({
+ fieldLabel: this.i18n.carnetDAdresses.cityField.fieldLabel,
+ name: 'ville'
+ });
+
+ this.postCodeField = this.postCodeField || new Ext.form.TextField({
+ fieldLabel: this.i18n.carnetDAdresses.postCodeField.fieldLabel,
+ name: 'codepostal'
+ });
+
+ //3° onglet add contact popup
+ this.noteField = this.noteField || new Ext.form.TextArea({
+ fieldLabel: this.i18n.carnetDAdresses.noteField.fieldLabel,
+ name: 'note',
+ xtype: 'textarea'
+ });
+
+ this.addContactWindowForm = this.addContactWindowForm || new Ext.FormPanel({
+ cls: 'addNewContactForm',
+ labelWidth: 75, // label settings here cascade unless overridden
+ bodyBorder: false,
+ border: false,
+ bodyStyle:'padding:5px 5px 0',
+ width: 380,
+ monitorValid:true,
+ items: {
+ xtype: 'tabpanel',
+ activeTab: 0,
+ defaults:{
+ autoHeight:true,
+ bodyStyle:'padding:10px'
+ },
+ items: [{
+ title:this.i18n.carnetDAdresses.addContactWindowForm.details.title,
+ layout: 'form',
+ defaults: {width: 230},
+ defaultType: 'textfield',
+ items: [this.nameField,
+ this.firstNameField,
+ this.courrielField,
+ this.organisationField]
+ }, {
+ title:this.i18n.carnetDAdresses.addContactWindowForm.tel.title,
+ layout: 'form',
+ defaults: {width: 230},
+ defaultType: 'textfield',
+ items: [this.phoneField,
+ this.mobileField,
+ this.faxField,
+ this.addressField,
+ this.cityField,
+ this.postCodeField]
+ }, {
+ title:this.i18n.carnetDAdresses.addContactWindowForm.note.title,
+ layout: 'form',
+ defaults: {width: 230},
+ defaultType: 'textfield',
+ items: this.noteField
+ }]
+ },
+ buttons: [this.addContactPopUpBtn,
+ this.cancelAddContactPopUpBtn]
+ });
+
+
+ this.addContactWindow = this.addContactWindow || new Ext.Window({
+ // applyTo:'addContactWindow-win',
+ title: "Ajouter un contact",
+ cls: "carnetDAdresses-portlet",
+ layout:'fit',
+ modal:true,
+ height: 350,
+ width: 380,
+ closeAction:'hide',
+ plain: true,
+ items: this.addContactWindowForm
+ });
+
+ //CONTACT DETAILS
+
+ this.contactId="";
+ this.contactType="";
+
+ this.contactInfosStore = new Ext.data.Store({
+ // load using HTTP
+ // url: this.renderURLAjax+"&jspPage=/contact_infos.jsp&contactId="+this.contactId+"&contactType="+this.contactType,
+
+ proxy: new Ext.data.HttpProxy({
+ url: this.renderURLAjax+"&jspPage=/contact_infos.jsp"
+ }),
+ // the return will be XML, so lets set up a reader
+ reader: new Ext.data.XmlReader({
+ record: "fiche",
+ id: "id"},
+ ["nom","prenom","email", "id","organisation","phone","mobile",
+ "fax", "adresse","ville","codepostal","note","relUserId","urlImage"]
+ )
+ });
+
+ this.editBBarBtn = this.editBBarBtn || new Ext.Button ({
+ tooltip: this.i18n.carnetDAdresses.editBBarBtn.tooltip,
+ iconCls: 'contact-edit',
+ disabled: true,
+ scope:this,
+ handler: this.onEditContactSwitch
+ });
+ this.modifyBBarBtn = this.modifyBBarBtn || new Ext.Button ({
+ text: this.i18n.carnetDAdresses.modifyBBarBtn.text,
+ handler: this.onEditContactAction,
+ formBind:true,
+ scope:this,
+ hidden: true
+ });
+ this.cancelBBarBtn = this.cancelBBarBtn || new Ext.Button ({
+ text: this.i18n.carnetDAdresses.cancelBBarBtn.text,
+ handler: this.onEditContactCancel,
+ scope:this,
+ hidden: true
+ });
+
+ //init le flag readonly à true
+ this.readOnly = true;
+
+//1° onglet display infos
+ this.imageThumbnail = this.imageThumbnail || new Ext.Panel({
+ html: '',
+ style: 'margin-left: 10px; margin-bottom: 15px;',
+ padding: 5,
+ hidden: true,
+ border: false,
+ width: 80
+ });
+
+ this.nomDisplayField = this.nomDisplayField || new Ext.form.TextField({
+ emptyText: this.i18n.carnetDAdresses.nomDisplayField.fieldLabel,
+ name:'nom',
+ hideLabel: true,
+ width: 185,
+ allowBlank:false,
+ disabled: true,
+ readOnly: true
+ });
+ this.prenomDisplayField = this.prenomDisplayField || new Ext.form.TextField({
+ emptyText: this.i18n.carnetDAdresses.prenomDisplayField.fieldLabel,
+ name:'prenom',
+ hideLabel: true,
+ width: 185,
+ allowBlank:false,
+ disabled: true,
+ readOnly: true
+ });
+ this.courrielDisplayField = this.courrielDisplayField ||new Ext.form.TextField({
+ emptyText: this.i18n.carnetDAdresses.courrielDisplayField.fieldLabel,
+ name:'email',
+ vtype: 'email',
+ hideLabel: true,
+ width: 185,
+ allowBlank:false,
+ disabled: true,
+ readOnly: true
+ });
+ this.orgaDisplayField = this.orgaDisplayField || new Ext.form.TextArea({
+ emptyText: this.i18n.carnetDAdresses.orgaDisplayField.fieldLabel,
+ name:'organisation',
+ hideLabel: true,
+ height: 150,
+ width: 185,
+ disabled: true,
+ readOnly: true,
+ autoScroll:true
+ });
+
+//2°onglet display infos
+ this.phoneDisplayField = this.phoneDisplayField || new Ext.form.TextField({
+ emptyText: this.i18n.carnetDAdresses.phoneDisplayField.fieldLabel,
+ name:'phone',
+ hideLabel: true,
+ width: 185,
+ disabled: true,
+ readOnly: true
+ });
+
+ this.mobileDisplayField = this.mobileDisplayField || new Ext.form.TextField({
+ emptyText: this.i18n.carnetDAdresses.mobileDisplayField.fieldLabel,
+ name:'mobile',
+ hideLabel: true,
+ width: 185,
+ disabled: true,
+ readOnly: true
+ });
+
+ this.faxDisplayField = this.faxDisplayField || new Ext.form.TextField({
+ emptyText: this.i18n.carnetDAdresses.faxDisplayField.fieldLabel,
+ name:'fax',
+ hideLabel: true,
+ width: 185,
+ disabled: true,
+ readOnly: true
+ });
+
+ this.addressDisplayField = this.addressDisplayField || new Ext.form.TextArea({
+ width: 185,
+ emptyText: this.i18n.carnetDAdresses.addressDisplayField.fieldLabel,
+ name:'adresse',
+ hideLabel: true,
+ disabled: true,
+ readOnly: true,
+ autoScroll:true
+ });
+
+ this.cityDisplayField = this.cityDisplayField || new Ext.form.TextField({
+ emptyText: this.i18n.carnetDAdresses.cityDisplayField.fieldLabel,
+ name:'ville',
+ hideLabel: true,
+ width: 185,
+ disabled: true,
+ readOnly: true
+ });
+
+ this.postCodeDisplayField = this.postCodeDisplayField || new Ext.form.TextField({
+ emptyText: this.i18n.carnetDAdresses.postCodeDisplayField.fieldLabel,
+ name:'codepostal',
+ hideLabel: true,
+ width: 185,
+ disabled: true,
+ readOnly: true
+ });
+
+//3° onglet
+ this.noteDisplayField = this.noteDisplayField || new Ext.form.TextArea({
+ width: 185,
+ height: 100,
+ emptyText: this.i18n.carnetDAdresses.noteDisplayField.fieldLabel,
+ name:'note',
+ hideLabel: true,
+ disabled: true,
+ readOnly: true,
+ autoScroll:true
+ });
+
+
+ this.showContactPanel = this.showContactPanel || new Ext.FormPanel({
+ labelWidth: 75,
+ layout: 'fit',
+ cls: "showContactPanel",
+ width: 250,
+ region: "east",
+ defaultType: 'textfield',
+ monitorValid:true,
+ items: {
+ xtype: 'tabpanel',
+ activeTab: 0,
+ plain: true,
+ defaults:{
+ height:420,
+ bodyStyle:'padding:10px'
+ },
+ items:[{
+ title: this.i18n.carnetDAdresses.showContactPanel.details.title,
+ layout: 'form',
+ width: 220,
+ items: [
+ this.imageThumbnail,
+ this.nomDisplayField ,
+ this.prenomDisplayField ,
+ this.courrielDisplayField,
+ this.orgaDisplayField
+ ]
+ }, {
+ title: this.i18n.carnetDAdresses.showContactPanel.tel.title,
+ layout: 'form',
+ width: 220,
+ items: [
+ this.phoneDisplayField,
+ this.mobileDisplayField,
+ this.faxDisplayField,
+ this.addressDisplayField,
+ this.cityDisplayField,
+ this.postCodeDisplayField
+ ]
+ }, {
+ title: this.i18n.carnetDAdresses.showContactPanel.note.title,
+ layout: 'form',
+ width: 220,
+ items: this.noteDisplayField
+ }]
+ },
+ bbar: {
+ width: 22,
+ items:[this.editBBarBtn,
+ '-',
+ '->',
+ this.modifyBBarBtn,
+ this.cancelBBarBtn]
+ }
+ });
+
+ //ENVOI DE MESSAGE
+ //fenetre de creation de new msg
+ this.createMessageWindow = this.createMessageWindow || new EntSavoie.InternalMessaging.CreateMessageView({
+ renderURLAjax: this.renderURLAjax,
+ actionURLAjax: this.actionURLAjax,
+ userGroupId: this.userGroupId,
+ closeActionWindow: 'hide',
+ sendToCasierBtnHide: true,
+ isGroupManagment: this.isGroupManagment,
+ hasDirectoryRights : this.hasDirectoryRights
+ });
+
+ this.sendFromType="";
+
+ this.htmlDestinataire = this.htmlDestinataire || new Ext.form.DisplayField({
+ style: 'color: #15428B; margin-top: 4px;',
+ value: this.i18n.carnetDAdresses.htmlDestinataire.value
+ });
+
+ this.sendMsgBtn = this.sendMsgBtn || new Ext.menu.Item ({
+ text: this.i18n.carnetDAdresses.sendMsgBtn.text.lists,
+ handler: this.onSendMessage,
+ iconCls: 'sendMsgBig',
+ scope: this
+ });
+
+ this.sendMenu = this.sendMenu || new Ext.menu.Menu({
+ cls: "carnetDAdresses-portlet",
+ items: [
+ this.sendMsgBtn,
+ {
+ handler: this.onSendVcard,
+ scope: this,
+ iconCls: "sendVcard",
+ text: this.i18n.carnetDAdresses.sendVcardBtn.text.contacts
+ }
+ ]
+ });
+
+ this.importWindow = this.importWindow || new EntSavoie.ImportVcardWindow({
+ actionURLAjax: this.actionURLAjax,
+ renderURLAjax: this.renderURLAjax
+ });
+
+ this.exportMenu = this.exportMenu || new Ext.menu.Menu({
+ cls: "carnetDAdresses-portlet",
+ items: [
+ {
+ text: this.i18n.carnetDAdresses.exportMenu.imp.text,
+ handler: this.onImport,
+ iconCls: 'import',
+ scope: this
+ },
+ {
+ text: this.i18n.carnetDAdresses.exportMenu.exp.text,
+ handler: this.onExport,
+ iconCls: 'export',
+ scope: this
+ }
+ ]
+ });
+
+ this.mainPanel = this.mainPanel || new Ext.Panel({
+ layout: "border",
+ region: "center",
+ border: false,
+ items: [
+ this._listes_grid,
+ this._content_grid,
+ this.showContactPanel
+ ],
+ bbar: [
+ {
+ text: this.i18n.carnetDAdresses.bbar.text,
+ menu: this.exportMenu,
+ style: "margin: 0px 5px 0px 5px;"
+ },
+ '-',
+ {
+ text: this.i18n.carnetDAdresses.bbar.SendMsgtext,
+ menu: this.sendMenu,
+ style: "margin: 0px 5px 0px 5px;"
+ }
+ ]
+ });
+
+ EntSavoie.carnetDAdresses.superclass.constructor.call(this, {
+ layout: "border",
+ border: false,
+ width: "auto",
+ monitorResize: true,
+ height: EntSavoie.FullScreen.fired()?EntSavoie.FullScreen.getContainerHeight():Global.Portlet.height,
+ items: [
+ this.mainPanel
+ ]
+ });
+
+ // definition des listeners
+ //Les listes
+ this._listes_store.on("load", this.onLoadListStore, this);
+ this._listes_store.proxy.on("beforeload", this.onBeforeloadListStoreProxy, this);
+ this.searchListFilter.on("valid", this.onValidSearchListFilter, this);
+ this._listes_grid.on("cellclick", this.onCellClickListGrid, this);
+
+ //les contacts
+ this._content_store.on("beforeload",this.onBeforeloadContentStore, this);
+ this._content_store.on("loadexception", this.onLoadexceptionContentStore, this);
+ this._content_store.on("load", this.onLoadContentStore, this);
+ this._content_store.proxy.on("beforeload", this.onBeforeloadContentStoreProxy, this);
+ this._content_grid.on("cellclick", this.onCellClickContact,this);
+ this.searchMemberFilter.on("valid", this.onValidSearchMemberFilter, this);
+
+ //les contacts details
+ this.contactInfosStore.on("load", this.onLoadContactInfosStore, this);
+ this.contactInfosStore.on("beforeload", this.onBeforeloadContactInfosStore, this);
+ this.contactInfosStore.proxy.on("beforeload", this.onBeforeloadContactInfosStoreProxy, this);
+
+ //Clic Droit
+ this._listes_grid.on("cellcontextmenu", this.onCellContextListGrid, this);
+ this._content_grid.on("cellcontextmenu", this.onCellContextContactGrid, this);
+
+};
+
+Ext.extend(EntSavoie.carnetDAdresses, Ext.Panel, {
+ initComponent: function () {
+ EntSavoie.carnetDAdresses.superclass.initComponent.call(this);
+ },
+
+ resetInteface : function() {
+ this.searchListFilter.reset();
+ this.searchMemberFilter.reset();
+ },
+
+ refreshInteface : function() {
+ this.resetInterface();
+ this._listes_store.load();
+ },
+
+ //LISTES
+ onLoadListStore: function(store, records, e){
+ var onload = Ext.getCmp(this._listes_grid.id);
+ if (onload){
+ onload.getEl().unmask();
+ }
+ if (records.length>0) {
+ if (this.currentSelectedList!=null) {
+ var recIndex = store.indexOfId(this.currentSelectedList.get("id"));
+ this._listes_grid.getSelectionModel().selectRow(recIndex);
+ }
+ }
+ if(this.userId>0){
+ this._content_store.load({params:{userId:this.userId}});
+ }
+ },
+
+ onBeforeloadListStoreProxy: function(proxy, params){
+ var onload = Ext.getCmp(this._listes_grid.id);
+ if (onload){
+ onload.getEl().mask(this.i18n.carnetDAdresses.mask, 'x-mask-loading');
+ }
+ if (this.searchListFilter!=null) {
+ params.recherche = this.searchListFilter.getValue();
+ } else {
+ params.recherche = "";
+ }
+ },
+
+ onValidSearchListFilter: function(textFieldObj){
+ if (this.searchListValue != textFieldObj.getValue()) {
+ this.searchListValue=textFieldObj.getValue();
+ this._listes_store.reload();
+ }
+ },
+
+ onRenderListGrid : function(grid){
+ this._listes_store.load();
+ // on rends la liste
+ var ddrow = new Ext.dd.DropTarget(this._listes_grid.getView().mainBody, {
+ scope: this,
+ ddGroup : 'addFicheToListe',
+ notifyDrop : function(dd, e, data){
+ var droppedFicheIds = new Array();
+ var droppedUserIds = new Array();
+ var droppedListes = new Array();
+
+ //regupere ou les contacts ont ete drag
+ var t = Ext.lib.Event.getTarget(e);
+ var rindex = this.scope._listes_grid.getView().findRowIndex(t);
+ var destId = this.scope._listes_store.getAt(rindex).get("listId");
+ var destType = this.scope._listes_store.getAt(rindex).get("type");
+ if (destType == "local") {
+ for (var i=0; i<data.selections.length; i++) {
+ if (data.selections[i].get("type") == "user") {
+ droppedUserIds.push(data.selections[i].get("id"));
+ }
+ if (data.selections[i].get("type") == "fiche") {
+ droppedFicheIds.push(data.selections[i].get("id"));
+ }
+ if (data.selections[i].get("type") == "local" || data.selections[i].get("type") == "search") {
+ var dropList = {};
+ dropList['listId'] = data.selections[i].get("listId");
+ dropList['orgId'] = data.selections[i].get("orgId");
+ dropList['roleId'] = data.selections[i].get("roleId");
+ dropList['type'] = data.selections[i].get("type");
+ dropList['parentList'] = data.selections[i].get("parentList");
+ dropList['childrenList'] = data.selections[i].get("childrenList");
+ droppedListes.push(dropList);
+ }
+ }
+ this.scope._addUsersToList(destId, droppedFicheIds, droppedUserIds, droppedListes);
+ return true;
+ }
+ return false;
+ },
+ notifyOver: function(dd, e, data) {
+ //regupere ou les contacts ont ete drag
+ try{
+ var t = Ext.lib.Event.getTarget(e);
+ var rindex = this.scope._listes_grid.getView().findRowIndex(t);
+ var destType = this.scope._listes_store.getAt(rindex).get("type");
+ if (destType == "local") {
+ return 'x-dd-drop-ok';
+ } else {
+ return "";
+ }
+ }
+ catch(err){
+ return "";
+ }
+ }
+ });
+ },
+
+
+
+ /**
+ * on select a cell in list grid
+ */
+ onCellClickListGrid : function(grid, rowIndex, colIndex, e){
+ var record = grid.getStore().getAt(rowIndex);
+
+ var entityArray = grid.getSelectionModel().getSelections();
+ var editable = false;
+
+ for (var i=0; i < entityArray.length; i++) {
+ if (!editable && entityArray[i].get("type") == "local") {
+ editable = true;
+ break;
+ }
+ }
+
+ this.deleteListBtn.setDisabled(!editable);
+
+ if (entityArray.length == 1) {
+ this.editListButton.setDisabled(!editable);
+ }
+ else {
+ this.editListButton.setDisabled(true);
+ }
+
+ this.currentSelectedContactRecord = null;
+ this.resetInterfaceContactDetails();
+ this._content_grid.getSelectionModel().clearSelections(true);
+
+ //on reset les params de la liste
+ this.listId = null;
+ this.orgId = null;
+ this.roleId = null;
+ this.type = null;
+ this.parentList = null;
+ this.childrenList = null;
+
+ this.load_liste_content(record);
+ this.refreshSender("list");
+
+// this.sendMsgBtn.enable();
+// this.sendVcardBtn.disable();
+ this.exportMenu.enable();
+ },
+
+
+ /**
+ * onAdd list
+ */
+ onAddList : function(btn) {
+ Ext.MessageBox.show({
+ title: this.i18n.carnetDAdresses.onAddList.title,
+ msg: this.i18n.carnetDAdresses.onAddList.msg,
+ buttons: {yes: this.i18n.carnetDAdresses.onAddList.buttons.yes, cancel: this.i18n.carnetDAdresses.onAddList.buttons.cancel},
+ fn: this.add_list_call,
+ prompt: true,
+ value: "Nouvelle Liste",
+ minWidth:250,
+ animEl: 'addListBtn',
+ scope: this
+ });
+
+ },
+
+ add_list_call : function(btn, listName) {
+ if (btn=="cancel") {
+ return false;
+ }
+
+ if(listName == ""){
+ this.onAddList();
+ return false;
+ }
+
+ this.wait = new Ext.LoadMask(Ext.getBody(), {msg: "Opération en cours. <br /> <b> Veuillez patienter ... </b>"});
+ this.wait.show();
+
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: "addList",
+ name: listName,
+ groupId: this.userGroupId
+ },
+ scope: this,
+ success: this.onSuccessAddList,
+ failure: this.onFailureAddList
+ });
+ },
+
+
+ onSuccessAddList: function(response, options) {
+ this.wait.hide();
+ /* Code verifiant le succes de la requete */
+ var backObj = Ext.decode(response.responseText);
+ if (!backObj.success) {
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onSuccessAddList.alert.title, this.i18n.carnetDAdresses.onSuccessAddList.alert.msg, function(btn){});
+ }
+ /* Code verifiant le succes de la requete */
+ else{
+
+ var newListRecord = new this.listeRecordCreator({ id:'local'+backObj.idList,
+ name: backObj.nameList,
+ type: 'local',
+ orgId: '',
+ roleId: '',
+ listId: backObj.idList,
+ parentList: '',
+ childrenList: '',
+ groupId: 10,
+ grouping: this.i18n.carnetDAdresses.grouping.perso
+ });
+ //this._listes_store.addSorted(newListRecord);
+ this._listes_store.reload();
+
+ Ext.slideMsg.msg(this.i18n.carnetDAdresses.onSuccessAddList.slideMsg.title, this.i18n.carnetDAdresses.onSuccessAddList.slideMsg.body[0] +backObj.nameList+ this.i18n.carnetDAdresses.onSuccessAddList.slideMsg.body[1]);
+ }
+ },
+
+ onFailureAddList: function(response, options) {
+ this.wait.hide();
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onFailureAddList.alert.title, this.i18n.carnetDAdresses.onFailureAddList.alert.msg, function(btn){});
+ },
+
+
+ /**
+ * onDelete list
+ */
+ onDeleteList : function(btn) {
+ var recArray = this._listes_grid.getSelectionModel().getSelections();
+ if (recArray.length==0) {
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onDeleteList.length.alert.title, this.i18n.carnetDAdresses.onDeleteList.length.alert.msg, function(btn){});
+ return false;
+ }
+
+ var listIds = [];
+ var recs = [];
+ var i = 0;
+ for (i = 0 ; i < recArray.length ;i++) {
+ var idL = recArray[i].get("id");
+ var typeL = recArray[i].get("type");
+ if (typeL == "local") {
+ listIds.push(idL);
+ recs.push(recArray[i]);
+ }
+ }
+
+ if (listIds.length==0) {
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onDeleteList.nolist.alert.title, this.i18n.carnetDAdresses.onDeleteList.nolist.alert.msg, function(btn){});
+ return false;
+ }
+
+ this.listToDelete = listIds;
+ this.recsToDelete = recs;
+
+ Ext.MessageBox.show({
+ title: this.i18n.carnetDAdresses.onDeleteList.messageBox.title,
+ msg: this.i18n.carnetDAdresses.onDeleteList.messageBox.msg,
+ buttons: {yes:this.i18n.carnetDAdresses.onDeleteList.messageBox.buttons.yes, no:this.i18n.carnetDAdresses.onDeleteList.messageBox.buttons.no},
+ fn: this.remove_list_call,
+ animEl: 'confirmBtn',
+ icon: Ext.MessageBox.QUESTION,
+ scope:this
+ });
+
+
+ },
+
+ remove_list_call : function(btn) {
+ if(btn=="no") {
+ return false;
+ }
+ else if(btn!="yes"){
+ this.listToDelete = null;
+ this.recsToDelete = null;
+ }
+
+ this.wait = new Ext.LoadMask(Ext.getBody(), {msg: "Opération en cours. <br /> <b> Veuillez patienter ... </b>"});
+ this.wait.show();
+
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: "delList",
+ listIds: this.listToDelete,
+ },
+ scope:this,
+ success: this.onSuccessDelList,
+ failure: this.onFailureDelList
+ });
+ },
+
+ onSuccessDelList:function(response, options) {
+ this.wait.hide();
+ /* Code verifiant le succes de la requete */
+ var backObj = Ext.decode(response.responseText);
+ if (!backObj.success) {
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onSuccessDelList.alert.title, this.i18n.carnetDAdresses.onSuccessDelList.alert.msg, function(btn){});
+ }
+ /* Code verifiant le succes de la requete */
+ else{
+ //var recArray = this._listes_grid.getSelectionModel().getSelections();
+ this._listes_store.remove(this.recsToDelete);
+
+ this.currentSelectedList = null;
+ this.listToDelete = null;
+ this.recsToDelete = null;
+
+ this.resetInterfaceContactDetails();
+
+ this._content_store.removeAll();
+ Ext.slideMsg.msg(this.i18n.carnetDAdresses.onSuccessDelList.slideMsg.title, this.i18n.carnetDAdresses.onSuccessDelList.slideMsg.body);
+ }
+ },
+
+ onFailureDelList:function(response, options) {
+ this.wait.hide();
+ this.listToDelete = null;
+ this.recsToDelete = null;
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onFailureDelList.alert.title, this.i18n.carnetDAdresses.onFailureDelList.alert.msg, function(btn){});
+ },
+
+
+
+ /**
+ * onEdit list
+ */
+ onEditList: function(btn){
+ var recArray = this._listes_grid.getSelectionModel().getSelections();
+ if (recArray.length==0) {
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onEditList.length.alert.title, this.i18n.carnetDAdresses.onEditList.length.alert.msg, function(btn){});
+ return false;
+ }
+
+ this.currentSelectedList = recArray[0];
+ if (recArray.length>1) {
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onEditList.alert.title, this.i18n.carnetDAdresses.onEditList.alert.msg, function(btn){});
+ return false;
+ }
+
+ Ext.MessageBox.show({
+ title: this.i18n.carnetDAdresses.onEditList.messageBox.title,
+ msg: this.i18n.carnetDAdresses.onEditList.messageBox.msg,
+ value: this.currentSelectedList.get("name"),
+ buttons: {yes: this.i18n.carnetDAdresses.onEditList.messageBox.buttons.yes, cancel: this.i18n.carnetDAdresses.onEditList.messageBox.buttons.cancel},
+ fn: this.onRenameList,
+ prompt: true,
+ minWidth:250,
+ scope: this
+ });
+ },
+
+ onRenameList : function(btn, listName) {
+ if (btn=="cancel") {
+ return false;
+ }
+
+ if(listName == ""){
+ this.onEditList();
+ return false;
+ }
+
+ this.wait = new Ext.LoadMask(Ext.getBody(), {msg: "Opération en cours. <br /> <b> Veuillez patienter ... </b>"});
+ this.wait.show();
+
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: "editList",
+ listName: listName,
+ listId: this.currentSelectedList.get("listId")
+ },
+ scope: this,
+ success: this.onSuccessRenameList,
+ failure: this.onFailureRenameList
+ });
+ },
+
+ onSuccessRenameList:function(response, options) {
+ this.wait.hide();
+ var backObj = Ext.decode(response.responseText);
+ if (!backObj.success) {
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onSuccessRenameList.alert.title, this.i18n.carnetDAdresses.onSuccessRenameList.alert.msg, function(btn){});
+ }
+ else {
+
+ var list = backObj.list;
+ var recordL = this.currentSelectedList;
+ recordL.set("name", list.name);
+ Ext.slideMsg.msg(this.i18n.carnetDAdresses.onSuccessRenameList.slideMsg.title, this.i18n.carnetDAdresses.onSuccessRenameList.slideMsg.body);
+ }
+ },
+
+ onFailureRenameList:function(XMLHttpRequest, textStatus, errorThrown) {
+ this.wait.hide();
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onFailureRenameList.alert.title, this.i18n.carnetDAdresses.onFailureRenameList.alert.msg, function(btn){});
+ },
+
+
+ //CONTACTS
+
+ onBeforeloadContentStore: function(store, options){
+ var onload = Ext.getCmp(this._content_grid.id);
+ if (onload){
+ onload.getEl().mask(this.i18n.carnetDAdresses.mask, 'x-mask-loading');
+ }
+
+ },
+
+ onLoadexceptionContentStore: function(misc){
+ var onload = Ext.getCmp(this._content_grid.id);
+ if (onload){
+ onload.getEl().unmask();
+ }
+ },
+
+ onLoadContentStore: function(store, records, e){
+ var onload = Ext.getCmp(this._content_grid.id);
+ if (onload){
+ onload.getEl().unmask();
+ }
+
+ if (records.length>0) {
+ if (this.currentSelectedContactRecord!=null) {
+ var recIndex = store.indexOfId(this.currentSelectedContactRecord.get("id"));
+ this._content_grid.getSelectionModel().selectRow(recIndex);
+ }
+ }
+
+ if(this.userId>0){
+ var recIndex = store.indexOfId(this.userId);
+ this._content_grid.getSelectionModel().selectRow(recIndex);
+ this._content_grid.fireEvent("cellclick", this._content_grid, recIndex, 0, null);
+ this.userId = 0;
+ }
+ },
+
+ onBeforeloadContentStoreProxy: function(proxy, params){
+ if (this.searchMemberFilter!=null) {
+ params.recherche = this.searchMemberFilter.getValue();
+ } else {
+ params.recherche = "";
+ }
+
+ //on set les params
+ params.listId = this.listId;
+ params.orgId = this.orgId;
+ params.roleId = this.roleId;
+ params.type = this.type;
+ params.parentList = this.parentList;
+ params.childrenList = this.childrenList;
+ },
+
+
+ load_liste_content : function(listRecord) {
+ this.currentSelectedList = listRecord;
+ this.listId = listRecord.get("listId");
+ this.orgId = listRecord.get("orgId");
+ this.roleId = listRecord.get("roleId");
+ this.type = listRecord.get("type");
+ this.parentList = listRecord.get("parentList");
+ this.childrenList = listRecord.get("childrenList");
+
+ this._content_store.load({params:{start:0, limit:35}});
+
+ // on active ou non les controles
+ if (this.type == "search" || this.type == "all" || this.type == "inst"
+ || this.type == "perso" || this.type == "allAmis") {
+ this.addContactButton.disable();
+ this.removeContactButton.disable();
+ }
+ else {
+ this.addContactButton.enable();
+ this.removeContactButton.enable();
+ }
+ },
+
+
+ onCellClickContact : function(grid, rowIndex, colIndex, e){
+ var record = grid.getStore().getAt(rowIndex);
+ if (record!=null) {
+ this.load_contact_detail(record.get("id"), record.get("type"));
+ this.refreshSender("contact");
+ }
+
+ var recDestArray = this._content_grid.getSelectionModel().getSelections();
+// if (recDestArray.length == 1) {
+// if (recDestArray[0].get("type") == "local" && recDestArray[0].get("relUserId")==0) {
+// this.sendMsgBtn.disable();
+// this.sendVcardBtn.disable();
+// }
+// else {
+// this.sendMsgBtn.enable();
+// this.sendVcardBtn.enable();
+// }
+// }
+// else {
+// this.sendMsgBtn.enable();
+// this.sendVcardBtn.enable();
+// }
+
+ this.exportMenu.enable();
+ },
+
+ onValidSearchMemberFilter: function(tf){
+ if (this.memberPaggingTB!=null && this.searchMemberValue != tf.getValue()) {
+ this.searchMemberValue=tf.getValue();
+ tf.suspendEvents(false);
+ this.memberPaggingTB.moveFirst();
+ tf.resumeEvents();
+ }
+ },
+
+ onRenderContentGrid: function(grid){
+ //scope: this;
+ grid.getView().dragZone.onBeforeDrag = function(data, e) {
+ // on authorise maintenant le drag sur les entree de type user
+ // --> dans le cas d'une dépose sur une liste perso --> creation d'un contact perso avec relUserId
+ return true;
+ /*
+ var t = Ext.lib.Event.getTarget(e);
+ var rindex = this.scope._content_grid.getView().findRowIndex(t);
+ var typeRec = this.scope._content_grid.getStore().getAt(rindex).get("type");
+ if (typeRec == "fiche") {
+ return true;
+ } else {
+ return false;
+ }
+ */
+ };
+ },
+
+ /**
+ * onAdd contact
+ */
+ onAddContact : function(btn) {
+ this.addContactWindowForm.getForm().reset();
+ this.addContactWindow.show(this);
+ //return false;
+ },
+
+ onAddContactAction : function() {
+
+ this.wait = new Ext.LoadMask(Ext.getBody(), {msg: "Opération en cours. <br /> <b> Veuillez patienter ... </b>"});
+ this.wait.show();
+
+ this.addContactWindowForm.getForm().submit({
+ url:this.actionURLAjax,
+ params:{
+ cmd:'addContact',
+ groupId: this.userGroupId,
+ listId: this.currentSelectedList?this.currentSelectedList.get("listId"):0
+ },
+ waitMsg: this.i18n.carnetDAdresses.onAddContactAction.waitMsg,
+ scope:this,
+ success:this.onSuccessAddContact,
+ failure:this.onFailureAddContact
+ });
+ },
+
+ onSuccessAddContact:function(form, action) {
+ this.wait.hide();
+ this.addContactWindow.hide();
+ /* Code verifiant le succes de la requete */
+ if (!action.result.success) {
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onSuccessAddContact.alert.title, this.i18n.carnetDAdresses.onSuccessAddContact.alert.msg, function(btn){});
+ }
+ /* Code verifiant le succes de la requete */
+ else{
+ if (this.currentSelectedList) {
+ var newContactRecord = new this.contactRecordCreator({
+ nom: action.result.nom,
+ prenom: action.result.prenom,
+ statut: action.result.statut,
+ id:action.result.id,
+ type:action.result.type,
+ relUserId: ""
+ });
+ this._content_store.addSorted(newContactRecord);
+ }
+ Ext.slideMsg.msg(this.i18n.carnetDAdresses.onSuccessAddContact.slideMsg.title, this.i18n.carnetDAdresses.onSuccessAddContact.slideMsg.body);
+ }
+ },
+
+ onFailureAddContact:function(form, action) {
+ this.wait.hide();
+ this.addContactWindow.hide();
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onFailureAddContact.alert.title, this.i18n.carnetDAdresses.onFailureAddContact.alert.msg, function(btn){});
+ },
+
+ onAddContactCancel : function() {
+ this.addContactWindow.hide();
+ },
+
+
+ /**
+ * onDelete contact
+ */
+ onDeleteContact : function(btn) {
+ var recContactArray = this._content_grid.getSelectionModel().getSelections();
+ if (recContactArray.length==0) {
+ return false;
+ }
+
+ Ext.MessageBox.show({
+ title: this.i18n.carnetDAdresses.onDeleteContact.messageBox.title,
+ msg: this.i18n.carnetDAdresses.onDeleteContact.messageBox.msg,
+ buttons: {yes: this.i18n.carnetDAdresses.onDeleteContact.messageBox.buttons.yes, no: this.i18n.carnetDAdresses.onDeleteContact.messageBox.buttons.no},
+ fn: this.remove_contact_call,
+ animEl: 'confirmBtnDeleteContact',
+ icon: Ext.MessageBox.QUESTION,
+ scope:this
+ });
+
+ },
+
+ remove_contact_call : function(btn) {
+ if (btn=="no") {
+ return;
+ }
+ var recContactArray = this._content_grid.getSelectionModel().getSelections();
+
+ var contactIds = [];
+ var i = 0;
+ for (i = 0 ; i < recContactArray.length ;i++) {
+ contactIds.push(recContactArray[i].get("id"));
+ }
+
+ this._content_store.remove(recContactArray);
+
+ if (btn=="yes") {
+
+ this.wait = new Ext.LoadMask(Ext.getBody(), {msg: "Opération en cours. <br /> <b> Veuillez patienter ... </b>"});
+ this.wait.show();
+
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: "removeContact",
+ listId: this.currentSelectedList.get("listId"),
+ contactIds: contactIds
+ },
+ scope:this,
+ success: this.onSuccessDelContact,
+ failure:this.onFailureDelContact
+ });
+
+ }
+ else {
+ return false;
+ }
+
+ },
+
+ onSuccessDelContact:function(response, options) {
+ this.wait.hide();
+ /* Code verifiant le succes de la requete */
+ var backObj = Ext.decode(response.responseText);
+ if (!backObj.success) {
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onSuccessDelContact.alert.title, this.i18n.carnetDAdresses.onSuccessDelContact.alert.msg, function(btn){});
+ }
+ /* Code verifiant le succes de la requete */
+ else{
+ this.currentSelectedContactRecord = null;
+ this.resetInterfaceContactDetails();
+ Ext.slideMsg.msg(this.i18n.carnetDAdresses.onSuccessDelContact.slideMsg.title, this.i18n.carnetDAdresses.onSuccessDelContact.slideMsg.body);
+ }
+ },
+
+ onFailureDelContact:function(response, options) {
+ this.wait.hide();
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onFailureDelContact.alert.title, this.i18n.carnetDAdresses.onFailureDelContact.alert.msg, function(btn){});
+ },
+
+
+
+ /*will add users to a list*/
+ _addUsersToList : function(listId, ficheIds, userIds, droppedListes) {
+ //Traite le cas des pseudo listes
+ if (listId == "perso" || listId == "inst" || listId == "all") {
+ return;
+ }
+ //Gere le cas ss utilisateurs
+ if (userIds.length==0 && ficheIds.length==0 && droppedListes.length==0) {
+ return;
+ }
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: "countNewListSize",
+ listId: listId,
+ ficheIds: ficheIds,
+ listesObj: Ext.encode(droppedListes),
+ userIds: userIds
+ },
+ scope: this,
+ success: this.onSuccessCountNewListSize,
+ failure: this.onFailureCountNewListSize
+ });
+ },
+
+
+ onSuccessCountNewListSize: function(response, options){
+ var backObj = Ext.decode(response.responseText);
+ if (backObj.success) {
+ console.log(backObj.size);
+ if( (backObj.size >= this.COUNT_FOR_LIST_WARNING) && (options.params.listesObj != '[]') ){
+ Ext.MessageBox.show({
+ title: this.i18n.carnetDAdresses.onCountList.title,
+ msg: this.i18n.carnetDAdresses.onCountList.msg,
+ buttons: {yes: this.i18n.carnetDAdresses.onCountList.btn.yes, cancel: this.i18n.carnetDAdresses.onCountList.btn.cancel},
+ scope: this,
+ fn: this.decisionAddListCall,
+ //prompt: true,
+ minWidth:250,
+ closable: false,
+ params : options.params
+ });
+ }
+ else{
+ this.wait = new Ext.LoadMask(Ext.getBody(), {msg: "Opération en cours. <br /> <b> Veuillez patienter ... </b>"});
+ this.wait.show();
+
+ // on doit maintenant gerer le soucis
+ console.log("add");
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: "addUsersToList",
+ listId: options.params.listId,
+ ficheIds: options.params.ficheIds,
+ listesObj: options.params.listesObj,
+ userIds: options.params.userIds
+ },
+ scope: this,
+ success: this.onSuccessAddUserList,
+ failure: this.onFailureAddUserList
+ });
+ }
+ }
+ },
+
+
+ decisionAddListCall: function(btn){
+ if (btn == 'cancel') {
+ return;
+ }
+ else{
+ this.wait = new Ext.LoadMask(Ext.getBody(), {msg: "Opération en cours. <br /> <b> Veuillez patienter ... </b>"});
+ this.wait.show();
+
+ // on doit maintenant gerer le soucis
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: "addUsersToList",
+ listId: arguments[2].params.listId,
+ ficheIds: arguments[2].params.ficheIds,
+ listesObj: arguments[2].params.listesObj,
+ userIds: arguments[2].params.userIds
+ },
+ scope: this,
+ success: this.onSuccessAddUserList,
+ failure: this.onFailureAddUserList
+ });
+ }
+ },
+
+ onFailureCountNewListSize: function(response, options){
+ },
+
+ onSuccessAddUserList: function(response, options){
+ this.wait.hide();
+ /* Code verifiant le succes de la requete */
+ var backObj = Ext.decode(response.responseText);
+ if (!backObj.success) {
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onSuccessAddUserList.alert.title, this.i18n.carnetDAdresses.onSuccessAddUserList.alert.msg, function(btn){});
+ }
+ /* Code verifiant le succes de la requete */
+ else{
+ Ext.slideMsg.msg(this.i18n.carnetDAdresses.onSuccessAddUserList.slideMsg.title, this.i18n.carnetDAdresses.onSuccessAddUserList.slideMsg.body);
+ }
+ },
+
+ onFailureAddUserList: function(response, options){
+ this.wait.hide();
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onFailureAddUserList.alert.title, this.i18n.carnetDAdresses.onFailureAddUserList.alert.msg, function(btn){});
+ },
+
+ //LES CONTACTS DETAILS
+ resetInterfaceContactDetails: function(){
+ //on reset les fields
+ this.nomDisplayField.reset();
+ this.prenomDisplayField.reset();
+ this.courrielDisplayField.reset();
+ this.orgaDisplayField.reset();
+ this.phoneDisplayField.reset();
+ this.mobileDisplayField.reset();
+ this.faxDisplayField.reset();
+ this.addressDisplayField.reset();
+ this.cityDisplayField.reset();
+ this.postCodeDisplayField.reset();
+ this.noteDisplayField.reset();
+ this.imageThumbnail.getEl().dom.innerHTML = "";
+ this.imageThumbnail.hide();
+
+ this.disableContactInfosFields();
+ this.setReadOnlyContactInfosFields(true);
+
+ //on passe en readonly
+ this.readOnly= true;
+
+ //on cache tous les btn
+ this.editBBarBtn.setTooltip(this.i18n.carnetDAdresses.editBBarBtn.impossible);
+ this.editBBarBtn.disable();
+ this.modifyBBarBtn.hide();
+ this.cancelBBarBtn.hide();
+
+ //on vide les données du contact sélectionné
+ this.contactId = null;
+ this.contactType = null;
+ },
+
+
+ load_contact_detail: function(contactId, contactType) {
+ this.contactId = contactId;
+ this.contactType = contactType;
+ this.readOnly=true;
+
+ this.contactInfosStore.load();
+ },
+
+ onBeforeloadContactInfosStore: function(store, options){
+ var onload = Ext.getCmp(this.showContactPanel.id);
+ if (onload){
+ onload.getEl().mask(this.i18n.carnetDAdresses.mask, 'x-mask-loading');
+ }
+
+ },
+
+ onBeforeloadContactInfosStoreProxy: function(proxy, params){
+ params.contactId=this.contactId;
+ params.contactType=this.contactType;
+ },
+
+
+ onLoadContactInfosStore: function(store, records, e){
+ var onload = Ext.getCmp(this.showContactPanel.id);
+ if (onload){
+ onload.getEl().unmask();
+ }
+
+ if (records.length>0) {
+ this.currentSelectedContactRecord=records[0];
+
+ //on set les valeurs des champs
+ //Setter l'image de la personne si ok
+ this.nomDisplayField.setValue(this.currentSelectedContactRecord.get("nom"));
+ this.prenomDisplayField.setValue(this.currentSelectedContactRecord.get("prenom"));
+ this.courrielDisplayField.setValue(this.currentSelectedContactRecord.get("email"));
+ this.orgaDisplayField.setValue(this.currentSelectedContactRecord.get("organisation"));
+ this.phoneDisplayField.setValue(this.currentSelectedContactRecord.get("phone"));
+ this.mobileDisplayField.setValue(this.currentSelectedContactRecord.get("mobile"));
+ this.faxDisplayField.setValue(this.currentSelectedContactRecord.get("fax"));
+ this.addressDisplayField.setValue(this.currentSelectedContactRecord.get("adresse"));
+ this.cityDisplayField.setValue(this.currentSelectedContactRecord.get("ville"));
+ this.postCodeDisplayField.setValue(this.currentSelectedContactRecord.get("codepostal"));
+ this.noteDisplayField.setValue(this.currentSelectedContactRecord.get("note"));
+ if(this.currentSelectedContactRecord.get("urlImage")){
+ this.imageThumbnail.show();
+ this.imageThumbnail.getEl().dom.innerHTML = "<img border='no' src='" +this.currentSelectedContactRecord.get("urlImage")+"' height='60px' width='60px' />";
+ } else {
+ this.imageThumbnail.hide();
+ this.imageThumbnail.getEl().dom.innerHTML = "";
+ }
+
+
+ this.drawInterfaceFromModeChoice();
+
+ }
+ else {
+ //this.showContactPanel.removeAll();
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onLoadContactInfosStore.alert.title, this.i18n.carnetDAdresses.onLoadContactInfosStore.alert.msg, function(btn){});
+ this.resetInterfaceContactDetails();
+ }
+
+
+ },
+
+ disableContactInfosFields: function(){
+ //disable tous les fields => display only
+ this.nomDisplayField.disable();
+ this.prenomDisplayField.disable();
+ this.courrielDisplayField.disable();
+ this.orgaDisplayField.disable();
+ this.phoneDisplayField.disable();
+ this.mobileDisplayField.disable();
+ this.faxDisplayField.disable();
+ this.addressDisplayField.disable();
+ this.cityDisplayField.disable();
+ this.postCodeDisplayField.disable();
+ this.noteDisplayField.disable();
+ },
+
+ enableContactInfosFields: function(){
+ //enable tous les fields
+ this.nomDisplayField.enable();
+ this.prenomDisplayField.enable();
+ this.courrielDisplayField.enable();
+ this.orgaDisplayField.enable();
+ this.phoneDisplayField.enable();
+ this.mobileDisplayField.enable();
+ this.faxDisplayField.enable();
+ this.addressDisplayField.enable();
+ this.cityDisplayField.enable();
+ this.postCodeDisplayField.enable();
+ this.noteDisplayField.enable();
+ },
+
+ setReadOnlyContactInfosFields: function(readOnly){
+ //disable tous les fields => display only
+ this.nomDisplayField.setReadOnly(readOnly);
+ this.prenomDisplayField.setReadOnly(readOnly);
+ this.courrielDisplayField.setReadOnly(readOnly);
+ this.orgaDisplayField.setReadOnly(readOnly);
+ this.phoneDisplayField.setReadOnly(readOnly);
+ this.mobileDisplayField.setReadOnly(readOnly);
+ this.faxDisplayField.setReadOnly(readOnly);
+ this.addressDisplayField.setReadOnly(readOnly);
+ this.cityDisplayField.setReadOnly(readOnly);
+ this.postCodeDisplayField.setReadOnly(readOnly);
+ this.noteDisplayField.setReadOnly(readOnly);
+ },
+
+ drawInterfaceFromModeChoice: function(){
+ //on est en readonly sur un contact de l'annuaire
+ if (this.readOnly && this.currentSelectedContactRecord.get("relUserId")!=0) {
+
+ //(on ne peut donc pas activer l'edition)
+ this.editBBarBtn.setTooltip(this.i18n.carnetDAdresses.editBBarBtn.impossible);
+ this.editBBarBtn.disable();
+ //on hide les boutons relatifs à l'edition
+ this.modifyBBarBtn.hide();
+ this.cancelBBarBtn.hide();
+ //on show la BBAr
+ this.showContactPanel.getBottomToolbar().doLayout();
+ //disable tous les fields => display only
+ this.enableContactInfosFields();
+ this.setReadOnlyContactInfosFields(true);
+
+ //on est en read nly sur un contact perso
+ }else if (this.readOnly && this.currentSelectedContactRecord.get("relUserId")==0){
+
+ //(on peut donc activer l'edition)
+ this.editBBarBtn.setTooltip(this.i18n.carnetDAdresses.editBBarBtn.tooltip);
+ this.editBBarBtn.enable();
+ //on hide les boutons relatifs à l'edition
+ this.modifyBBarBtn.hide();
+ this.cancelBBarBtn.hide();
+ //on show la BBAr
+ this.showContactPanel.getBottomToolbar().doLayout();
+ //disable tous les fields => display only
+ this.enableContactInfosFields();
+ this.setReadOnlyContactInfosFields(true);
+
+ //on est en mode edition
+ }else if (!this.readOnly){
+
+ //on disable le bouton d'activation du mode edition
+ this.editBBarBtn.setTooltip(this.i18n.carnetDAdresses.editBBarBtn.impossible);
+ this.editBBarBtn.disable();
+ //on show les boutons relatifs à l'edition
+ this.modifyBBarBtn.show();
+ this.cancelBBarBtn.show();
+ //on show la BBAr
+ this.showContactPanel.getBottomToolbar().doLayout();
+ //enable tous les fields
+ this.enableContactInfosFields();
+ this.setReadOnlyContactInfosFields(false);
+ }
+ },
+
+ onEditContactSwitch : function(btn) {
+ this.readOnly=false;
+ this.setReadOnlyContactInfosFields(false);
+ this.contactInfosStore.load();
+ },
+
+ onEditContactCancel : function(btn) {
+ this.readOnly=true;
+ this.contactInfosStore.load();
+ },
+
+ onEditContactAction : function(btn) {
+
+ if (this.nomDisplayField.validate() && this.prenomDisplayField.validate() && this.courrielDisplayField.validate()) {
+
+ this.wait = new Ext.LoadMask(Ext.getBody(), {msg: "Opération en cours. <br /> <b> Veuillez patienter ... </b>"});
+ this.wait.show();
+
+ this.showContactPanel.getForm().submit({
+ url:this.actionURLAjax
+ ,scope:this
+ ,success:this.onSuccessEditContact
+ ,failure:this.onFailureEditContact
+ ,params:{
+ cmd:'editContact',
+ groupId: this.userGroupId,
+ contactId: this.contactId
+ }
+ ,waitMsg: this.i18n.carnetDAdresses.onEditContactAction.waitMsg
+ });
+ }
+
+ },
+
+ onSuccessEditContact:function(form, action) {
+ this.wait.hide();
+ /* Code verifiant le succes de la requete */
+ if (!action.result.success) {
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onSuccessEditContact.alert.title, this.i18n.carnetDAdresses.onSuccessEditContact.alert.msg, function(btn){});
+ //this.load_contact_detail(this.currentSelectedContactRecord.get("id"),this.currentSelectedContactRecord.get("type"));
+ }
+ /* Code verifiant le succes de la requete */
+ else{
+ Ext.slideMsg.msg(this.i18n.carnetDAdresses.onSuccessEditContact.slideMsg.title, this.i18n.carnetDAdresses.onSuccessEditContact.slideMsg.body);
+ }
+ var nom = this.nomDisplayField.getValue();
+ var prenom = this.prenomDisplayField.getValue();
+ this._content_store.getById(this.contactId).set('nom', nom);
+ this._content_store.getById(this.contactId).set('prenom', prenom);
+
+ this.readOnly=true;
+ this.contactInfosStore.load();
+ },
+
+ onFailureEditContact:function(form, action) {
+ this.wait.hide();
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onFailureEditContact.alert.title, this.i18n.carnetDAdresses.onSuccessEditContact.alert.msg, function(btn){});
+ this.readOnly=true;
+ this.contactInfosStore.load();
+ },
+
+ //L'ENVOIE DE MESSAGE
+ refreshSender: function(type){
+ this.sendFromType=type;
+
+ if (type =="contact"){
+ this.sendMsgBtn.setText(this.i18n.carnetDAdresses.sendMsgBtn.text.contacts);
+// this.sendVcardBtn.setText(this.i18n.carnetDAdresses.sendVcardBtn.text.contacts);
+ }
+ else{
+ this.sendMsgBtn.setText(this.i18n.carnetDAdresses.sendMsgBtn.text.lists);
+ }
+ this.htmlDestinataire.hide();
+// this.sendMsgBtn.enable();
+// this.sendVcardBtn.disable();
+ this.exportMenu.enable();
+ },
+
+ onImport: function() {
+ this.importWindow.show();
+ this.importWindow.resetInterface();
+ },
+
+
+ onExport: function(btn){
+
+ if (this._content_grid.getSelectionModel().getSelections().length > 0 || this._listes_grid.getSelectionModel().getSelections().length > 0) {
+ var currentDate = new Date();
+ var month = currentDate.getMonth() + 1;
+ var day = currentDate.getDate();
+ var year = currentDate.getFullYear();
+
+ var valueField = this.i18n.carnetDAdresses.onExport.valueField + " " + day + "-" + month + "-" + year;
+
+ Ext.MessageBox.show({
+ title: this.i18n.carnetDAdresses.onExport.messageBox.title,
+ msg: this.i18n.carnetDAdresses.onExport.messageBox.msg,
+ buttons: {yes: this.i18n.carnetDAdresses.onExport.messageBox.buttons.yes, cancel: this.i18n.carnetDAdresses.onExport.messageBox.buttons.cancel},
+ value: valueField,
+ fn: this.onExport_call,
+ prompt: true,
+ minWidth:300,
+ animEl: 'exportBtn',
+ scope: this
+ });
+ }
+ else {
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onExport.alert.title, this.i18n.carnetDAdresses.onExport.alert.msg, function(btn){});
+ }
+ },
+
+ onExport_call: function(btn, fileName) {
+ if (btn=="cancel") {
+ return false;
+ }
+
+ if (!this.wait) {
+ this.wait = new Ext.LoadMask(Ext.getBody(), {msg: this.i18n.carnetDAdresses.onExport_call.wait.msg});
+ }
+ this.wait.show();
+
+ var arrayExport = [];
+
+ if (this.sendFromType =="contact"){
+ var recArray = this._content_grid.getSelectionModel().getSelections();
+ for (var i=0; i<recArray.length; i++){
+ //on ne prend que les contact de l'annuaire
+
+ if (recArray[i].get("type")=="user" || recArray[i].get("type")=="fiche"){
+ var idRec = recArray[i].get("id");
+ var val = {
+ type: recArray[i].get("type"),
+ userId: idRec
+ };
+ arrayExport.push(val);
+ }
+ else{
+ if(recArray[i].get("relUserId")!= 0 && recArray[i].get("relUserId")!=""){
+ var idRec = recArray[i].get("relUserId");
+ var val = {
+ type: recArray[i].get("type"),
+ userId: idRec
+ };
+ arrayExport.push(val);
+ }
+ }
+ }
+ }
+ else{
+ var recArray = this._listes_grid.getSelectionModel().getSelections();
+ //cas des listes
+ for (i=0; i<recArray.length; i++){
+ var list = recArray[i];
+ var val = {
+ type: list.get("type"),
+ orgId: list.get("orgId"),
+ roleId: list.get("roleId"),
+ listId: list.get("listId"),
+ parentList: list.get("parentList"),
+ childrenList: list.get("childrenList")
+ };
+ arrayExport.push(val);
+ }
+ }
+
+
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: "exportVCARD",
+ listArray: Ext.util.JSON.encode(arrayExport),
+ name: fileName
+ },
+ scope: this,
+ success: this.onSuccessExportVCARD,
+ failure: this.onFailureExportVCARD
+ });
+
+ },
+
+ onSuccessExportVCARD: function(response, options){
+ // Traitement des messages
+ var backObj = Ext.decode(response.responseText);
+ this.wait.hide();
+ if (!backObj.success) {
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onSuccessExportVCARD.alert.title, this.i18n.carnetDAdresses.onSuccessExportVCARD.alert.msg, function(btn){});
+ } else {
+ Ext.MessageBox.show({
+ title: this.i18n.carnetDAdresses.onSuccessExportVCARD.messageBox.title,
+ msg: backObj.msg,
+ icon: Ext.MessageBox.INFO,
+ buttons: {yes: this.i18n.carnetDAdresses.onSuccessExportVCARD.messageBox.yes},
+ minWidth: 350
+ });
+ }
+ },
+
+ onFailureExportVCARD: function(response, options){
+ this.wait.hide();
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onFailureExportVCARD.alert.title, this.i18n.carnetDAdresses.onFailureExportVCARD.alert.msg, function(btn){});
+ },
+
+ //send msg to the selected users from the Contact-grid
+ onSendMessage: function(btn) {
+
+ var arrayReceiversIM = [];
+ var openWindow = false;
+
+ if (this.sendFromType =="contact"){
+ var recDestArray = this._content_grid.getSelectionModel().getSelections();
+ if(recDestArray.length > 0){
+ openWindow = true;
+ for (var i=0; i<recDestArray.length; i++){
+ //on ne prend que les contact de l'annuaire
+
+ if (recDestArray[i].get("type")=="user"){
+ var idRec = '2' + recDestArray[i].get("id");
+ var val = {
+ itemValue: idRec,
+ displayValue: recDestArray[i].get("nom")+ " " +recDestArray[i].get("prenom"),
+ type:""
+ };
+ arrayReceiversIM.push(val);
+ }
+ else{
+ if(recDestArray[i].get("relUserId")!= 0 && recDestArray[i].get("relUserId")!=""){
+ var idRec = '2' + recDestArray[i].get("relUserId");
+ var val = {
+ itemValue: idRec,
+ displayValue: recDestArray[i].get("nom")+ " " +recDestArray[i].get("prenom"),
+ type:""
+ };
+ arrayReceiversIM.push(val);
+ }
+ }
+ }
+ }else{
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onSendMsg.alert.title, this.i18n.carnetDAdresses.onSendMsg.alert.msg, function(btn){});
+ }
+ }
+ else{
+ //cas des listes
+ var recDestArray = this._listes_grid.getSelectionModel().getSelections();
+ if(recDestArray.length > 0){
+ openWindow = true;
+ for (i=0; i<recDestArray.length; i++){
+ var list = recDestArray[i];
+ var val = {
+ itemValue: "1"+list.get("id"),
+ displayValue: "Liste "+list.get("name"),
+ type:list.get("type"),
+ orgId: list.get("orgId"),
+ roleId: list.get("roleId"),
+ listId: list.get("listId"),
+ parentList: list.get("parentList"),
+ childrenList: list.get("childrenList")
+ };
+ arrayReceiversIM.push(val);
+ }
+ }else{
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onSendMsg.alertList.title, this.i18n.carnetDAdresses.onSendMsg.alertList.msg, function(btn){});
+ }
+ }
+
+ if(openWindow){
+ //on initialise les champs d'ecriture des new msg
+ this.createMessageWindow.createNewMessage();
+
+ //On expand les destinataires IM
+ this.createMessageWindow.imFieldSet.expand(false);
+
+ this.createMessageWindow.destinataireChooser.setValues(arrayReceiversIM);
+ }
+
+ },
+
+ onSendVcard: function(btn) {
+
+
+ var arraySendVcard = [];
+
+ if (this.sendFromType =="contact"){
+ var recDestArray = this._content_grid.getSelectionModel().getSelections();
+ if(recDestArray.length > 0){
+ for (var i=0; i<recDestArray.length; i++){
+ //on ne prend que les contact de l'annuaire
+ if (recDestArray[i].get("type")=="user" || recDestArray[i].get("type")=="fiche"){
+ var idRec = recDestArray[i].get("id");
+ var val = {
+ userId: idRec,
+ displayValue: recDestArray[i].get("nom")+ " " +recDestArray[i].get("prenom"),
+ type: recDestArray[i].get("type")
+ };
+ arraySendVcard.push(val);
+ }
+ else{
+ if(recDestArray[i].get("relUserId")!= 0 && recDestArray[i].get("relUserId")!=""){
+ var idRec = recDestArray[i].get("relUserId");
+ var val = {
+ userId: idRec,
+ displayValue: recDestArray[i].get("nom")+ " " +recDestArray[i].get("prenom"),
+ type: recDestArray[i].get("type")
+ };
+ arraySendVcard.push(val);
+ }
+ }
+ }
+
+ if (!this.wait) {
+ this.wait = new Ext.LoadMask(Ext.getBody(), {msg: this.i18n.carnetDAdresses.onExport_call.wait.msg});
+ }
+ this.wait.show();
+
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: "sendVcard",
+ listeContact: Ext.encode(arraySendVcard)
+ },
+ scope: this,
+ success: this.onSuccessSendVcard,
+ failure: this.onFailureSendVcard
+ });
+ }else{
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onSendVcard.alert.title, this.i18n.carnetDAdresses.onSendVcard.alert.msg, function(btn){});
+ }
+ }else{
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onSendVcard.alertList.title, this.i18n.carnetDAdresses.onSendVcard.alertList.msg, function(btn){});
+ }
+ },
+
+ onSuccessSendVcard: function(response, options){
+
+ var backObj = Ext.decode(response.responseText);
+ this.wait.hide();
+ if (!backObj.success) {
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onSuccessExportVCARD.alert.title, this.i18n.carnetDAdresses.onSuccessExportVCARD.alert.msg, function(btn){});
+ } else {
+ //on initialise les champs d'ecriture des new msg
+ this.createMessageWindow.createNewMessage();
+
+ //On expand les destinataires IM
+ this.createMessageWindow.imFieldSet.expand(false);
+
+
+// var fpjValue = "<table><tr> <th> Pieces jointes : </th>";
+// fpjValue = fpjValue + " <td> " + backObj.name + "</td>";
+// fpjValue = fpjValue + "</tr></table>";
+// this.createMessageWindow.forwardPjField.setValue(fpjValue);
+// this.createMessageWindow.forwardPjField.show();
+
+ this.createMessageWindow.forwardPj = backObj.jsonForwardPj;
+ if (this.createMessageWindow.forwardPj.length > 0) {
+ var fpjValue = "<table><tr> <th> " + this.i18n.carnetDAdresses.onSuccessSendVcard.pj + " : </th> </tr></table><table><tr><td width='80px'></td>";
+ for(var i=0; i<this.createMessageWindow.forwardPj.length; i++){
+ if (i!=0 && i%4==0){
+ fpjValue = fpjValue + "</tr><tr><td width='80px'></td>";
+ }
+ fpjValue = fpjValue + " <td><div class='" + this.createMessageWindow.forwardPj[i].iconClass + "'> </div> " + this.createMessageWindow.forwardPj[i].name + "</td>";
+ }
+ fpjValue = fpjValue + "</tr></table>";
+ this.createMessageWindow.forwardPjField.setValue(fpjValue);
+ this.createMessageWindow.forwardPjField.show();
+ this.createMessageWindow.subjectField.setValue(this.i18n.carnetDAdresses.onSuccessSendVcard.subject);
+ }
+
+
+ // permet de mettre le focus sur le textArea !!
+ this.createMessageWindow.contentField.focus.defer(600, this.contentField);
+
+// this.createMessageWindow.destinataireChooser.setValues(arrayReceiversIM);
+
+ }
+ },
+
+ onFailureSendVcard: function(response, options){
+ this.wait.hide();
+ Ext.MessageBox.alert(this.i18n.carnetDAdresses.onSuccessExportVCARD.alert.title, this.i18n.carnetDAdresses.onSuccessExportVCARD.alert.msg, function(btn){});
+ },
+
+ onCellContextListGrid: function(grid, rowIndex, cellIndex, e ) {
+ e.stopEvent();
+ var coords = e.getXY();
+ var entityArray = grid.getSelectionModel().getSelections();
+ var select = false;
+ var deletable = false;
+ //on ajoute la sélection s'il n'y pas de ligne selectionné
+ if (entityArray.length==0) {
+ grid.getSelectionModel().selectRow(rowIndex);
+ this.addListItem.show();
+ if (grid.getSelectionModel().getSelections()[0].get("type") != "local") {
+ this.deleteListItem.hide();
+ this.editListItem.hide();
+ }
+ else {
+ this.deleteListItem.show();
+ this.editListItem.show();
+ }
+ this.sendListItem.show();
+ //} else if (entityArray.length==1) {
+ // this.rightClicListMenu.findById('addListItem').show();
+ // if (entityArray[0].get("type") != "local") {
+ // this.rightClicListMenu.findById('deleteListItem').hide();
+ // this.rightClicListMenu.findById('editListItem').hide();
+ // }
+ // else {
+ // this.rightClicListMenu.findById('deleteListItem').show();
+ // this.rightClicListMenu.findById('editListItem').show();
+ // }
+ // this.rightClicListMenu.findById('sendListItem').show();
+ } else {
+ //ou si l'utilisateur clic sur une ligne non selectionné
+ for (var i=0; i < entityArray.length; i++) {
+ if (!select && grid.getStore().indexOf(entityArray[i]) == rowIndex) {
+ select = true;
+ }
+ if (!deletable && entityArray[i].get("type") == "local") {
+ deletable = true;
+ }
+ }
+ if (select == false) {
+ grid.getSelectionModel().selectRow(rowIndex);
+ this.addListItem.show();
+ if (grid.getSelectionModel().getSelections()[0].get("type") != "local") {
+ this.deleteListItem.hide();
+ this.editListItem.hide();
+ }
+ else {
+ this.deleteListItem.show();
+ this.editListItem.show();
+ }
+ this.sendListItem.show();
+ } else {
+ this.addListItem.show();
+ if (deletable == false) {
+ this.deleteListItem.hide();
+ }
+ else {
+ this.deleteListItem.show();
+ }
+ this.editListItem.hide();
+ this.sendListItem.show();
+ }
+ }
+ this.rightClicListMenu.showAt([coords[0], coords[1]]);
+ },
+
+ onCellContextContactGrid: function(grid, rowIndex, cellIndex, e ) {
+ e.stopEvent();
+ var coords = e.getXY();
+ var entityArray = grid.getSelectionModel().getSelections();
+ var select = false;
+
+ //on ajoute la sélection s'il n'y pas de ligne selectionné
+ if (entityArray.length==0 || entityArray.length==1) {
+ grid.getSelectionModel().selectRow(rowIndex);
+ }
+ else {
+ //ou si l'utilisateur clic sur une ligne non selectionné
+ for (var i=0; i < entityArray.length; i++) {
+ if (!select && grid.getStore().indexOf(entityArray[i]) == rowIndex) {
+ select = true;
+ break;
+ }
+ }
+ if (select == false) {
+ grid.getSelectionModel().selectRow(rowIndex);
+ }
+ }
+ if (this.currentSelectedList.get("type") == "local") {
+ this.addContactItem.show();
+ this.deleteContactItem.show();
+ }
+ else {
+ this.addContactItem.hide();
+ this.deleteContactItem.hide();
+ }
+ this.sendContactItem.show();
+ this.rightClicContactMenu.showAt([coords[0], coords[1]]);
+ }
+
+});
+