--- /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.UserManagement");
+EntSavoie.UserManagement.AddUserWindow = function (config) {
+ Ext.apply(this, config);
+
+ // Ajoute le texte des erreurs
+ Ext.QuickTips.init();
+
+ // turn on validation errors beside the field globally
+ Ext.form.Field.prototype.msgTarget = 'side';
+
+ this.dataLoaded = this.dataLoaded || false;
+
+ this.properties = {
+ lastName: true,
+ firstName: true,
+ mail: true,
+ birthday: true,
+ roles: true,
+ functions: false,
+ status: false,
+ organizations: true,
+ disciplines: false,
+ instruments: true,
+ login: true,
+ password: true
+ };
+
+ this.itemsUserCardPanel = new Array();
+
+ /*
+ * Nom
+ */
+ this.lastNameTextField = this.lastNameTextField || new Ext.form.TextField({
+ fieldLabel: "Nom",
+ emptyText: "Nom",
+ allowBlank: false,
+ anchor: "95%"
+ });
+ if(this.properties.lastName){
+ this.itemsUserCardPanel.push(this.lastNameTextField);
+ }
+
+ /*
+ * Prenom
+ */
+ this.firstNameTextField = this.firstNameTextField || new Ext.form.TextField({
+ fieldLabel: "Prénom",
+ emptyText: "Prénom",
+ allowBlank: false,
+ anchor: "95%"
+ });
+ if(this.properties.firstName){
+ this.itemsUserCardPanel.push(this.firstNameTextField);
+ }
+
+ /*
+ * Email
+ */
+ this.mailTextField = this.mailTextField || new Ext.form.TextField({
+ fieldLabel: "Email",
+ emptyText: "Email",
+ allowBlank: false,
+ vtype: 'email',
+ anchor: "95%"
+ });
+ if(this.properties.mail){
+ this.itemsUserCardPanel.push(this.mailTextField);
+ }
+
+ /*
+ * Date de naissance
+ */
+ this.birthdayDateField = this.birthdayDateField || new Ext.form.DateField({
+ fieldLabel: "Date de naissance",
+ emptyText: "Date de naissance",
+ allowBlank: false,
+ format: "d/m/Y",
+ anchor: "95%"
+ });
+ if(this.properties.birthday){
+ this.itemsUserCardPanel.push(this.birthdayDateField);
+ }
+
+ /*
+ * Role
+ */
+ this.rolesJsonStore = this.rolesJsonStore || new Ext.data.JsonStore({
+ root: "items",
+ id: 'id',
+ fields: [
+ 'id',
+ 'name'
+ ]
+ });
+
+ this.rolesComboBox = this.rolesComboBox || new Ext.form.ComboBox({
+ listClass: "userManagement-portlet",
+ fieldLabel: "Rôle",
+ emptyText: "Rôle",
+ valueField: "id",
+ displayField: "name",
+ editable: false,
+ mode: 'local',
+ typeAhead: true,
+ store: this.rolesJsonStore,
+ lazyRender: true,
+ triggerAction: "all",
+ anchor: "95%",
+ allowBlank: false
+ });
+ if(this.properties.roles){
+ this.itemsUserCardPanel.push(this.rolesComboBox);
+ }
+
+ /*
+ * Fonction
+ */
+ this.functionsJsonStore = this.functionsJsonStore || new Ext.data.JsonStore({
+ root: "items",
+ id: 'id',
+ fields: [
+ 'id',
+ 'name'
+ ],
+ sortInfo: {
+ field: "name",
+ direction: "ASC"
+ }
+ });
+
+ this.functionsComboBox = this.functionsComboBox || new Ext.form.ComboBox({
+ listClass: "userManagement-portlet",
+ fieldLabel: "Fonction",
+ emptyText: "Fonction",
+ valueField: "id",
+ displayField: "name",
+ editable: false,
+ mode: 'local',
+ typeAhead: true,
+ store: this.functionsJsonStore,
+ lazyRender: true,
+ triggerAction: "all",
+ anchor: "95%"
+ });
+ if(this.properties.functions){
+ this.itemsUserCardPanel.push(this.functionsComboBox);
+ }
+
+ /*
+ * Statut
+ */
+ this.statusComboBox = this.statusComboBox || new Ext.form.ComboBox({
+ listClass: "userManagement-portlet",
+ disabled: true,
+ fieldLabel: "Statut",
+ emptyText: "Statut",
+ typeAhead: true,
+ triggerAction: 'all',
+ store: [
+ ["Amateur", "Amateur"],
+ ["Pro Formation Continue", "Pro Formation Continue"],
+ ["Pro Mima 1", "Pro Mima 1"],
+ ["Pro Mima 2", "Pro Mima 2"]
+ ],
+ lazyRender: true,
+ anchor: "95%"
+ });
+ if(this.properties.status){
+ this.itemsUserCardPanel.push(this.statusComboBox);
+ }
+
+ /*
+ * Etablissement et Classes
+ */
+ this.treeOrganizationLoader = this.treeOrganizationLoader || new Ext.tree.TreeLoader({
+ dataUrl: this.renderURLAjax+'&jspPage=%2Fajax%2FlistOrganizationsForTree.jsp'
+ });
+
+ this.treeOrganization = this.treeOrganization || new Ext.tree.TreePanel({
+ height: 220,
+ anchor: "95%",
+ fieldLabel: "Etablissements / Classes",
+ useArrows: true,
+ autoScroll : true,
+ animate : true,
+ loader : this.treeOrganizationLoader,
+ rootVisible : false,
+ root : {
+ nodeType: 'async',
+ draggable: false,
+ id: "organizations",
+ leaf: false,
+ allowDrop: false,
+ expanded: true
+ }
+ });
+ if(this.properties.organizations){
+ this.itemsUserCardPanel.push(this.treeOrganization);
+ }
+
+ /*
+ * Disciplines
+ */
+ this.disciplinesJsonStore = this.disciplinesJsonStore || new Ext.data.JsonStore({
+ root: "items",
+ id: 'id',
+ fields: [
+ 'id',
+ 'name'
+ ],
+ sortInfo: {
+ field: "name",
+ direction: "ASC"
+ }
+ });
+
+ this.disciplinesCheckBox = this.disciplinesCheckBox || new Ext.grid.CheckboxSelectionModel();
+
+ this.disciplinesGridPanel = this.disciplinesGridPanel || new Ext.grid.GridPanel({
+ fieldLabel: "Discipline",
+ anchor: "95%",
+ height: 150,
+ border: true,
+ autoFill: true,
+ editable: false,
+ store: this.disciplinesJsonStore,
+ autoExpandColumn: "disciplineName",
+ sm: this.disciplinesCheckBox,
+ columns: [
+ this.disciplinesCheckBox,
+ {
+ id: "disciplineName",
+ header: "Nom",
+ dataIndex: "name",
+ sortable: true
+ }
+ ]
+ });
+ if(this.properties.disciplines){
+ this.itemsUserCardPanel.push(this.disciplinesGridPanel);
+ }
+
+ /*
+ * Instruments
+ */
+ this.instrumentsJsonStore = this.instrumentsJsonStore || new Ext.data.JsonStore({
+ root: "items",
+ id: 'id',
+ fields: [
+ 'id',
+ 'name'
+ ],
+ sortInfo: {
+ field: "name",
+ direction: "ASC"
+ }
+ });
+
+ this.instrumentsCheckBox = this.instrumentsCheckBox || new Ext.grid.CheckboxSelectionModel();
+
+ this.instrumentsGridPanel = this.instrumentsGridPanel || new Ext.grid.GridPanel({
+ disabled: true,
+ fieldLabel: "Instrument",
+ anchor: "95%",
+ height: 150,
+ border: true,
+ autoFill: true,
+ editable: false,
+ store: this.instrumentsJsonStore,
+ autoExpandColumn: "instrumentName",
+ sm: this.instrumentsCheckBox,
+ columns: [
+ this.instrumentsCheckBox,
+ {
+ id: "instrumentName",
+ header: "Instrument",
+ dataIndex: "name",
+ sortable: true
+ }
+ ]
+ });
+ if(this.properties.instruments){
+ this.itemsUserCardPanel.push(this.instrumentsGridPanel);
+ }
+
+ /*
+ * Identifiant
+ */
+ this.loginDisplayField = this.loginDisplayField || new Ext.form.DisplayField({
+ fieldLabel: "Identifiant",
+ value: "",
+ anchor: "95%"
+ });
+ if(this.properties.login){
+ this.itemsUserCardPanel.push(this.loginDisplayField);
+ }
+
+ /*
+ * Mot de passe
+ */
+ this.passwordTextField = this.passwordTextField || new Ext.form.TextField({
+ fieldLabel: "Mot de passe",
+ emptyText: "Mot de passe",
+ allowBlank: false,
+ anchor: "95%"
+ });
+ if(this.properties.password){
+ this.itemsUserCardPanel.push(this.passwordTextField);
+ }
+
+ /*
+ * Bouton : Generation Identifiant et Mot de passe
+ */
+ this.generateLoginPasswordButton = this.generateLoginPasswordButton || new Ext.Button({
+ text: "Obtenir un login et un mot de passe",
+ handler: this.generateLoginPassword,
+ scope: this
+ });
+
+ /*
+ * Bouton : Creation Utilisateur
+ */
+ this.createUserButton = this.createUserButton || new Ext.Button({
+ text: "Créer",
+ handler: this.onCreateUserButton,
+ scope: this
+ });
+
+ /*
+ * Bouton : Modification Utilisateur
+ */
+ this.modifyUserButton = this.modifyUserButton || new Ext.Button({
+ text: "Modifer",
+ handler: this.onModifyUserButton,
+ scope: this
+ });
+
+ /*
+ * Bouton : Reinitialisation du Formulaire
+ */
+ this.resetInformationsButton = this.resetInformationsButton || new Ext.Button({
+ text: "Réinitialiser",
+ handler: this.onResetInformationsButton,
+ scope: this
+ });
+
+ /*
+ * Bouton : Fermeture de la Fenetre
+ */
+ this.closeExportUserWindowButton = this.closeExportUserWindowButton || new Ext.Button({
+ text: "Fermer",
+ handler: this.onCloseAddUserWindowButton,
+ scope: this
+ });
+
+ /*
+ * Constructeur
+ */
+ EntSavoie.UserManagement.AddUserWindow.superclass.constructor.call(this, {
+ cls: "userManagement-portlet",
+ title: "Fiche Utilisateur",
+ height: 700,
+ width: 525,
+ modal: true,
+ closable: true,
+ resizable: false,
+ closeAction: "hide",
+ layout: "form",
+ padding: 5,
+ buttonAlign: "left",
+ items: [
+ this.itemsUserCardPanel
+ ],
+ buttons: [
+ this.generateLoginPasswordButton,
+ this.createUserButton,
+ this.modifyUserButton,
+ "->",
+ this.resetInformationsButton,
+ this.closeExportUserWindowButton
+ ]
+ });
+
+ // listeners
+ this.on("show", this.onShowAddUserWindow, this);
+ this.rolesComboBox.on("select", this.onSelectRolesComboBox, this);
+ this.treeOrganizationLoader.on("beforeload", this.onBeforeLoadTreeOrganization, this);
+
+};
+
+Ext.extend(EntSavoie.UserManagement.AddUserWindow, Ext.Window, {
+ initComponent: function () {
+ EntSavoie.UserManagement.AddUserWindow.superclass.initComponent.call(this);
+ },
+
+ /*
+ * Obtention des datas
+ */
+ onShowAddUserWindow: function(){
+ if(this.user != null || !this.dataLoaded) {
+ this.wait = new Ext.LoadMask(this.id, {msg: "<b>Obtention des informations en cours</b> <br/> Veuillez patienter ..."});
+ this.wait.show();
+
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: "getAddUserWindowData",
+ loadData: !this.dataLoaded,
+ userDN: (this.user != null)?this.user.get("dn"):""
+ },
+ scope: this,
+ success: this.onSuccessGetAddUserWindowData,
+ failure: this.onFailureGetAddUserWindowData
+ });
+ }
+ else {
+ this.clearInformations();
+ this.setButtons();
+ }
+ },
+
+ onSuccessGetAddUserWindowData: function(response, options) {
+ this.wait.hide();
+ // Traitement des messages
+ var backObj = Ext.decode(response.responseText);
+ if (!backObj.success) {
+ Ext.MessageBox.alert("Attention", "En raison d'un dysfonctionnement réseau l'opération demandée n'a pas pu être effectuée", function(btn){}, this);
+ } else {
+ if(!this.dataLoaded){
+ this.rolesJsonStore.loadData(backObj.rolesData);
+ this.functionsJsonStore.loadData(backObj.functionsData);
+ this.disciplinesJsonStore.loadData(backObj.disciplinesData);
+ this.instrumentsJsonStore.loadData(backObj.instrumentsData);
+
+ this.dataLoaded = true;
+ }
+ if(this.user != null){
+
+ var user = Ext.decode(backObj.user);
+ this.lastNameTextField.setValue(user.sn[0]);
+ this.firstNameTextField.setValue(user.givenName[0]);
+ this.mailTextField.setValue(user.mail[0]);
+ this.birthdayDateField.setValue(user.ENTPersonDateNaissance[0]);
+ this.rolesComboBox.setValue(user.ENTPersonProfils[0]);
+ this.rolesComboBox.disable();
+
+ if (this.rolesComboBox.getValue() == "National_1") {
+ this.functionsComboBox.disable();
+ this.statusComboBox.enable();
+ this.disciplinesGridPanel.disable();
+ this.instrumentsGridPanel.enable();
+ } else {
+ this.functionsComboBox.enable();
+ this.statusComboBox.disable();
+ this.disciplinesGridPanel.enable();
+ this.instrumentsGridPanel.disable();
+ }
+
+ try {
+ this.functionsComboBox.setValue(user.fonctionId[0]);
+ } catch (e){}
+
+ try {
+ this.statusComboBox.setValue(user.ENTEleveRegime[0]);
+ } catch (e){}
+
+ try {
+ var disciplines = [];
+ for (var i = 0; i < user.disciplineId.length; i++) {
+ disciplines[i] = this.disciplinesGridPanel.getStore().getById(user.disciplineId[i]);
+ }
+ this.disciplinesGridPanel.getSelectionModel().selectRecords(disciplines);
+ } catch (e){}
+
+ try {
+ var instruments = [];
+ for (var i = 0; i < user.instrumentsId.length; i++) {
+ instruments[i] = this.instrumentsGridPanel.getStore().getById(user.instrumentsId[i]);
+ }
+ this.instrumentsGridPanel.getSelectionModel().selectRecords(instruments);
+ } catch (e){}
+
+ this.loginDisplayField.setValue(user.ENTPersonLogin[0]);
+ this.passwordTextField.setValue(user.password[0]);
+
+ if(this.treeLoad){
+ this.treeOrganization.getLoader().load(this.treeOrganization.getRootNode());
+ this.treeLoad = true;
+ }
+ if(!this.user.get("handmake")){
+ this.disableAllFields();
+ }
+ }
+ this.setButtons();
+ }
+ },
+
+ onFailureGetAddUserWindowData: function(response, options) {
+ this.wait.hide();
+ Ext.MessageBox.alert("Attention", "En raison d'un dysfonctionnement réseau l'opération demandée n'a pas pu être effectuée", function(btn){}, this);
+ },
+
+ /*
+ * Before Load du Tree Loader
+ */
+ onBeforeLoadTreeOrganization: function(tl, node){
+ if(this.user != null){
+ tl.baseParams.userId = this.user.get("userId");
+ tl.baseParams.userDN = this.user.get("dn");
+ tl.baseParams.etabDN = this.user.get("etabDN");
+ }
+ else {
+ tl.baseParams.userId = 0;
+ tl.baseParams.userDN = "";
+ tl.baseParams.etabDN = "";
+ }
+ },
+
+ /*
+ * Set des boutons sur la toolbar
+ */
+ setButtons: function(){
+ // Si on est en edition
+ if(this.user != null){
+ this.generateLoginPasswordButton.setVisible(false);
+ this.createUserButton.setVisible(false);
+ this.modifyUserButton.setVisible(true);
+ this.resetInformationsButton.setVisible(false);
+ this.closeExportUserWindowButton.setVisible(true);
+ }
+ else {
+ this.generateLoginPasswordButton.setVisible(true);
+ this.createUserButton.setVisible(true);
+ this.modifyUserButton.setVisible(false);
+ this.resetInformationsButton.setVisible(false);
+ this.closeExportUserWindowButton.setVisible(true);
+ }
+ },
+
+ /*
+ * Disable de l'ensemble des fields du formulaire
+ */
+ disableAllFields: function(){
+ this.lastNameTextField.disable();
+ this.firstNameTextField.disable();
+ this.mailTextField.disable();
+ this.birthdayDateField.disable();
+ this.rolesComboBox.disable();
+ this.functionsComboBox.disable();
+ this.statusComboBox.disable();
+ this.disciplinesGridPanel.disable();
+ this.instrumentsGridPanel.disable();
+ this.loginDisplayField.disable();
+ this.passwordTextField.disable();
+ },
+
+ /*
+ * Remise a zero des informations du formulaire
+ */
+ clearInformations: function(){
+ this.lastNameTextField.setValue("");
+ this.firstNameTextField.setValue("");
+ this.mailTextField.setValue("");
+ this.birthdayDateField.setValue("");
+ this.rolesComboBox.enable();
+ this.rolesComboBox.reset();
+ this.functionsComboBox.enable();
+ this.functionsComboBox.reset();
+ this.statusComboBox.disable();
+ this.statusComboBox.reset();
+ if(this.properties.disciplines){
+ this.disciplinesGridPanel.getSelectionModel().clearSelections(false);
+ }
+ if(this.properties.instruments){
+ this.instrumentsGridPanel.getSelectionModel().clearSelections(false);
+ }
+ this.instrumentsGridPanel.disable();
+ this.loginDisplayField.setValue("");
+ this.passwordTextField.setValue("");
+ this.treeOrganization.getLoader().load(this.treeOrganization.getRootNode());
+ },
+
+ /*
+ * Verifications des informations du formulaire
+ */
+ informationsValid: function(){
+ var lastNameValid = this.lastNameTextField.validate() || !this.properties.lastName;
+ var firstNameValid = this.firstNameTextField.validate() || !this.properties.firstName;
+ var mailValid = this.mailTextField.validate() || !this.properties.mail;
+ var birthdayValid = this.birthdayDateField.validate() || !this.properties.birthday;
+ var organizationsValid = this.treeOrganization.getChecked().length>0 || !this.properties.organizations;
+ var loginValid = this.loginDisplayField.getValue() != "" || !this.properties.login;
+ var passwordValid = this.passwordTextField.validate() || !this.properties.password;
+
+ return lastNameValid && firstNameValid && mailValid && birthdayValid && organizationsValid && loginValid && passwordValid;
+ },
+
+ /*
+ * Obtention des informations du formulaire
+ */
+ getUserInformations: function(){
+ var userRecord = {
+ userId: this.user?this.user.get("userId"):0,
+ userdn: this.user?this.user.get("dn"):"",
+ lastname: this.lastNameTextField.getValue(),
+ firstname: this.firstNameTextField.getValue(),
+ mail: this.mailTextField.getValue(),
+ daten: this.birthdayDateField.getValue().format("j/n/Y"),
+ profil: this.rolesComboBox.getValue(),
+ fonction: this.functionsComboBox.getValue(),
+ status: this.statusComboBox.getValue(),
+ login: this.loginDisplayField.getValue(),
+ pwd: this.passwordTextField.getValue(),
+ etab: "",
+ organizations: [],
+ disciplines: [],
+ instruments: [],
+ handmake: (this.user != null)?this.user.get("handmake"):true
+ };
+
+ for (var i = 0; i < this.treeOrganization.getChecked().length; i++){
+ var node = this.treeOrganization.getChecked()[i];
+ if(node.isLeaf()){
+ userRecord.organizations[i] = {
+ "id": node.attributes.dn,
+ "name": node.text,
+ "type": node.attributes.type,
+ "organizationId": node.attributes.orgId
+ };
+ var parentNode = node.parentNode;
+ userRecord.etab = parentNode.attributes.dn;
+ }
+ else {
+ userRecord.etab = node.attributes.dn;
+ }
+ }
+
+ for (var i = 0; i < this.disciplinesGridPanel.getSelectionModel().getSelections().length; i++) {
+ var discipline = this.disciplinesGridPanel.getSelectionModel().getSelections()[i];
+ userRecord.disciplines[i] = discipline.get('id');
+ }
+
+ for (var i = 0; i < this.instrumentsGridPanel.getSelectionModel().getSelections().length; i++) {
+ var instrument = this.instrumentsGridPanel.getSelectionModel().getSelections()[i];
+ userRecord.instruments[i] = instrument.get('id');
+ }
+
+ return userRecord;
+ },
+
+ /*
+ * Selection d'un role sur le combobox
+ */
+ onSelectRolesComboBox: function(cmp, record, index){
+ if (record.get("id") == "National_1") {
+ this.functionsComboBox.disable();
+ this.statusComboBox.enable();
+ this.disciplinesGridPanel.disable();
+ this.instrumentsGridPanel.enable();
+ } else {
+ this.functionsComboBox.enable();
+ this.statusComboBox.disable();
+ this.disciplinesGridPanel.enable();
+ this.instrumentsGridPanel.disable();
+ }
+ },
+
+ /*
+ * Generation Login et Mot de passe
+ */
+ generateLoginPassword: function(btn){
+ var lastname = this.lastNameTextField.getValue();
+ var firstname = this.firstNameTextField.getValue();
+
+ if (lastname != "" && firstname != "") {
+
+ this.wait = new Ext.LoadMask(this.id, {msg: "<b>Génération des informations en cours.</b> <br/> Veuillez patienter ..."});
+ this.wait.show();
+
+ Ext.Ajax.request({
+ url: this.renderURLAjax + '&jspPage=/ajax/generateLW.jsp',
+ method: "POST",
+ params: {
+ lastname: lastname,
+ firstname: firstname
+ },
+ scope: this,
+ success: this.onSuccessGenerateLoginPassword,
+ failure: this.onFailureGenerateLoginPassword
+ });
+ }
+ else {
+ Ext.Msg.show({
+ title: "Attention",
+ buttons: Ext.Msg.OK,
+ msg: "Pour pouvoir générer un identifiant et un mot de passe vous devez préalablement entrer un nom et un prénom."
+ });
+ }
+ },
+
+ onSuccessGenerateLoginPassword: function(response, options){
+ this.wait.hide();
+ // Traitement des messages
+ var backObj = Ext.decode(response.responseText);
+ if (!backObj.success) {
+ Ext.MessageBox.alert("Attention", "En raison d'un dysfonctionnement réseau l'opération demandée n'a pas pu être effectuée", function(btn){}, this);
+ } else {
+ var login = "";
+ var password = "";
+
+ for (var i = 0; i < backObj.items.length; i++) {
+ var record = backObj.items[i];
+ var key = record["id"];
+ var value = record["name"];
+ if (key == "login") {
+ login = value;
+ }
+ if (key == "pwd") {
+ password = value;
+ }
+ }
+
+ this.loginDisplayField.setValue(login);
+ this.passwordTextField.setValue(password);
+ }
+ },
+
+ onFailureGenerateLoginPassword: function(response, options){
+ this.wait.hide();
+ Ext.MessageBox.alert("Attention", "En raison d'un dysfonctionnement réseau l'opération demandée n'a pas pu être effectuée", function(btn){}, this);
+ },
+
+ /*
+ * Creation d'un utilisateur
+ */
+ onCreateUserButton: function(btn){
+ if(this.informationsValid()){
+
+ this.wait = new Ext.LoadMask(this.id, {msg: "<b>Ajout d'un 'utilisateur en cours.</b> <br/> Veuillez patienter ..."});
+ this.wait.show();
+
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ method: "POST",
+ timeout: 30000,
+ params: {
+ cmd: "addUser",
+ user: Ext.util.JSON.encode(this.getUserInformations())
+ },
+ scope: this,
+ success: this.onSuccessCreateUser,
+ failure: this.onFailureCreateUser
+ });
+ }
+ },
+
+ onSuccessCreateUser: function(response, options){
+ this.wait.hide();
+ // Traitement des messages
+ var backObj = Ext.decode(response.responseText);
+ if (!backObj.success) {
+ Ext.MessageBox.alert("Attention", "En raison d'un dysfonctionnement réseau l'opération demandée n'a pas pu être effectuée", function(btn){}, this);
+ } else {
+ this.hide();
+ Ext.slideMsg.msg("Création d'un utilisateur", "L'utilisateur a été correctement créé.");
+ }
+ },
+
+ onFailureCreateUser: function(response, options){
+ this.wait.hide();
+ if(response.isTimeout){
+ Ext.MessageBox.show({
+ icon:Ext.Msg.INFO,
+ title: "Information",
+ msg: "Le processus d'ajout d'utilisateurs peut être long. <br />" +
+ "Il est actuellement toujours en cours. Nous vous invitons à vérifier que l'utilisateur ajouté ait bien été créé dans quelques minutes.",
+ buttons: {
+ ok: "OK",
+ },
+ fn: function(btn){
+ this.hide();
+ },
+ scope: this
+ });
+ } else {
+ Ext.MessageBox.alert("Attention", "En raison d'un dysfonctionnement réseau l'opération demandée n'a pas pu être effectuée", function(btn){}, this);
+ }
+ },
+
+ /*
+ * Modification de l'utilisateur selectionne
+ */
+ onModifyUserButton: function(btn){
+ if(this.informationsValid()){
+
+ this.wait = new Ext.LoadMask(this.id, {msg: "<b>Modification d'un 'utilisateur en cours.</b> <br/> Veuillez patienter ..."});
+ this.wait.show();
+
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ method: "POST",
+ timeout: 30000,
+ params: {
+ cmd: "editUser",
+ user: Ext.util.JSON.encode(this.getUserInformations())
+ },
+ scope: this,
+ success: this.onSuccessEditUser,
+ failure: this.onFailureEditUser
+ });
+ }
+ },
+
+ onSuccessEditUser: function(response, options){
+ this.wait.hide();
+ // Traitement des messages
+ var backObj = Ext.decode(response.responseText);
+ if (!backObj.success) {
+ Ext.MessageBox.alert("Attention", "En raison d'un dysfonctionnement réseau l'opération demandée n'a pas pu être effectuée", function(btn){}, this);
+ } else {
+ this.hide();
+ Ext.slideMsg.msg("Modification d'un utilisateur", "L'utilisateur a été correctement modifié.");
+ }
+ },
+
+ onFailureEditUser: function(response, options){
+ this.wait.hide();
+ if(response.isTimeout){
+ Ext.MessageBox.show({
+ icon:Ext.Msg.INFO,
+ title: "Information",
+ msg: "Le processus d'ajout d'utilisateurs peut être long. <br />" +
+ "Il est actuellement toujours en cours. Nous vous invitons à vérifier que l'utilisateur ait bien été modifié dans quelques minutes.",
+ buttons: {
+ ok: "OK",
+ },
+ fn: function(btn){
+ this.hide();
+ },
+ scope: this
+ });
+ } else {
+ Ext.MessageBox.alert("Attention", "En raison d'un dysfonctionnement réseau l'opération demandée n'a pas pu être effectuée", function(btn){}, this);
+ }
+ },
+
+ /*
+ * Fermeture de la window
+ */
+ onCloseAddUserWindowButton: function(btn){
+ this.hide();
+ }
+});
+