File size: 2,383 Bytes
07c3cdd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Ext.onReady(function() {
  HeartFields = new Ext.form.FieldSet({
   
    title : _('ID_HEARTBEAT_DISPLAY'),
    items : [
      {
        xtype      : 'checkbox',
        checked    : heartBeatChecked,
        name       : 'acceptHB',
        fieldLabel : _('ID_TERMS_USE'),
        hideLabel  : true,
        id         : 'ch_ii',
        style      : 'margin-top:15px',
        boxLabel   : '<b>' + _('ID_ENABLE_HEART_BEAT') + '</b>',
        listeners : {
          check : function(){
            Ext.getCmp('btn_save').enable();
          }
        }

      },
      {
        xtype  : 'box',
        autoEl : { tag  : 'div', 
                   html : '<br />' + _('ID_HEART_BEAT_DETAILS_1') + _('ID_HEART_BEAT_DETAILS_2')
                          + '<br>' + _('ID_SEE') + ' <a href="' + 'http://wiki.processmaker.com/index.php/Heartbeat'
                          + '" target="_blank" align="center">' + _('ID_MORE_INFORMATION') + '</a>.'
                 },
        style : 'margin-left:20px'        
      }
    ],    
    buttons : [{
      id      : 'btn_save',
      text    : _('ID_SAVE'),
      disabled: true,
      handler : saveOption    
    }]
  });
  
  
  var frm = new Ext.FormPanel( {
    title         : '&nbsp',
    id            : 'frmHeart',
    labelWidth    : 150,
    width         : 600,
    labelAlign    : 'right',
    autoScroll    : true,
    bodyStyle     : 'padding:2px',
    waitMsgTarget : true,
    frame         : true,
    
    defaults: {
      allowBlank : false,
      msgTarget  : 'side',
      align      : 'center'
    },
    items : [ HeartFields ]
   
  });
  //render to process-panel
  frm.render(document.body);
});

function saveOption()
{
  Ext.getCmp('btn_save').disable();
  Ext.getCmp('frmHeart').getForm().submit( {  
    url     : 'processHeartBeatAjax?action=saveOption',
    waitMsg : _('ID_SAVING_PROCESS'),
    waitTitle : "&nbsp;",
    timeout : 36000,
    success : function(obj, resp) {
      //nothing to do
      response = Ext.decode(resp.response.responseText);
      if (response.enable) {
        parent.PMExt.notify(_('ID_HEARTBEAT_DISPLAY'), _('ID_HEART_BEAT_ENABLED'));        
      }
      else {
        parent.PMExt.notify(_('ID_HEARTBEAT_DISPLAY'), _('ID_HEART_BEAT_DISABLED'));
      }
    },
    failure : function(obj, resp) {
      Ext.Msg.alert( _('ID_ERROR'), resp.result.msg);
    }
  });
}