--- /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.CantineCollege");
+EntSavoie.CantineCollege.ExportMenuWindow = 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.nameFileField = this.nameFileField || new Ext.form.TextField({
+ value: "Menu",
+ fieldLabel: "Nom du fichier",
+ anchor: "95%"
+ });
+
+ this.datePicker = this.datePicker || new Ext.ux.DatePickerRange({
+ style: "margin-left: 80px;",
+ selectionMode: "week"
+ });
+
+ this.exportRG = this.exportRG || new Ext.form.RadioGroup({
+ fieldLabel: "Type d'export",
+ itemCls: 'item',
+ width: 180,
+ items: [
+ {boxLabel: "Semaine", name: 'typeExport', inputValue: true, checked: true},
+ {boxLabel: "Jour", name: 'typeExport', inputValue: false}
+ ]
+ });
+
+ this.exportChooseRG = this.exportChooseRG || new Ext.form.RadioGroup({
+ fieldLabel: "Exporter les menus du",
+ itemCls: 'item',
+ width: 180,
+ items: [
+ {boxLabel: "Midi", name: 'chooseExport', inputValue: true, checked: true},
+ {boxLabel: "Soir", name: 'chooseExport', inputValue: false},
+ {boxLabel: "Les 2", name: 'chooseExport', inputValue: false}
+ ]
+ });
+
+ this.exportPanel = this.exportPanel || new Ext.form.FormPanel({
+ border: false,
+ bodyStyle:{"background-color": "#DFE8F6"},
+ labelWidth: 130,
+ items: [this.nameFileField, {border: false, bodyStyle:{"background-color": "#DFE8F6"}, html: "<br />"}, this.datePicker, {border: false, bodyStyle:{"background-color": "#DFE8F6"}, html: "<br />"}, this.exportRG, {border: false, bodyStyle:{"background-color": "#DFE8F6"}, html: "<br />"}, this.exportChooseRG]
+ });
+
+ this.validBtn = this.validBtn || new Ext.Button ({
+ text: "Valider",
+ handler: this.onValidFn,
+ scope: this
+ });
+
+ this.cancelBtn = this.cancelBtn || new Ext.Button ({
+ text: "Annuler",
+ handler: this.onCancelFn,
+ scope: this
+ });
+
+ /**
+ * Constructeur
+ */
+ EntSavoie.CantineCollege.ExportMenuWindow.superclass.constructor.call(this, {
+ cls: "cantine-portlet",
+ title: "Export du menu",
+ border: false,
+ height: 390,
+ width: 350,
+ layout: 'fit',
+ resizable: false,
+ closable: false,
+ modal: true,
+ bodyStyle:{"background-color": "#DFE8F6"},
+ padding: 10,
+ items: [this.exportPanel],
+ buttons: [this.validBtn, this.cancelBtn]
+ });
+
+ this.exportRG.on("change", this.onChangeExportRG, this);
+
+};
+
+Ext.extend(EntSavoie.CantineCollege.ExportMenuWindow, Ext.Window, {
+ initComponent: function () {
+ EntSavoie.CantineCollege.ExportMenuWindow.superclass.initComponent.call(this);
+ },
+
+ showExportWindow: function(date){
+ this.datePicker.setValue(date);
+ this.show();
+ },
+
+ onValidFn: function(btn){
+
+ this.wait = new Ext.LoadMask(this.id, {msg: "Export du menu en cours. <br /> <b> Veuillez patienter ... </b>"});
+ this.wait.show();
+
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: "exportMenu",
+ fileName: this.nameFileField.getValue(),
+ isWeek: this.exportRG.items.items[0].getValue(),
+ isMidi: this.exportChooseRG.items.items[0].getValue(),
+ isSoir: this.exportChooseRG.items.items[1].getValue(),
+ isAll: this.exportChooseRG.items.items[2].getValue(),
+ date: this.datePicker.getValue()
+ },
+ scope: this,
+ success: this.onSuccessExportMenu,
+ failure: this.onFailureExportMenu
+ });
+ },
+
+ onSuccessExportMenu: 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 {
+ Ext.slideMsg.msg("Export du menu", "L'export du menu au format pdf a été correctement réalisé.");
+ Ext.MessageBox.show({
+ title: "Export du Menu",
+ msg: backObj.hrefFile,
+ icon: Ext.MessageBox.INFO,
+ buttons: {yes:"OK"},
+ minWidth: 350
+ });
+ this.hide();
+ }
+ },
+
+ onFailureExportMenu: 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);
+ },
+
+ onCancelFn: function(btn){
+ this.hide();
+ },
+
+ onChangeExportRG: function(rg, radio){
+ if(this.exportRG.items.items[0].getValue()){
+ this.datePicker.setSelectionMode("week");
+ } else {
+ this.datePicker.setSelectionMode("day");
+ }
+ }
+
+});