dustin@760: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
dustin@760:  * Software engineering by Intevation GmbH
dustin@760:  *
dustin@760:  * This file is Free Software under the GNU GPL (v>=3)
dustin@760:  * and comes with ABSOLUTELY NO WARRANTY! Check out
dustin@760:  * the documentation coming with IMIS-Labordaten-Application for details.
dustin@760:  */
dustin@760: 
dustin@760: /*
dustin@760:  * Window to generate Proben from a Messprogramm
dustin@760:  */
dustin@760: Ext.define('Lada.view.window.GenProbenFromMessprogramm', {
dustin@760:     extend: 'Ext.window.Window',
dustin@760:     alias: 'widget.genpfm',
dustin@760: 
dustin@760:     collapsible: true,
dustin@760:     maximizable: true,
dustin@760:     autoShow: true,
dustin@760:     autoScroll: true,
dustin@760:     layout: 'fit',
dustin@760:     constrain: true,
dustin@760: 
dustin@760:     record: null,
dustin@760: 
dustin@760:     initComponent: function() {
dustin@760:         var i18n = Lada.getApplication().bundle;
dustin@760: 
dustin@760:         this.title = i18n.getMsg('gpfm.window.title');
dustin@760:         var me = this;
dustin@760:         this.buttons = [{
dustin@760:             text: i18n.getMsg('cancel'),
dustin@760:             scope: this,
dustin@760:             handler: this.close
dustin@760:         }, {
dustin@760:             text: i18n.getMsg('generateproben'),
dustin@760:             handler: function() {
dustin@760:                 var jsondata = {
dustin@760:                     id: me.record.id,
dustin@761:                     start: new Date(me.down('datetime [name=start]').getValue()).valueOf(),
dustin@761:                     end: new Date(me.down('datetime [name=end]').getValue()).valueOf()
dustin@760:                 };
dustin@760: 
dustin@760: 
dustin@760:                 Ext.Ajax.request({
dustin@760:                     url: '/lada-server/probe/messprogramm',
dustin@760:                     method: 'POST',
dustin@760:                     headers: {
dustin@760:                         'X-OPENID-PARAMS': Lada.openIDParams
dustin@760:                     },
dustin@760:                     jsonData: jsondata,
dustin@760:                     success: function(form, action) {
dustin@760:                         Ext.Msg.alert('Success', action.result.msg);
dustin@760:                     },
dustin@760:                     failure: function(form, action) {
dustin@760:                         Ext.Msg.alert('Failed', action.result.msg);
dustin@760:                     }
dustin@760:                 });
dustin@760:             }
dustin@760:         }];
dustin@760:         this.width = 400;
dustin@760:         this.height = 300;
dustin@760: 
dustin@760:         // add listeners to change the window appearence when it becomes inactive
dustin@760:         this.on({
dustin@760:             activate: function(){
dustin@760:                 this.getEl().removeCls('window-inactive');
dustin@760:             },
dustin@760:             deactivate: function(){
dustin@760:                 this.getEl().addCls('window-inactive');
dustin@760:             }
dustin@760:         });
dustin@760: 
dustin@760:         // InitialConfig is the config object passed to the constructor on
dustin@760:         // creation of this window. We need to pass it throuh to the form as
dustin@760:         // we need the "Id" param to load the correct item.
dustin@760:         this.items = [{
dustin@760:             border: 0,
dustin@760:             autoScroll: true,
dustin@760:             items: [{
dustin@760:                 xtype: 'text',
dustin@760:                 text: i18n.getMsg('nameofmessprogramm')+ ' '
dustin@760:             }, {
dustin@760:                 xtype: 'text',
dustin@760:                 text: this.record.get('name')
dustin@760:             }, {
dustin@760:                 xtype: 'text',
dustin@760:                 text: ' ' + i18n.getMsg('messprogtimeperiod')
dustin@760:             }, {
dustin@760:                 xtype: 'datetime',
dustin@760:                 fieldLabel: i18n.getMsg('from'),
dustin@760:                 labelWidth: 90,
dustin@760:                 name: 'start',
dustin@760:                 format: 'd.m.Y H:i',
dustin@760:                 period: 'start'
dustin@760:             }, {
dustin@760:                 xtype: 'datetime',
dustin@760:                 fieldLabel: i18n.getMsg('to'),
dustin@760:                 labelWidth: 90,
dustin@760:                 name: 'end',
dustin@760:                 format: 'd.m.Y H:i',
dustin@760:                 period: 'end'
dustin@760:             }]
dustin@760:         }];
dustin@760:         this.callParent(arguments);
dustin@760:     },
dustin@760: 
dustin@760:     /**
dustin@760:      * Init
dustin@760:      */
dustin@760:     initData: function() {
dustin@760:         var i18n = Lada.getApplication().bundle;
dustin@760:         me = this;
dustin@760:     },
dustin@760: });