Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Dialog.XtupleJournalEntry.js
index 96a0707..635c66f 100644 (file)
@@ -32,16 +32,16 @@ Pman.Dialog.XtupleJournalEntry = {
             xns: Roo,
             closable : false,
             collapsible : false,
-            height : 910,
+            height : 600,
             modal : true,
             resizable : false,
-            title : "Edit / Create gltrans",
+            title : "Create / View  Transaction",
             width : 800,
             items : [
                 {
                     xtype: 'ContentPanel',
                     xns: Roo,
-                    region : 'center',
+                    region : 'north',
                     items : [
                         {
                             xtype: 'Form',
@@ -51,16 +51,20 @@ Pman.Dialog.XtupleJournalEntry = {
                                 {
                                     if (action.type == 'setdata') {
                                        //_this.dialog.el.mask("Loading");
-                                       //this.load({ method: 'GET', params: { '_id' : _this.data.id }});
+                                       if (_this.data.gltrans_id) {
+                                            this.load({ method: 'GET', params: { '_id' : _this.data.gltrans_id }});
+                                           return;
+                                       }
+                                       _this.grid.footer.onClick('first'); // clear..
                                        return;
                                     }
                                     if (action.type == 'load') {
-                                        _this.dialog.el.unmask();
+                                         _this.grid.footer.onClick('first');
                                         return;
                                     }
                                     if (action.type =='submit') {
                                     
-                                        _this.dialog.el.unmask();
+                                        
                                         _this.dialog.hide();
                                     
                                          if (_this.callback) {
@@ -90,6 +94,7 @@ Pman.Dialog.XtupleJournalEntry = {
                                             xns: Roo.form,
                                             fieldLabel : 'Sequence',
                                             name : 'gltrans_sequence',
+                                            readOnly : true,
                                             width : 100
                                         },
                                         {
@@ -97,6 +102,7 @@ Pman.Dialog.XtupleJournalEntry = {
                                             xns: Roo.form,
                                             fieldLabel : 'Journal No.',
                                             name : 'gltrans_journalnumber',
+                                            readOnly : true,
                                             width : 75
                                         },
                                         {
@@ -125,8 +131,9 @@ Pman.Dialog.XtupleJournalEntry = {
                                         {
                                             xtype: 'TextField',
                                             xns: Roo.form,
-                                            fieldLabel : 'Entered',
-                                            name : 'gltrans_entered',
+                                            fieldLabel : 'Created',
+                                            name : 'gltrans_created',
+                                            readOnly : true,
                                             width : 150
                                         }
                                     ]
@@ -140,8 +147,9 @@ Pman.Dialog.XtupleJournalEntry = {
                                             xns: Roo.form,
                                             boxLabel : 'Posted',
                                             fieldLabel : 'Status',
-                                            name : 'Posted',
-                                            width : 75
+                                            name : 'gltrans_posted',
+                                            width : 100,
+                                            inputValue : true
                                         },
                                         {
                                             xtype: 'Row',
@@ -153,6 +161,7 @@ Pman.Dialog.XtupleJournalEntry = {
                                                     xns: Roo.form,
                                                     boxLabel : 'Recorded in Bank Reconcile',
                                                     fieldLabel : ' ',
+                                                    inputValue : true,
                                                     name : 'gltrans_rec',
                                                     width : 200
                                                 },
@@ -161,6 +170,7 @@ Pman.Dialog.XtupleJournalEntry = {
                                                     xns: Roo.form,
                                                     boxLabel : 'Deleted',
                                                     fieldLabel : 'Deleted',
+                                                    inputValue : true,
                                                     name : 'gltrans_deleted',
                                                     width : 75
                                                 }
@@ -177,6 +187,7 @@ Pman.Dialog.XtupleJournalEntry = {
                                             xns: Roo.form,
                                             fieldLabel : 'Source',
                                             name : 'gltrans_source',
+                                            readOnly : true,
                                             width : 100
                                         },
                                         {
@@ -184,6 +195,7 @@ Pman.Dialog.XtupleJournalEntry = {
                                             xns: Roo.form,
                                             fieldLabel : 'Doc Type',
                                             name : 'gltrans_doctype',
+                                            readOnly : true,
                                             width : 100
                                         },
                                         {
@@ -191,25 +203,271 @@ Pman.Dialog.XtupleJournalEntry = {
                                             xns: Roo.form,
                                             fieldLabel : 'References',
                                             name : 'gltrans_misc_id',
+                                            readOnly : true,
                                             width : 75
+                                        },
+                                        {
+                                            xtype: 'Button',
+                                            xns: Roo,
+                                            text : "Show"
                                         }
                                     ]
                                 },
                                 {
-                                    xtype: 'TextField',
+                                    xtype: 'Row',
                                     xns: Roo.form,
-                                    fieldLabel : 'Doc No.',
-                                    name : 'gltrans_docnumber',
-                                    width : 400
+                                    items : [
+                                        {
+                                            xtype: 'TextField',
+                                            xns: Roo.form,
+                                            fieldLabel : 'Doc No.',
+                                            name : 'gltrans_docnumber',
+                                            width : 100
+                                        },
+                                        {
+                                            xtype: 'TextField',
+                                            xns: Roo.form,
+                                            fieldLabel : 'Notes',
+                                            name : 'gltrans_notes',
+                                            width : 300
+                                        }
+                                    ]
                                 }
                             ]
                         }
                     ]
+                },
+                {
+                    xtype: 'GridPanel',
+                    xns: Roo,
+                    listeners : {
+                        activate : function() {
+                            _this.panel = this;
+                            if (_this.grid) {
+                                _this.grid.footer.onClick('first');
+                            }
+                        }
+                    },
+                    background : false,
+                    fitContainer : true,
+                    fitToframe : true,
+                    region : 'center',
+                    tableName : 'gltrans',
+                    title : "gltrans",
+                    grid : {
+                        xtype: 'Grid',
+                        xns: Roo.grid,
+                        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');
+                                }); 
+                            }
+                        },
+                        autoExpandColumn : 'gltrans_accnt_id',
+                        loadMask : true,
+                        dataSource : {
+                            xtype: 'Store',
+                            xns: Roo.data,
+                            listeners : {
+                                beforeload : function (_self, options)
+                                {
+                                    this.removeAll();
+                                    if (!_this.form.findField('gltrans_sequence').getValue()) {
+                                        return false;
+                                    }
+                                    options.params.gltrans_sequence = _this.form.findField('gltrans_sequence').getValue();
+                                }
+                            },
+                            remoteSort : true,
+                            sortInfo : { field : 'gltrans_source', direction: 'ASC' },
+                            proxy : {
+                                xtype: 'HttpProxy',
+                                xns: Roo.data,
+                                method : 'GET',
+                                url : baseURL + '/Roo/gltrans.php'
+                            },
+                            reader : {
+                                xtype: 'JsonReader',
+                                xns: Roo.data,
+                                totalProperty : 'total',
+                                root : 'data',
+                                id : 'id',
+                                fields : [
+                                    {
+                                        'name': 'gltrans_id',
+                                        'type': 'int'
+                                    },
+                                    {
+                                        'name': 'gltrans_exported',
+                                        'type': 'int'
+                                    },
+                                    {
+                                        'name': 'gltrans_created',
+                                        'type': 'date',
+                                        'dateFormat': 'Y-m-d'
+                                    },
+                                    {
+                                        'name': 'gltrans_date',
+                                        'type': 'date',
+                                        'dateFormat': 'Y-m-d'
+                                    },
+                                    {
+                                        'name': 'gltrans_sequence',
+                                        'type': 'int'
+                                    },
+                                    {
+                                        'name': 'gltrans_accnt_id',
+                                        'type': 'int'
+                                    },
+                                    {
+                                        'name': 'gltrans_source',
+                                        'type': 'string'
+                                    },
+                                    {
+                                        'name': 'gltrans_docnumber',
+                                        'type': 'string'
+                                    },
+                                    {
+                                        'name': 'gltrans_misc_id',
+                                        'type': 'int'
+                                    },
+                                    {
+                                        'name': 'gltrans_amount',
+                                        'type': 'float'
+                                    },
+                                    {
+                                        'name': 'gltrans_notes',
+                                        'type': 'string'
+                                    },
+                                    {
+                                        'name': 'gltrans_journalnumber',
+                                        'type': 'int'
+                                    },
+                                    {
+                                        'name': 'gltrans_posted',
+                                        'type': 'int'
+                                    },
+                                    {
+                                        'name': 'gltrans_doctype',
+                                        'type': 'string'
+                                    },
+                                    {
+                                        'name': 'gltrans_rec',
+                                        'type': 'int'
+                                    },
+                                    {
+                                        'name': 'gltrans_username',
+                                        'type': 'string'
+                                    },
+                                    {
+                                        'name': 'gltrans_deleted',
+                                        'type': 'int'
+                                    }
+                                ]
+                            }
+                        },
+                        footer : {
+                            xtype: 'PagingToolbar',
+                            xns: Roo,
+                            pageSize : 25,
+                            displayInfo : true,
+                            displayMsg : "Displaying gltrans{0} - {1} of {2}",
+                            emptyMsg : "No gltrans 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: 'Fill',
+                                    xns: Roo.Toolbar
+                                },
+                                {
+                                    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, 'gltrans'); 
+                                        }
+                                    }
+                                }
+                            ]
+                        },
+                        colModel : [
+                            {
+                                xtype: 'ColumnModel',
+                                xns: Roo.grid,
+                                dataIndex : 'gltrans_id',
+                                header : 'ID#',
+                                width : 50,
+                                renderer : function(v) { return String.format('{0}', v); }
+                            },
+                            {
+                                xtype: 'ColumnModel',
+                                xns: Roo.grid,
+                                dataIndex : 'gltrans_accnt_id',
+                                header : 'Account',
+                                width : 75,
+                                renderer : function(v,x,r) {
+                                
+                                     return String.format('{0}', r.data.gltrans_accnt_id_accnt_descrip); 
+                                 }
+                            },
+                            {
+                                xtype: 'ColumnModel',
+                                xns: Roo.grid,
+                                align : 'right',
+                                dataIndex : 'gltrans_amount',
+                                header : 'Gltrans amount',
+                                width : 100,
+                                renderer : function(v) { 
+                                
+                                    var vv = Roo.util.Format.number(v,2);
+                                    if (v*1 < 0 ) {
+                                        return '<span style="color:red">' + vv + '</span>';
+                                    }
+                                    return vv; 
+                                }
+                            }
+                        ]
+                    }
                 }
             ],
             north : {
                 xtype: 'LayoutRegion',
-                xns: Roo
+                xns: Roo,
+                height : 150
             },
             center : {
                 xtype: 'LayoutRegion',
@@ -235,8 +493,10 @@ Pman.Dialog.XtupleJournalEntry = {
                         {
                             // do some checks?
                              
-                            
-                            _this.dialog.el.mask("Saving");
+                            if (_this.data.gltrans_id) {
+                                return;
+                            }
+                        
                             _this.form.doAction("submit");
                         
                         }