--- /dev/null
+/*
+Copyright (c) Igor Barma, Alexandre Desoubeaux, Christian Martel, Eric Brun, Mathieu Amblard, Gwenael Gevet, Pierre Guillot, 2012
+For licensing, see README.txt or http://www.pentilanero.com (Cecill-C or AGPL or LGPL)
+*/
+Ext.ns("EntSavoie.Cartable");
+EntSavoie.Cartable.SendToCasier = 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.waitPanel = null;
+
+ this.type = this.type || "user";
+
+ this.contentLabel = this.contentLabel || new Ext.form.Label({
+ text: this.i18n.Cartable.SendToCasier.contentLabel.text,
+ style : 'padding: 5px 5px 5px 5px; text-align: left; color:#3764A0; font-size: 12px;'
+ });
+
+ this.fileLabel = this.fileLabel || new Ext.form.Label({
+ text: this.i18n.Cartable.SendToCasier.fileLabel.text,
+ style : 'padding: 5px 5px 5px 5px; text-align: left; color:#3764A0; font-size: 12px;'
+ });
+
+ this.contentField = this.contentField || new Ext.ux.form.CKEditor({
+ CKConfig: {
+ toolbar: [
+ ['Source','-','FontSize','Bold','Italic','Underline','Strike','TextColor','BGColor'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], ['SpellChecker', 'Scayt']
+ ],
+ removePlugins : 'elementspath',
+ skin: 'kama',
+ resize_enabled: false,
+ enterMode: 2,
+ scayt_autoStartup : true,
+ scayt_sLang : "fr_FR",
+ width: 345,
+ height: 70,
+ language: this.language || "fr"
+ }
+ });
+
+ // Pieces jointes
+ this.attachFileChooserAdvanced = this.attachFileChooserAdvanced || new EntSavoie.AttachFileChooserAdvanced({
+ treeWindowId: "sendToCasierAttachFileChooserAdvanced",
+ actionURLAjax: this.actionURLAjax,
+ renderURLAjax: this.renderURLAjax,
+ btnText: this.i18n.Cartable.SendToCasier.attachFileChooserAdvanced.btnText,
+ btnStyle: "margin-left: 220px;",
+ bodyCssClass: 'panelAttachChooserStyle',
+ draggable: false,
+ cartableView: true,
+ attachFile_gridHeight: 130,
+ attachFile_gridWidth: 320
+ });
+
+ // on redefinit les destinataires
+ this.membreRecordCreator = Ext.data.Record.create(["type",
+ "orgId",
+ "roleId",
+ "listId",
+ "mail",
+ "id",
+ "displayText",
+ "admin"]);
+
+ this.membres_store = this.membres_store || new Ext.data.Store( {
+ fields : [ "id", "displayText", "mail", "type", "orgId", "roleId", "listId", "admin"],
+ sortInfo: {
+ field: 'displayText',
+ direction: 'ASC' // or 'DESC' (case sensitive for local sorting)
+ }
+ });
+
+ this.membresPaggingTB = this.membresPaggingTB || new Ext.PagingToolbar({
+ hidden: true,
+ pageSize: 18,
+ store: this.membres_store,
+ displayInfo: false,
+ displayMsg: '',
+ emptyMsg: "",
+ cls: "no-border-paging-toolbar",
+ items:[]
+ });
+
+ // the check column is created using a custom plugin
+ this.checkColumn = "no column";
+
+ this.title_membres_grid = this.title_membres_grid || new Ext.form.DisplayField({
+ value: this.i18n.Cartable.SendToCasier.title_membres_grid.value,
+ cls: "title-membre-grid",
+ style: "color: #15428B"
+ });
+
+ this.retirerMembresBtn = this.retirerMembresBtn || new Ext.Button({
+ text: this.i18n.Cartable.SendToCasier.retirerMembresBtn.text,
+ iconCls: 'remove-receiver',
+ handler: this.retirerMembres,
+ scope: this
+ });
+
+ this.membreGridTBar = this.membreGridTBar || new Ext.Toolbar({
+ items: [
+ this.title_membres_grid,
+ '->',
+ this.retirerMembresBtn
+ ]
+ });
+
+ this.membres_grid = this.membres_grid || new Ext.grid.GridPanel({
+ enableDragDrop: true,
+ border: false,
+ ddGroup : "retirerMembresDD",
+ ddText : this.i18n.Cartable.SendToCasier.membres_grid.ddText,
+ store : this.membres_store,
+ autoExpandColumn: 'nom',
+ columns :
+ [{ header : this.i18n.Cartable.SendToCasier.membres_grid.columns[0],
+ id: 'nom',
+ dataIndex : this.type=="mail"?"mail":"displayText",
+ sortable : false,
+ width: 165,
+ editable: false
+ }],
+ tbar: this.membreGridTBar,
+ bbar: [this.membresPaggingTB]
+ });
+
+ // on definit maintenant le composant
+ this.destinatairesChooserPanel = this.destinatairesChooserPanel || new EntSavoie.Atelier.GestionMembres({
+ renderURLAjax: this.renderURLAjax,
+ activeLocal: this.type=="mail"?true:false,
+ type: this.type,
+ height: 380,
+ border: false,
+ membreRecordCreator: this.membreRecordCreator,
+ checkColumn: this.checkColumn,
+ membres_store: this.membres_store,
+ membresPaggingTB: this.membresPaggingTB,
+ membres_grid: this.membres_grid,
+ frameView: true,
+ hideColumnStatut: true,
+ isGroupManagment: this.isGroupManagment
+ });
+
+ this.containerPanel = this.containerPanel || new Ext.form.FormPanel({
+ border: false,
+ layout: 'column',
+ height: 200,
+ width: 710,
+ layoutConfig: {
+ columns: 2
+ },
+ defaults: {
+ collapsible: false,
+ split: false
+ },
+ items: [
+ {
+ height: 180,
+ columnWidth: .45,
+ border: false,
+ style: "margin-left:5px; margin-top:5px;",
+ items: [this.fileLabel, this.attachFileChooserAdvanced]
+ },
+ {
+ height: 180,
+ columnWidth: .55,
+ border: false,
+ style: "margin-left:20px; margin-top:5px;",
+ items: [this.contentLabel, this.contentField]
+ }
+ ]
+ });
+
+
+ this.sendFormPanel = this.sendFormPanel || new Ext.Panel({
+ border: false,
+ height: 640,
+ // autoHeight: true,
+ layout: 'form',
+ frame: true,
+ items:[{style: "margin-left:5px;",
+ border: false,
+ items:[this.containerPanel]
+ },
+ {style: "margin-left:5px; margin-bottom:5px;",
+ border: false,
+ items:[this.destinatairesChooserPanel]
+ }
+ ]
+ });
+
+ this.sendToCasierBtn = this.sendToCasierBtn || new Ext.Button({
+ minWidth: 80,
+ text: this.i18n.Cartable.SendToCasier.sendToCasierBtn.text,
+ handler: this.onSendToCasierBtn,
+ scope: this
+ });
+
+ this.cancelBtn = this.cancelBtn || new Ext.Button({
+ minWidth: 80,
+ text: this.i18n.Cartable.SendToCasier.cancelBtn.text,
+ handler: this.onCancelFn,
+ scope: this
+ });
+
+ // Grid contenant les elements
+ EntSavoie.Cartable.SendToCasier.superclass.constructor.call(this, {
+ id: "window",
+ title: "<div style='font-size: 14px !important;'> " + this.i18n.Cartable.SendToCasier.title + " <div>",
+ width: 720,
+ layout: 'fit',
+ hidden: true,
+ border: true,
+ //autoHeight: true,
+ height: 670,
+ resizable: false,
+ modal: true,
+ closeAction: 'hide',
+ items: [this.sendFormPanel],
+ buttons: [this.sendToCasierBtn, '-', this.cancelBtn]
+ });
+
+};
+
+Ext.extend(EntSavoie.Cartable.SendToCasier, Ext.Window, {
+ initComponent: function () {
+ EntSavoie.Cartable.SendToCasier.superclass.initComponent.call(this);
+ },
+
+ onSendToCasierBtn: function(btn) {
+ // on recupere les destinataires
+ var arrayDest = new Array();
+
+ for (i=0; i<this.destinatairesChooserPanel.membres_store.getCount(); i++) {
+ var rec = this.destinatairesChooserPanel.membres_store.getAt(i);
+ var id = rec.get("id").substring(1);
+ var val = { displayValue: rec.get("displayText"),
+ orgId: rec.get("orgId"),
+ roleId: rec.get("roleId"),
+ listId: rec.get("listId"),
+ id: id,
+ type: rec.get("type")};
+ arrayDest.push(val);
+ }
+
+
+
+ // on ajoute les pieces jointes
+ var pjArray = new Array();
+ for (i=0; i<this.attachFileChooserAdvanced.attachFile_store.getCount(); i++) {
+ var pjRec = this.attachFileChooserAdvanced.attachFile_store.getAt(i);
+ var pjObj = {};
+ pjObj.type = pjRec.get("type");
+ pjObj.id = pjRec.get("id");
+ pjArray.push(pjObj);
+ }
+
+ if (arrayDest.length==0) {
+ Ext.MessageBox.alert(this.i18n.Cartable.SendToCasier.onSendToCasierBtn.alert.title, this.i18n.Cartable.SendToCasier.onSendToCasierBtn.alert.msg, function(btn){});
+ return false;
+ } else if(pjArray.length==0){
+ Ext.MessageBox.alert(this.i18n.Cartable.SendToCasier.onSendToCasierBtn.alert.title, this.i18n.Cartable.SendToCasier.onSendToCasierBtn.alert.msg2, function(btn){}, this);
+ } else {
+ if(!this.waitPanel){
+ this.waitPanel = new Ext.LoadMask("window", {msg: this.i18n.Cartable.SendToCasier.wait.msg});
+ }
+ this.waitPanel.show();
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: 'createMessageCasier',
+ content: this.contentField.getValue(),
+ destinatairesIM: Ext.util.JSON.encode(arrayDest),
+ attachFiles: Ext.util.JSON.encode(pjArray)
+ },
+ scope: this,
+ success: this.onSuccessSendMessage,
+ failure: this.onFailureSendMessage
+ });
+ }
+ },
+
+ onSuccessSendMessage: function(response, options) {
+ this.waitPanel.hide();
+ var backObj = Ext.decode(response.responseText);
+ if (backObj.success==false) {
+ if (backObj.portal_message) {
+ Ext.MessageBox.alert(this.i18n.Cartable.SendToCasier.onSuccessSendMessage.alert.title, backObj.portal_message, function(btn){});
+ } else {
+ Ext.MessageBox.alert(this.i18n.Cartable.SendToCasier.onSuccessSendMessage.alert.title, this.i18n.Cartable.SendToCasier.onSuccessSendMessage.alert.msg, function(btn){});
+ }
+ } else {
+ Ext.slideMsg.msg(this.i18n.Cartable.SendToCasier.onSuccessSendMessage.slideMsg.title, this.i18n.Cartable.SendToCasier.onSuccessSendMessage.slideMsg.msg);
+ this.hide();
+ xiti(userXitiId,roleXitiId,etabXitiId,serviceXitiId_courrier_elec,libServiceXiti_courrier_elec, true);
+ }
+ },
+
+ onFailureSendMessage: function(response, options) {
+ this.waitPanel.hide();
+ Ext.MessageBox.alert(this.i18n.Cartable.SendToCasier.onFailureSendMessage.alert.title, this.i18n.Cartable.SendToCasier.onFailureSendMessage.alert.msg, function(btn){});
+ },
+
+ onCancelFn: function(btn){
+ this.hide();
+ },
+
+ retirerMembres: function(btn){
+ var entityArray = this.membres_grid.getSelectionModel().getSelections();
+ for (var i=0; i < entityArray.length; i++) {
+ var rec = entityArray[i];
+ this.membres_store.remove(rec);
+ }
+ }
+
+});