--- /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.CantineDepartement");
+EntSavoie.CantineDepartement.Aliment = 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';
+
+ /***************************************************
+ * FAMILLES D'ALIMENTS
+ ***************************************************/
+
+ this.familleAlimentStore = this.familleAlimentStore || new Ext.data.JsonStore({
+ autoLoad: true,
+ root: 'familles',
+ idProperty: 'familleAlimentId',
+ fields: [
+ 'familleAlimentId',
+ 'nomFamille'
+ ],
+ sortInfo: {
+ field: 'nomFamille',
+ direction: 'ASC'
+ },
+ url: this.renderURLAjax+'&jspPage=%2Fajax%2FlistFamilleAliment.jsp'
+ });
+
+ this.cmFamilleAliment = this.cmFamilleAliment || new Ext.grid.ColumnModel({
+ columns: [
+ {
+ header: "Famille d'aliments",
+ dataIndex: 'nomFamille',
+ id: 'nomFamille'
+ }
+ ]
+ });
+
+ this.addFamilleAlimentBtn = this.addFamilleAlimentBtn || new Ext.Button({
+ iconCls: 'cantineAdd',
+ handler: this.onAddFamilleAliment,
+ tooltip: "Ajouter une nouvelle famille",
+ scope: this
+ });
+
+ this.deleteFamilleAlimentBtn = this.deleteFamilleAlimentBtn || new Ext.Button({
+ iconCls: 'cantineDelete',
+ handler: this.onDeleteFamilleAliment,
+ tooltip: "Supprimer la(les) famille(s) sélectionnée(s)",
+ scope: this
+ });
+
+ this.editFamilleAlimentBtn = this.editFamilleAlimentBtn || new Ext.Button({
+ iconCls: 'cantineEdit',
+ handler: this.onEditFamilleAliment,
+ tooltip: "Renommer la(les) famille(s) sélectionnée(s)",
+ scope: this
+ });
+
+ this.editFamilleAlimentWindow = this.editFamilleAlimentWindow || new Ext.Window({
+ cls: "cantine-portlet",
+ title: "Edition des familles",
+ modal: true,
+ width: 450,
+ height: 200,
+ layout: 'form',
+ closable: false,
+ autoScroll: true,
+ padding: 10,
+ buttons: [{
+ text: "Valider",
+ handler: this.onValideEditFamilleAliment,
+ scope: this
+ },
+ {
+ text: "Annuler",
+ handler: this.onCancelEditFamilleAliment,
+ scope: this
+ }
+ ]
+ });
+
+ this.familleGridPanel = this.familleGridPanel || new Ext.grid.GridPanel({
+ store: this.familleAlimentStore,
+ cm: this.cmFamilleAliment,
+ buttonAlign: "left",
+ autoExpandColumn: 'nomFamille',
+ bbar: [this.addFamilleAlimentBtn, this.deleteFamilleAlimentBtn, this.editFamilleAlimentBtn]
+ });
+
+
+ /***************************************************
+ * ALIMENTS
+ ***************************************************/
+
+ this.alimentStore = this.alimentStore || new Ext.data.JsonStore({
+ root: 'aliments',
+ idProperty: 'alimentId',
+ fields: [
+ 'alimentId',
+ 'nomAliment',
+ 'protide',
+ 'lipide',
+ 'glucide',
+ 'calcium'
+ ],
+ sortInfo: {
+ field: 'nomAliment',
+ direction: 'ASC'
+ },
+ url: this.renderURLAjax+'&jspPage=%2Fajax%2FlistAliment.jsp'
+ });
+
+ this.cmAliment = this.cmAliment || new Ext.grid.ColumnModel({
+ columns: [
+ {
+ header: "Nom",
+ dataIndex: 'nomAliment',
+ id: 'nomAliment'
+ },
+ {
+ header: "Protide",
+ dataIndex: 'protide'
+ },
+ {
+ header: "Lipide",
+ dataIndex: 'lipide'
+ },
+ {
+ header: "Glucide",
+ dataIndex: 'glucide'
+ },
+ {
+ header: "Calcium",
+ dataIndex: 'calcium'
+ }
+ ]
+ });
+
+ this.addAlimentBtn = this.addAlimentBtn || new Ext.Button({
+ iconCls: 'cantineAdd',
+ handler: this.onAddAliment,
+ tooltip: "Ajouter un nouvel aliment",
+ scope: this
+ });
+
+ this.deleteAlimentBtn = this.deleteAlimentBtn || new Ext.Button({
+ iconCls: 'cantineDelete',
+ handler: this.onDeleteAliment,
+ tooltip: "Supprimer l'(les) aliment(s) sélectionné(s)",
+ scope: this
+ });
+
+ this.editAlimentBtn = this.editAlimentBtn || new Ext.Button({
+ iconCls: 'cantineEdit',
+ handler: this.onEditAliment,
+ tooltip: "Editer l'(les) aliment(s) sélectionné(s)",
+ scope: this
+ });
+
+ this.alimentGridPanel = this.alimentGridPanel || new Ext.grid.GridPanel({
+ title: "Valeurs nutrionnelles pour 100g d'aliment comestible",
+ store: this.alimentStore,
+ cm: this.cmAliment,
+ autoExpandColumn: 'nomAliment',
+ buttonAlign: "left",
+ bbar: [this.addAlimentBtn, this.deleteAlimentBtn, this.editAlimentBtn]
+ });
+
+ this.addOrEditAlimentWindow = this.addOrEditAlimentWindow || new Ext.Window({
+ cls: "cantine-portlet",
+ title: "Ajout d'un aliment",
+ modal: true,
+ width: 450,
+ height: 200,
+ closable: false,
+ autoScroll: true,
+ padding: 10,
+ buttons: [{
+ text: "Valider",
+ handler: this.onValidAlimentAction,
+ scope: this
+ },
+ {
+ text: "Annuler",
+ handler: this.onCancelAlimentAction,
+ scope: this
+ }
+ ]
+ });
+
+ /**
+ * Constructeur
+ */
+ EntSavoie.CantineDepartement.Aliment.superclass.constructor.call(this, {
+ border: false,
+ layout: 'border',
+ height: 630,
+ width: "auto",
+ title: "Table CIQUAL",
+ monitorResize: true,
+ defaults: {
+ collapsible: false,
+ split: false,
+ border: false
+ },
+ items: [
+ {
+ width: 300,
+ region: "west",
+ border: false,
+ layout: 'fit',
+ items: [this.familleGridPanel]
+ },{
+ region: "center",
+ width: "auto",
+ border: false,
+ layout: 'fit',
+ items: [this.alimentGridPanel]
+ }
+ ]
+ });
+
+ this.familleGridPanel.on("rowclick", this.onRowClickFamilleGridPanel, this);
+
+};
+
+Ext.extend(EntSavoie.CantineDepartement.Aliment, Ext.Panel, {
+ initComponent: function () {
+ EntSavoie.CantineDepartement.Aliment.superclass.initComponent.call(this);
+ },
+
+ /***************************************************
+ * FAMILLES D'ALIMENTS
+ ***************************************************/
+ onRowClickFamilleGridPanel: function(grid, rowIndex, e){
+ var record = grid.getStore().getAt(rowIndex);
+ this.familleId = record.get("familleAlimentId");
+ this.alimentStore.load({params:{familleAlimentId: record.get("familleAlimentId")}})
+ },
+
+ onAddFamilleAliment : function(btn){
+ Ext.MessageBox.show({
+ title: "Ajout d'une nouvelle famille",
+ msg: "Nom de la famille :",
+ buttons: {yes:"Valider", no:"Annuler"},
+ value: "Famille",
+ fn: this.onAddFamilleAlimentCall,
+ prompt: true,
+ minWidth:250,
+ scope: this
+ });
+ },
+
+ onAddFamilleAlimentCall: function(btn, nomFamille){
+ if (btn=="no") {
+ return false;
+ }
+
+ this.wait = new Ext.LoadMask(Ext.getBody(), {msg: "<b>Ajout de la famille en cours</b> <br/> Veuillez patienter ..."});
+ this.wait.show();
+
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: "addFamilleAliment",
+ nomFamille: nomFamille
+ },
+ scope: this,
+ success: this.onSuccessAddFamilleAliment,
+ failure: this.onFailureAddFamilleAliment
+ });
+ },
+
+ onSuccessAddFamilleAliment: 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 famille = new this.familleAlimentStore.recordType({
+ familleAlimentId: backObj.familleAlimentId,
+ nomFamille: backObj.nomFamille
+ }, backObj.familleAlimentId);
+
+ this.familleAlimentStore.addSorted(famille);
+ Ext.slideMsg.msg("Ajout d'une famille", "La famille d'aliment a correctement été ajoutée.");
+ }
+ },
+
+ onFailureAddFamilleAliment: 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);
+ },
+
+ onDeleteFamilleAliment: function(btn){
+ var familles = this.familleGridPanel.getSelectionModel().getSelections();
+ if(familles.length>0){
+ Ext.MessageBox.show({
+ title: "Suppression des familles sélectionnées",
+ msg: "Ces familles peuvent contenir plusieurs aliments qui eux même peuvent appartenir à des recettes. <br /> Souhaitez-vous continuer ?",
+ buttons: {yes: "Oui", no: "Non"},
+ fn: this.onDeleteFamilleAliementCall,
+ animEl: 'confirmBtn',
+ icon: Ext.MessageBox.QUESTION,
+ minWidth: 350,
+ scope: this
+ });
+ }
+ },
+
+ onDeleteFamilleAliementCall: function(btn){
+ if (btn=="no") {
+ return false;
+ }
+
+ this.wait = new Ext.LoadMask(Ext.getBody(), {msg: "Suppression des familles de en cours. <br /> <b> Veuillez patienter ... </b>"});
+ this.wait.show();
+
+ var familles = this.familleGridPanel.getSelectionModel().getSelections();
+ var listFamilleId = new Array();
+
+ for(i=0; i<familles.length; i++){
+ var famille = familles[i];
+ listFamilleId.push(famille.get("familleAlimentId"));
+ }
+
+
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: "deleteFamilleAliment",
+ listFamilleId: Ext.util.JSON.encode(listFamilleId)
+ },
+ scope: this,
+ success: this.onSuccessDeleteFamilleAliement,
+ failure: this.onFailureDeleteFamilleAliement
+ });
+ },
+
+ onSuccessDeleteFamilleAliement: 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 familles = this.familleGridPanel.getSelectionModel().getSelections();
+ this.familleAlimentStore.remove(familles);
+ this.familleId = null;
+ Ext.slideMsg.msg("Suppression des familles", "Les familles d'aliment ont correctement été supprimées.");
+ }
+ },
+
+ onFailureDeleteFamilleAliement: 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);
+ },
+
+ onEditFamilleAliment: function(btn){
+ var familles = this.familleGridPanel.getSelectionModel().getSelections();
+
+ if(familles.length>0){
+ for(i=0; i<familles.length; i++){
+ var famille = familles[i];
+ this.editFamilleAlimentWindow.add({
+ xtype: 'displayfield',
+ fieldLabel: "Famille",
+ value: famille.get("nomFamille"),
+ labelStyle: 'padding: 0 0 0 0'
+ });
+ this.editFamilleAlimentWindow.add({
+ id: famille.get("familleAlimentId"),
+ xtype: 'textfield',
+ name: 'renameFamilleField',
+ fieldLabel: "Nouveau nom",
+ value: famille.get("nomFamille"),
+ allowBlank: false,
+ width: 300,
+ style: 'margin-bottom: 20px;',
+ scope: this
+ });
+ }
+ this.editFamilleAlimentWindow.show();
+ }
+ },
+
+ onValideEditFamilleAliment: function(btn){
+
+ this.wait = new Ext.LoadMask(this.editFamilleAlimentWindow.id, {msg: "Edition des familles de en cours. <br /> <b> Veuillez patienter ... </b>"});
+ this.wait.show();
+
+ var fields = this.editFamilleAlimentWindow.find('name', 'renameFamilleField');
+ var familles = new Array();
+ for(i=0; i<fields.length; i++){
+ var field = fields[i];
+ var famille = {
+ familleAlimentId: field.id,
+ nomFamille: field.getValue()
+ };
+ familles.push(famille);
+ }
+
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: "editFamilleAliment",
+ familles: Ext.util.JSON.encode(familles)
+ },
+ scope: this,
+ success: this.onSuccessEditFamilleAliement,
+ failure: this.onFailureEditFamilleAliement
+ });
+ },
+
+ onSuccessEditFamilleAliement: 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 fields = this.editFamilleAlimentWindow.find('name', 'renameFamilleField');
+ for(i=0; i<fields.length; i++){
+ var field = fields[i];
+ var famille = this.familleAlimentStore.getById(field.id);
+ famille.set("nomFamille", field.getValue());
+ }
+ this.familleAlimentStore.sort('nomFamille', 'ASC');
+ this.editFamilleAlimentWindow.removeAll(true);
+ this.editFamilleAlimentWindow.hide();
+ Ext.slideMsg.msg("Edition des familles", "Les familles d'aliment ont correctement été éditées.");
+ }
+ },
+
+ onFailureEditFamilleAliement: 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);
+ },
+
+ onCancelEditFamilleAliment: function(btn){
+ this.editFamilleAlimentWindow.removeAll(true);
+ this.editFamilleAlimentWindow.hide();
+ },
+
+ /***************************************************
+ * ALIMENTS
+ ***************************************************/
+
+ onAddAliment: function(btn){
+ if(this.familleId != null){
+ this.alimentAction = "addAliment";
+
+ this.addOrEditAlimentWindow.setTitle("Ajout d'un aliment");
+
+ var patternAlimentPanel = new Ext.form.FieldSet({
+ width: 410,
+ checkboxToggle:false,
+ title: "Nouvel Aliment",
+ autoHeight:true,
+ padding: 0,
+ labelWidth: 120,
+ style: 'margin-bottom: 20px;',
+ items:[
+ {
+ xtype: 'textfield',
+ fieldLabel: "Nom de l'aliment",
+ value: "Aliment",
+ allowBlank: false,
+ width: 250,
+ scope: this
+ },
+ {
+ xtype: 'panel',
+ border: 'false',
+ layout: "table",
+ border: false,
+ bodyStyle:{"background-color": "#DFE8F6"},
+ layoutConfig: {
+ columns: 4
+ },
+ items: [
+ {
+ xtype: 'panel',
+ layout: 'form',
+ border: false,
+ labelWidth: 45,
+ bodyStyle:{"background-color": "#DFE8F6"},
+ items: [
+ {
+ xtype: 'numberfield',
+ fieldLabel: "Protide",
+ value: 0,
+ allowBlank: false,
+ width: 35,
+ scope: this
+ }
+ ]
+ },
+ {
+ xtype: 'panel',
+ layout: 'form',
+ border: false,
+ labelWidth: 45,
+ style: 'margin-left: 12px;',
+ bodyStyle:{"background-color": "#DFE8F6"},
+ items: [
+ {
+ xtype: 'numberfield',
+ fieldLabel: "Lipide",
+ value: 0,
+ allowBlank: false,
+ width: 35,
+ scope: this
+ }
+ ]
+ },
+ {
+ xtype: 'panel',
+ layout: 'form',
+ border: false,
+ labelWidth: 45,
+ bodyStyle:{"background-color": "#DFE8F6"},
+ style: 'margin-left: 12px;',
+ items: [
+ {
+ xtype: 'numberfield',
+ fieldLabel: "Glucide",
+ value: 0,
+ allowBlank: false,
+ width: 35,
+ scope: this
+ }
+ ]
+ },
+ {
+ xtype: 'panel',
+ layout: 'form',
+ border: false,
+ labelWidth: 45,
+ bodyStyle:{"background-color": "#DFE8F6"},
+ style: 'margin-left: 12px;',
+ items: [
+ {
+ xtype: 'numberfield',
+ fieldLabel: "Calcium",
+ value: 0,
+ allowBlank: false,
+ width: 35,
+ scope: this
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ });
+
+ this.addOrEditAlimentWindow.add(patternAlimentPanel);
+ this.addOrEditAlimentWindow.show();
+ } else {
+ Ext.MessageBox.alert("Attention", "Pour pouvoir ajouter un nouvel aliment, veuillez sélectionner sa famille d'appartenance.", function(btn){}, this);
+ }
+ },
+
+ onValidAlimentAction: function(btn){
+
+ //Ajout
+ if(this.alimentAction == "addAliment"){
+ this.wait = new Ext.LoadMask(this.addOrEditAlimentWindow.id, {msg: "<b>Ajout de l'aliment en cours</b> <br/> Veuillez patienter ..."});
+ }
+ //Edition
+ else {
+ this.wait = new Ext.LoadMask(this.addOrEditAlimentWindow.id, {msg: "<b>Edition des aliments en cours</b> <br/> Veuillez patienter ..."});
+ }
+
+ this.wait.show();
+
+ var fieldSets = this.addOrEditAlimentWindow.items;
+ var aliments = new Array();
+
+ for(i=0; i<fieldSets.length; i++){
+ var fieldSet = fieldSets.get(i);
+ var aliment = {
+ alimentId: fieldSet.id,
+ nomAliment: fieldSet.items.get(0).getValue(),
+ protide: fieldSet.items.get(1).items.get(0).items.get(0).getValue(),
+ lipide: fieldSet.items.get(1).items.get(1).items.get(0).getValue(),
+ glucide: fieldSet.items.get(1).items.get(2).items.get(0).getValue(),
+ calcium: fieldSet.items.get(1).items.get(3).items.get(0).getValue()
+ };
+ aliments.push(aliment);
+ }
+
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: this.alimentAction,
+ familleAlimentId: this.familleId,
+ aliments: Ext.util.JSON.encode(aliments)
+ },
+ scope: this,
+ success: this.onSuccessAlimentAction,
+ failure: this.onFailureAlimentAction
+ });
+ },
+
+ onSuccessAlimentAction: 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 {
+
+ //Ajout
+ if(this.alimentAction == "addAliment"){
+ var aliment = new this.alimentStore.recordType({
+ alimentId: backObj.alimentId,
+ nomAliment: backObj.nomAliment,
+ protide: backObj.protide,
+ lipide: backObj.lipide,
+ glucide: backObj.glucide,
+ calcium: backObj.calcium
+ }, backObj.alimentId);
+
+ this.alimentStore.addSorted(aliment);
+ Ext.slideMsg.msg("Ajout d'un aliment", "L'aliment a correctement été ajouté.");
+ }
+ //Edition
+ else {
+ var fieldSets = this.addOrEditAlimentWindow.items;
+
+ for(i=0; i<fieldSets.length; i++){
+ var fieldSet = fieldSets.get(i);
+ var aliment = this.alimentStore.getById(fieldSet.id);
+ aliment.set("nomAliment", fieldSet.items.get(0).getValue());
+ aliment.set("protide", fieldSet.items.get(1).items.get(0).items.get(0).getValue());
+ aliment.set("lipide", fieldSet.items.get(1).items.get(1).items.get(0).getValue());
+ aliment.set("glucide", fieldSet.items.get(1).items.get(2).items.get(0).getValue());
+ aliment.set("calcium", fieldSet.items.get(1).items.get(3).items.get(0).getValue());
+ }
+
+ this.alimentStore.sort("nomAliment", "ASC");
+ Ext.slideMsg.msg("Edition des aliments", "Les aliments ont correctement été édités.");
+ }
+
+ this.addOrEditAlimentWindow.removeAll(true);
+ this.addOrEditAlimentWindow.hide();
+ }
+ },
+
+ onFailureAlimentAction: 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);
+ },
+
+ onCancelAlimentAction: function(btn){
+ this.addOrEditAlimentWindow.removeAll(true);
+ this.addOrEditAlimentWindow.hide();
+ },
+
+ onDeleteAliment: function(btn){
+ var aliments = this.alimentGridPanel.getSelectionModel().getSelections();
+ if(aliments.length>0){
+ Ext.MessageBox.show({
+ title: "Suppression des aliments sélectionnés",
+ msg: "Ces aliments peuvent appartenir à des recettes. <br /> Souhaitez-vous continuer ?",
+ buttons: {yes: "Oui", no: "Non"},
+ fn: this.onDeleteAliementCall,
+ animEl: 'confirmBtn',
+ icon: Ext.MessageBox.QUESTION,
+ minWidth: 350,
+ scope: this
+ });
+ }
+ },
+
+ onDeleteAliementCall: function(btn){
+ if (btn=="no") {
+ return false;
+ }
+
+ this.wait = new Ext.LoadMask(Ext.getBody(), {msg: "Suppression des aliments de en cours. <br /> <b> Veuillez patienter ... </b>"});
+ this.wait.show();
+
+ var aliments = this.alimentGridPanel.getSelectionModel().getSelections();
+ var listAlimentId = new Array();
+
+ for(i=0; i<aliments.length; i++){
+ var aliment = aliments[i];
+ listAlimentId.push(aliment.get("alimentId"));
+ }
+
+
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: "deleteAliment",
+ listAlimentId: Ext.util.JSON.encode(listAlimentId)
+ },
+ scope: this,
+ success: this.onSuccessDeleteAliement,
+ failure: this.onFailureDeleteAliement
+ });
+ },
+
+ onSuccessDeleteAliement: 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 aliments = this.alimentGridPanel.getSelectionModel().getSelections();
+ this.alimentStore.remove(aliments);
+ Ext.slideMsg.msg("Suppression des aliments", "Les aliments ont correctement été supprimés.");
+ }
+ },
+
+ onFailureDeleteAliement: 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);
+ },
+
+ onEditAliment: function(btn){
+
+ var aliments = this.alimentGridPanel.getSelectionModel().getSelections();
+
+ if(aliments.length>0){
+
+ this.alimentAction = "editAliment";
+ this.addOrEditAlimentWindow.setTitle("Edition des aliments");
+
+ for(i=0; i<aliments.length; i++){
+
+ var aliment = aliments[i];
+
+ var patternAlimentPanel = new Ext.form.FieldSet({
+ id: aliment.get("alimentId"),
+ width: 400,
+ checkboxToggle:false,
+ title: aliment.get("nomAliment"),
+ autoHeight:true,
+ padding: 0,
+ labelWidth: 120,
+ style: 'margin-bottom: 20px;',
+ items:[
+ {
+ xtype: 'textfield',
+ fieldLabel: "Nom de l'aliment",
+ value: aliment.get("nomAliment"),
+ allowBlank: false,
+ width: 250,
+ scope: this
+ },
+ {
+ xtype: 'panel',
+ border: 'false',
+ layout: "table",
+ border: false,
+ bodyStyle:{"background-color": "#DFE8F6"},
+ layoutConfig: {
+ columns: 4
+ },
+ items: [
+ {
+ xtype: 'panel',
+ layout: 'form',
+ border: false,
+ labelWidth: 45,
+ bodyStyle:{"background-color": "#DFE8F6"},
+ items: [
+ {
+ xtype: 'numberfield',
+ fieldLabel: "Protide",
+ value: aliment.get("protide"),
+ allowBlank: false,
+ width: 35,
+ scope: this
+ }
+ ]
+ },
+ {
+ xtype: 'panel',
+ layout: 'form',
+ border: false,
+ labelWidth: 45,
+ style: 'margin-left: 12px;',
+ bodyStyle:{"background-color": "#DFE8F6"},
+ items: [
+ {
+ xtype: 'numberfield',
+ fieldLabel: "Lipide",
+ value: aliment.get("lipide"),
+ allowBlank: false,
+ width: 35,
+ scope: this
+ }
+ ]
+ },
+ {
+ xtype: 'panel',
+ layout: 'form',
+ border: false,
+ labelWidth: 45,
+ bodyStyle:{"background-color": "#DFE8F6"},
+ style: 'margin-left: 12px;',
+ items: [
+ {
+ xtype: 'numberfield',
+ fieldLabel: "Glucide",
+ value: aliment.get("glucide"),
+ allowBlank: false,
+ width: 35,
+ scope: this
+ }
+ ]
+ },
+ {
+ xtype: 'panel',
+ layout: 'form',
+ border: false,
+ labelWidth: 45,
+ bodyStyle:{"background-color": "#DFE8F6"},
+ style: 'margin-left: 12px;',
+ items: [
+ {
+ xtype: 'numberfield',
+ fieldLabel: "Calcium",
+ value: aliment.get("calcium"),
+ allowBlank: false,
+ width: 35,
+ scope: this
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ });
+
+ this.addOrEditAlimentWindow.add(patternAlimentPanel);
+ }
+ this.addOrEditAlimentWindow.show();
+ }
+ }
+
+});