Pman.Tab.XtupleReports.bjs
authorAlan Knowles <alan@roojs.com>
Wed, 18 Dec 2013 12:02:52 +0000 (20:02 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 18 Dec 2013 12:02:52 +0000 (20:02 +0800)
Pman.Tab.XtupleReports.js

Pman.Tab.XtupleReports.bjs
Pman.Tab.XtupleReports.js

index ebb7ad9..e98032f 100644 (file)
                             "*prop": "east",
                             "xtype": "LayoutRegion",
                             "|xns": "Roo"
+                        },
+                        {
+                            "|xns": "Roo",
+                            "xtype": "GridPanel",
+                            "title": "report",
+                            "fitToframe": true,
+                            "fitContainer": true,
+                            "tableName": "report",
+                            "background": true,
+                            "region": "center",
+                            "listeners": {
+                                "|activate": "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
+                            },
+                            "items": [
+                                {
+                                    "*prop": "grid",
+                                    "xtype": "Grid",
+                                    "autoExpandColumn": "report_name",
+                                    "loadMask": true,
+                                    "listeners": {
+                                        "|render": "function() \n{\n    _this.grid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.panel.active) {\n       this.footer.onClick('first');\n    }\n}",
+                                        "|rowdblclick": "function (_self, rowIndex, e)\n{\n    if (!_this.dialog) return;\n    _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {\n        _this.grid.footer.onClick('first');\n    }); \n}\n"
+                                    },
+                                    "|xns": "Roo.grid",
+                                    "items": [
+                                        {
+                                            "*prop": "dataSource",
+                                            "xtype": "Store",
+                                            "remoteSort": true,
+                                            "|sortInfo": "{ field : 'report_name', direction: 'ASC' }",
+                                            "|xns": "Roo.data",
+                                            "items": [
+                                                {
+                                                    "*prop": "proxy",
+                                                    "xtype": "HttpProxy",
+                                                    "method": "GET",
+                                                    "|url": "baseURL + '/Roo/report.php'",
+                                                    "|xns": "Roo.data"
+                                                },
+                                                {
+                                                    "|xns": "Roo.data",
+                                                    "xtype": "JsonReader",
+                                                    "totalProperty": "total",
+                                                    "root": "data",
+                                                    "*prop": "reader",
+                                                    "id": "id",
+                                                    "|fields": "[\n    {\n        'name': 'report_id',\n        'type': 'int'\n    },\n    {\n        'name': 'report_name',\n        'type': 'string'\n    },\n    {\n        'name': 'report_sys',\n        'type': 'int'\n    },\n    {\n        'name': 'report_source',\n        'type': 'string'\n    },\n    {\n        'name': 'report_descrip',\n        'type': 'string'\n    },\n    {\n        'name': 'report_grade',\n        'type': 'int'\n    },\n    {\n        'name': 'report_loaddate',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    }\n]"
+                                                }
+                                            ]
+                                        },
+                                        {
+                                            "*prop": "footer",
+                                            "xtype": "PagingToolbar",
+                                            "pageSize": 25,
+                                            "displayInfo": true,
+                                            "displayMsg": "Displaying report{0} - {1} of {2}",
+                                            "emptyMsg": "No report found",
+                                            "|xns": "Roo"
+                                        },
+                                        {
+                                            "*prop": "toolbar",
+                                            "xtype": "Toolbar",
+                                            "|xns": "Roo",
+                                            "items": [
+                                                {
+                                                    "text": "Add",
+                                                    "xtype": "Button",
+                                                    "cls": "x-btn-text-icon",
+                                                    "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
+                                                    "listeners": {
+                                                        "|click": "function()\n{\n    if (!_this.dialog) return;\n    _this.dialog.show( { id : 0 } , function() {\n        _this.grid.footer.onClick('first');\n   }); \n}\n"
+                                                    },
+                                                    "|xns": "Roo.Toolbar"
+                                                },
+                                                {
+                                                    "text": "Edit",
+                                                    "xtype": "Button",
+                                                    "cls": "x-btn-text-icon",
+                                                    "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'",
+                                                    "listeners": {
+                                                        "|click": "function()\n{\n    var s = _this.grid.getSelectionModel().getSelections();\n    if (!s.length || (s.length > 1))  {\n        Roo.MessageBox.alert(\"Error\", s.length ? \"Select only one Row\" : \"Select a Row\");\n        return;\n    }\n    if (!_this.dialog) return;\n    _this.dialog.show(s[0].data, function() {\n        _this.grid.footer.onClick('first');\n    }); \n    \n}\n"
+                                                    },
+                                                    "|xns": "Roo.Toolbar"
+                                                },
+                                                {
+                                                    "text": "Delete",
+                                                    "cls": "x-btn-text-icon",
+                                                    "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
+                                                    "xtype": "Button",
+                                                    "listeners": {
+                                                        "|click": "function()\n{\n     Pman.genericDelete(_this, 'report'); \n}\n        "
+                                                    },
+                                                    "|xns": "Roo.Toolbar"
+                                                }
+                                            ]
+                                        },
+                                        {
+                                            "xtype": "ColumnModel",
+                                            "header": "Report",
+                                            "width": 75,
+                                            "dataIndex": "report_id",
+                                            "|renderer": "function(v) { return String.format('{0}', v); }",
+                                            "|xns": "Roo.grid",
+                                            "*prop": "colModel[]"
+                                        },
+                                        {
+                                            "xtype": "ColumnModel",
+                                            "header": "Report name",
+                                            "width": 200,
+                                            "dataIndex": "report_name",
+                                            "|renderer": "function(v) { return String.format('{0}', v); }",
+                                            "|xns": "Roo.grid",
+                                            "*prop": "colModel[]"
+                                        },
+                                        {
+                                            "xtype": "ColumnModel",
+                                            "header": "Report sys",
+                                            "width": 75,
+                                            "dataIndex": "report_sys",
+                                            "|renderer": "function(v) { return String.format('{0}', v); }",
+                                            "|xns": "Roo.grid",
+                                            "*prop": "colModel[]"
+                                        },
+                                        {
+                                            "xtype": "ColumnModel",
+                                            "header": "Report source",
+                                            "width": 200,
+                                            "dataIndex": "report_source",
+                                            "|renderer": "function(v) { return String.format('{0}', v); }",
+                                            "|xns": "Roo.grid",
+                                            "*prop": "colModel[]"
+                                        },
+                                        {
+                                            "xtype": "ColumnModel",
+                                            "header": "Report descrip",
+                                            "width": 200,
+                                            "dataIndex": "report_descrip",
+                                            "|renderer": "function(v) { return String.format('{0}', v); }",
+                                            "|xns": "Roo.grid",
+                                            "*prop": "colModel[]"
+                                        },
+                                        {
+                                            "xtype": "ColumnModel",
+                                            "header": "Report grade",
+                                            "width": 75,
+                                            "dataIndex": "report_grade",
+                                            "|renderer": "function(v) { return String.format('{0}', v); }",
+                                            "|xns": "Roo.grid",
+                                            "*prop": "colModel[]"
+                                        },
+                                        {
+                                            "xtype": "ColumnModel",
+                                            "header": "Report loaddate",
+                                            "width": 75,
+                                            "dataIndex": "report_loaddate",
+                                            "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
+                                            "|xns": "Roo.grid",
+                                            "*prop": "colModel[]"
+                                        }
+                                    ]
+                                }
+                            ]
                         }
                     ]
                 }
index 3565ea8..2614b0f 100644 (file)
@@ -21,6 +21,222 @@ Pman.Tab.XtupleReports = new Roo.XComponent({
             layout : {
                 xtype: 'BorderLayout',
                 xns: Roo,
+                items : [
+                    {
+                        xtype: 'GridPanel',
+                        xns: Roo,
+                        title : "report",
+                        fitToframe : true,
+                        fitContainer : true,
+                        tableName : 'report',
+                        background : true,
+                        region : 'center',
+                        listeners : {
+                            activate : function() {
+                                _this.panel = this;
+                                if (_this.grid) {
+                                    _this.grid.footer.onClick('first');
+                                }
+                            }
+                        },
+                        grid : {
+                            xtype: 'Grid',
+                            xns: Roo.grid,
+                            autoExpandColumn : 'report_name',
+                            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).data, function() {
+                                        _this.grid.footer.onClick('first');
+                                    }); 
+                                }
+                            },
+                            dataSource : {
+                                xtype: 'Store',
+                                xns: Roo.data,
+                                remoteSort : true,
+                                sortInfo : { field : 'report_name', direction: 'ASC' },
+                                proxy : {
+                                    xtype: 'HttpProxy',
+                                    xns: Roo.data,
+                                    method : 'GET',
+                                    url : baseURL + '/Roo/report.php'
+                                },
+                                reader : {
+                                    xtype: 'JsonReader',
+                                    xns: Roo.data,
+                                    totalProperty : 'total',
+                                    root : 'data',
+                                    id : 'id',
+                                    fields : [
+                                        {
+                                            'name': 'report_id',
+                                            'type': 'int'
+                                        },
+                                        {
+                                            'name': 'report_name',
+                                            'type': 'string'
+                                        },
+                                        {
+                                            'name': 'report_sys',
+                                            'type': 'int'
+                                        },
+                                        {
+                                            'name': 'report_source',
+                                            'type': 'string'
+                                        },
+                                        {
+                                            'name': 'report_descrip',
+                                            'type': 'string'
+                                        },
+                                        {
+                                            'name': 'report_grade',
+                                            'type': 'int'
+                                        },
+                                        {
+                                            'name': 'report_loaddate',
+                                            'type': 'date',
+                                            'dateFormat': 'Y-m-d'
+                                        }
+                                    ]
+                                }
+                            },
+                            footer : {
+                                xtype: 'PagingToolbar',
+                                xns: Roo,
+                                pageSize : 25,
+                                displayInfo : true,
+                                displayMsg : "Displaying report{0} - {1} of {2}",
+                                emptyMsg : "No report found"
+                            },
+                            toolbar : {
+                                xtype: 'Toolbar',
+                                xns: Roo,
+                                items : [
+                                    {
+                                        xtype: 'Button',
+                                        xns: Roo.Toolbar,
+                                        text : "Add",
+                                        cls : 'x-btn-text-icon',
+                                        icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
+                                        listeners : {
+                                            click : function()
+                                            {
+                                                if (!_this.dialog) return;
+                                                _this.dialog.show( { id : 0 } , function() {
+                                                    _this.grid.footer.onClick('first');
+                                               }); 
+                                            }
+                                        }
+                                    },
+                                    {
+                                        xtype: 'Button',
+                                        xns: Roo.Toolbar,
+                                        text : "Edit",
+                                        cls : 'x-btn-text-icon',
+                                        icon : Roo.rootURL + 'images/default/tree/leaf.gif',
+                                        listeners : {
+                                            click : function()
+                                            {
+                                                var s = _this.grid.getSelectionModel().getSelections();
+                                                if (!s.length || (s.length > 1))  {
+                                                    Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
+                                                    return;
+                                                }
+                                                if (!_this.dialog) return;
+                                                _this.dialog.show(s[0].data, function() {
+                                                    _this.grid.footer.onClick('first');
+                                                }); 
+                                                
+                                            }
+                                        }
+                                    },
+                                    {
+                                        xtype: 'Button',
+                                        xns: Roo.Toolbar,
+                                        text : "Delete",
+                                        cls : 'x-btn-text-icon',
+                                        icon : rootURL + '/Pman/templates/images/trash.gif',
+                                        listeners : {
+                                            click : function()
+                                            {
+                                                 Pman.genericDelete(_this, 'report'); 
+                                            }
+                                        }
+                                    }
+                                ]
+                            },
+                            colModel : [
+                                {
+                                    xtype: 'ColumnModel',
+                                    xns: Roo.grid,
+                                    header : 'Report',
+                                    width : 75,
+                                    dataIndex : 'report_id',
+                                    renderer : function(v) { return String.format('{0}', v); }
+                                },
+                                {
+                                    xtype: 'ColumnModel',
+                                    xns: Roo.grid,
+                                    header : 'Report name',
+                                    width : 200,
+                                    dataIndex : 'report_name',
+                                    renderer : function(v) { return String.format('{0}', v); }
+                                },
+                                {
+                                    xtype: 'ColumnModel',
+                                    xns: Roo.grid,
+                                    header : 'Report sys',
+                                    width : 75,
+                                    dataIndex : 'report_sys',
+                                    renderer : function(v) { return String.format('{0}', v); }
+                                },
+                                {
+                                    xtype: 'ColumnModel',
+                                    xns: Roo.grid,
+                                    header : 'Report source',
+                                    width : 200,
+                                    dataIndex : 'report_source',
+                                    renderer : function(v) { return String.format('{0}', v); }
+                                },
+                                {
+                                    xtype: 'ColumnModel',
+                                    xns: Roo.grid,
+                                    header : 'Report descrip',
+                                    width : 200,
+                                    dataIndex : 'report_descrip',
+                                    renderer : function(v) { return String.format('{0}', v); }
+                                },
+                                {
+                                    xtype: 'ColumnModel',
+                                    xns: Roo.grid,
+                                    header : 'Report grade',
+                                    width : 75,
+                                    dataIndex : 'report_grade',
+                                    renderer : function(v) { return String.format('{0}', v); }
+                                },
+                                {
+                                    xtype: 'ColumnModel',
+                                    xns: Roo.grid,
+                                    header : 'Report loaddate',
+                                    width : 75,
+                                    dataIndex : 'report_loaddate',
+                                    renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
+                                }
+                            ]
+                        }
+                    }
+                ],
                 center : {
                     xtype: 'LayoutRegion',
                     xns: Roo