Pman.Tab.AdminNotify.bjs
[Pman.Admin] / Pman.Tab.AdminNotify.js
index 4a77155..b27e702 100644 (file)
@@ -2,91 +2,36 @@
 
 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
 
+Roo.namespace('Pman.Tab');
 
-
-// register the module first
-Pman.on('beforeload', function()
-{
-    Pman.register({
-        part :  ["Admin","Notify"],
-        modKey : '001-Pman.Tab.AdminNotify',
-        module : Pman.Tab.AdminNotify,
-        region : '',
-        parent : false,
-        name : "unnamed module",
-        disabled : false, 
-        permname: '' 
-    });
-});
-
-Pman.Tab.AdminNotify = new Roo.util.Observable({
-
-    panel : false,
-    disabled : false,
-    parentLayout:  false,
-
-    add : function(parentLayout, region)
+Pman.Tab.AdminNotify = new Roo.XComponent({
+    part     :  ["Admin", "Notify" ],
+    order    : '001-Pman.Tab.AdminNotify',
+    region   : 'center',
+    parent   : 'Pman.Tab.AdminWatchNotify',
+    name     : "Pman.Tab.AdminNotify",
+    disabled : false, 
+    permname : '', 
+    _tree : function()
     {
-
         var _this = this;
-        this.parentLayout = parentLayout;
-
-        this.panel = parentLayout.addxtype({
-            xtype: 'GridPanel',
-            xns: Roo,
-            listeners : {
-                activate : function() {
-                    _this.panel = this;
-                    if (_this.grid) {
-                        _this.grid.footer.onClick('first');
-                    }
-                }
-            },
-            background : true,
-            fitContainer : true,
-            fitToframe : true,
-            region : 'center',
-            tableName : 'core_notify',
-            title : "Notifications",
+        var MODULE = this;
+        return {
             grid : {
-                xtype: 'Grid',
-                xns: Roo.grid,
-                autoExpandColumn : 'ontable',
-                loadMask : true,
-                listeners : {
-                    render : function() 
-                    {
-                        _this.grid = this; 
-                        //_this.dialog = Pman.Dialog.FILL_IN
-                        if (_this.panel.active) {
-                           this.footer.onClick('first');
-                        }
-                    },
-                    rowdblclick : function (_self, rowIndex, e)
-                    {
-                        if (!_this.dialog) return;
-                        _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {
-                            _this.grid.footer.onClick('first');
-                        }); 
-                    }
-                },
                 dataSource : {
-                    xtype: 'Store',
-                    xns: Roo.data,
-                    remoteSort : true,
-                    sortInfo : { field : 'ontable', direction: 'ASC' },
                     proxy : {
-                        xtype: 'HttpProxy',
-                        xns: Roo.data,
+                        '|xns' : 'Roo.data',
+                        url : baseURL + '/Roo/core_notify.php',
                         method : 'GET',
-                        url : baseURL + '/Roo/core_notify.php'
+                        xtype : 'HttpProxy',
+                        xns : Roo.data
                     },
                     reader : {
-                        xtype: 'JsonReader',
-                        xns: Roo.data,
-                        totalProperty : 'total',
-                        root : 'data',
+                        '|xns' : 'Roo.data',
                         id : 'id',
+                        root : 'data',
+                        xtype : 'JsonReader',
+                        xns : Roo.data,
                         fields : [
                             {
                                 'name': 'id',
@@ -230,96 +175,342 @@ Pman.Tab.AdminNotify = new Roo.util.Observable({
                                 'name': 'event_id_remarks',
                                 'type': 'string'
                             }
-                        ]
-                    }
+                        ],
+                        totalProperty : 'total'
+                    },
+                    '|xns' : 'Roo.data',
+                    xtype : 'Store',
+                    remoteSort : true,
+                    sortInfo : { field : 'act_when', direction: 'DESC' },
+                    xns : Roo.data,
+                    listeners : {
+                       beforeload : function (_self, options)
+                          {
+                              options.params = options.params || {};
+                              
+                              options.params._evtype_align = 1;
+                              
+                              if (!_this.toggleBtn.pressed) {
+                                  options.params['event_id'] = 0;
+                              }
+                              if (!_this.personCombo) {
+                                  return false;
+                              }
+                              var p = _this.personCombo.getValue();
+                              if (p*1) { 
+                                  options.params.person_id = p;
+                              }
+                              
+                          }
+                    },
+                    items : [
+
+                    ]
+
                 },
                 footer : {
-                    xtype: 'PagingToolbar',
-                    xns: Roo,
+                    '|xns' : 'Roo',
                     pageSize : 25,
+                    xtype : 'PagingToolbar',
+                    emptyMsg : "No core_notify found",
+                    xns : Roo,
                     displayInfo : true,
-                    displayMsg : "Displaying core_notify{0} - {1} of {2}",
-                    emptyMsg : "No core_notify found"
+                    displayMsg : "Displaying core_notify{0} - {1} of {2}"
                 },
                 toolbar : {
-                    xtype: 'Toolbar',
-                    xns: Roo,
+                    '|xns' : 'Roo',
+                    xtype : 'Toolbar',
+                    xns : Roo,
                     items : [
-                        {
-                            xtype: 'Button',
-                            xns: Roo.Toolbar
+                       {
+                            store : {
+                                proxy : {
+                                    '|xns' : 'Roo.data',
+                                    url : baseURL + '/Roo/core_notify.php',
+                                    method : 'GET',
+                                    xtype : 'HttpProxy',
+                                    xns : Roo.data
+                                },
+                                reader : {
+                                    '|xns' : 'Roo.data',
+                                    id : 'id',
+                                    root : 'data',
+                                    xtype : 'JsonReader',
+                                    xns : Roo.data,
+                                    fields : [{"name":"id","type":"int"},{"name":"ontable","type":"string"}],
+                                    totalProperty : 'total'
+                                },
+                                '|xns' : 'Roo.data',
+                                xtype : 'Store',
+                                remoteSort : true,
+                                sortInfo : { direction : 'ASC', field: 'person_id_name' },
+                                xns : Roo.data,
+                                listeners : {
+                                       beforeload : function (_self, o){
+                                              o.params = o.params || {};
+                                              o.params._distinct='person_id';
+                                              o.params._columns='person_id,person_id_name,person_id_email';
+                                              o.params['!person_id_name'] = '';
+                                              
+                                              // set more here
+                                          }
+                                },
+                                items : [
+
+                                ]
+
+                            },
+                            '|xns' : 'Roo.form',
+                            listWidth : 400,
+                            triggerAction : 'all',
+                            forceSelection : true,
+                            selectOnFocus : true,
+                            pageSize : 20,
+                            displayField : 'person_id_name',
+                            emptyText : "Select person",
+                            hiddenName : 'id',
+                            minChars : 2,
+                            valueField : 'person_id',
+                            xtype : 'ComboBox',
+                            allowBlank : true,
+                            editable : true,
+                            width : 300,
+                            xns : Roo.form,
+                            name : 'name',
+                            qtip : "Select core_notify",
+                            queryParam : 'query[person_id_name]',
+                            tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{person_id_name}</b> {person_id_email}</div>',
+                            loadingText : "Searching...",
+                            listeners : {
+                               render : function (_self)
+                                  {
+                                     _this.personCombo = _self;
+                                  },
+                               select : function (combo, record, index)
+                                  {
+                                     _this.grid.footer.onClick('first');
+                                  }
+                            },
+                            items : [
+
+                            ]
+
+                        },
+                       {
+                            '|xns' : 'Roo.Toolbar',
+                            xtype : 'Separator',
+                            xns : Roo.Toolbar
+                        },
+                       {
+                            '|xns' : 'Roo.Toolbar',
+                            xtype : 'TextItem',
+                            xns : Roo.Toolbar
+                        },
+                       {
+                            '|xns' : 'Roo.form',
+                            format : 'd/M/Y',
+                            xtype : 'DateField',
+                            allowBlank : false,
+                            width : 100,
+                            xns : Roo.form,
+                            listeners : {
+                               render : function (_self)\r
+                                  {\r
+                                      _this.fromDateSel = _self;\r
+                                     _self.setValue(  new Date() );\r
+                                  },
+                               select : function (combo, date)
+                                  {
+                                      _this.grid.footer.onClick('first');
+                                  }
+                            }
+                        },
+                       {
+                            '|xns' : 'Roo.Toolbar',
+                            xtype : 'Fill',
+                            xns : Roo.Toolbar
+                        },
+                       {
+                            '|xns' : 'Roo.Toolbar',
+                            text : "Delete",
+                            xtype : 'Button',
+                            cls : 'x-btn-text-icon',
+                            icon : rootURL + '/Pman/templates/images/trash.gif',
+                            xns : Roo.Toolbar,
+                            listeners : {
+                               click : function()
+                                  {
+                                      Pman.genericDelete(_this, 'core_notify'); 
+                                  }
+                            }
+                        },
+                       {
+                            '|xns' : 'Roo.Toolbar',
+                            text : "Show Completed",
+                            enableToggle : true,
+                            xtype : 'Button',
+                            xns : Roo.Toolbar,
+                            listeners : {
+                               toggle : function (_self, pressed)
+                                  {
+                                      this.setText(pressed ? "Hide Completed" : "Show Completed");
+                                      _this.grid.footer.onClick('first');
+                                  },
+                               render : function (_self)
+                                  {
+                                      _this.toggleBtn = _self;
+                                  }
+                            }
                         }
                     ]
+
                 },
+                '|xns' : 'Roo.grid',
+                autoExpandColumn : 'person_id_name',
+                xtype : 'Grid',
+                loadMask : true,
+                xns : Roo.grid,
                 colModel : [
-                    {
-                        xtype: 'ColumnModel',
-                        xns: Roo.grid,
-                        header : 'Id',
-                        width : 75,
-                        dataIndex : 'id',
-                        renderer : function(v) { return String.format('{0}', v); }
-                    },
-                    {
-                        xtype: 'ColumnModel',
-                        xns: Roo.grid,
-                        header : 'Act when',
-                        width : 75,
-                        dataIndex : 'act_when',
-                        renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
-                    },
-                    {
-                        xtype: 'ColumnModel',
-                        xns: Roo.grid,
-                        header : 'Onid',
-                        width : 75,
-                        dataIndex : 'onid',
-                        renderer : function(v) { return String.format('{0}', v); }
-                    },
-                    {
-                        xtype: 'ColumnModel',
-                        xns: Roo.grid,
-                        header : 'Ontable',
-                        width : 200,
-                        dataIndex : 'ontable',
-                        renderer : function(v) { return String.format('{0}', v); }
-                    },
-                    {
-                        xtype: 'ColumnModel',
-                        xns: Roo.grid,
-                        header : 'Person',
-                        width : 75,
-                        dataIndex : 'person_id',
-                        renderer : function(v) { return String.format('{0}', v); }
-                    },
-                    {
-                        xtype: 'ColumnModel',
-                        xns: Roo.grid,
-                        header : 'Msgid',
-                        width : 200,
-                        dataIndex : 'msgid',
-                        renderer : function(v) { return String.format('{0}', v); }
-                    },
-                    {
-                        xtype: 'ColumnModel',
-                        xns: Roo.grid,
-                        header : 'Sent',
-                        width : 75,
-                        dataIndex : 'sent',
-                        renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
-                    },
-                    {
-                        xtype: 'ColumnModel',
-                        xns: Roo.grid,
-                        header : 'Event',
-                        width : 75,
-                        dataIndex : 'event_id',
-                        renderer : function(v) { return String.format('{0}', v); }
-                    }
+                        {
+                               '|xns' : 'Roo.grid',
+                               xtype : 'ColumnModel',
+                               sortable : true,
+                               header : 'id#',
+                               width : 50,
+                               renderer : function(v) { return String.format('{0}', v ); },
+                               xns : Roo.grid,
+                               dataIndex : 'id'
+                           },
+{
+                               '|xns' : 'Roo.grid',
+                               xtype : 'ColumnModel',
+                               sortable : true,
+                               header : 'Method',
+                               width : 200,
+                               renderer : function(v,x,r) 
+                               { 
+                                   var vv = (typeof(r.data.evtype_align) != 'undefined' && r.data.evtype_align) ? r.data.evtype_align : v;
+                                   return String.format('<span qtip="{0}">{1}</span>', v, vv ); 
+                               },
+                               xns : Roo.grid,
+                               dataIndex : 'evtype'
+                           },
+{
+                               '|xns' : 'Roo.grid',
+                               xtype : 'ColumnModel',
+                               sortable : true,
+                               header : 'Act when',
+                               width : 150,
+                               renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y H:i:s') : ''); },
+                               xns : Roo.grid,
+                               dataIndex : 'act_when'
+                           },
+{
+                               '|xns' : 'Roo.grid',
+                               xtype : 'ColumnModel',
+                               sortable : true,
+                               header : 'Sent',
+                               width : 150,
+                               renderer : function(v,x,r) {
+                                   if (r.data.event_id *1 == 0) {
+                                       return '';
+                                   }
+                                    return String.format('{0}', v ? v.format('d/M/Y H:i:s') : '');
+                                 },
+                               xns : Roo.grid,
+                               dataIndex : 'sent'
+                           },
+{
+                               '|xns' : 'Roo.grid',
+                               xtype : 'ColumnModel',
+                               header : 'Ontable',
+                               width : 150,
+                               renderer : function(v,x,r) { return String.format('{0}:{1}', v,r.data.onid); },
+                               xns : Roo.grid,
+                               dataIndex : 'ontable'
+                           },
+{
+                               '|xns' : 'Roo.grid',
+                               xtype : 'ColumnModel',
+                               header : 'Who to notify',
+                               width : 100,
+                               renderer : function(v,x,r) {
+                                    return String.format('{0} <u>&lt;{1}&gt;</u>', v, r.data.person_id_email); 
+                                },
+                               xns : Roo.grid,
+                               dataIndex : 'person_id_name'
+                           },
+{
+                               '|xns' : 'Roo.grid',
+                               xtype : 'ColumnModel',
+                               header : 'Triggered by',
+                               width : 100,
+                               renderer : function(v,x,r) {
+                                    return String.format(
+                                           '{0} : {1} {2}', 
+                                           r.data.trigger_event_id_on_table, 
+                                           r.data.trigger_event_id_on_id, 
+                                           r.data.trigger_event_id_remarks
+                                       ); 
+                                },
+                               xns : Roo.grid,
+                               dataIndex : 'trigger_event_id'
+                           },
+{
+                               '|xns' : 'Roo.grid',
+                               xtype : 'ColumnModel',
+                               width : 200,
+                               header : 'Msgid',
+                               renderer : function(v) { return String.format('{0}', v); },
+                               xns : Roo.grid,
+                               dataIndex : 'msgid'
+                           },
+{
+                               '|xns' : 'Roo.grid',
+                               xtype : 'ColumnModel',
+                               header : 'Event',
+                               width : 300,
+                               renderer : function(v) { return String.format('<span qtip="{0}">{0}</span>', v); },
+                               xns : Roo.grid,
+                               dataIndex : 'event_id_remarks'
+                           }
+                ],
+                listeners : {
+                       render : function() 
+                          {
+                              _this.grid = this; 
+                              //_this.dialog = Pman.Dialog.FILL_IN
+                              if (_this.panel.active) {
+                                 this.footer.onClick('first');
+                              }
+                          }
+                },
+                items : [
+
                 ]
-            }
-        });
-        this.layout = this.panel.layout;
 
-    }
+            },
+            '|xns' : 'Roo',
+            fitToframe : true,
+            background : true,
+            region : 'center',
+            title : "Current Notifications",
+            xtype : 'GridPanel',
+            fitContainer : true,
+            xns : Roo,
+            tableName : 'core_notify',
+            listeners : {
+               activate : function() {
+                      _this.panel = this;
+                      if (_this.grid) {
+                          _this.grid.footer.onClick('first');
+                      }
+                      
+                  }
+            },
+            items : [
+
+            ]
+
+        };    }
 });