Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Tab.XtupleTerms.js
index c2d446f..70d1c37 100644 (file)
@@ -29,6 +29,12 @@ Pman.Tab.XtupleTerms = new Roo.XComponent({
                 items : [
                        {
                         grid : {
+                            sm : {
+                                '|xns' : 'Roo.grid',
+                                singleSelect : true,
+                                xtype : 'RowSelectionModel',
+                                xns : Roo.grid
+                            },
                             toolbar : {
                                 '|xns' : 'Roo',
                                 xtype : 'Toolbar',
@@ -76,6 +82,73 @@ Pman.Tab.XtupleTerms = new Roo.XComponent({
                                                       _this.grid.footer.onClick('first');\r
                                                   }
                                         }
+                                    },
+                                       {
+                                        '|xns' : 'Roo.Toolbar',
+                                        xtype : 'Fill',
+                                        xns : Roo.Toolbar
+                                    },
+                                       {
+                                        '|xns' : 'Roo.Toolbar',
+                                        text : "Add",
+                                        xtype : 'Button',
+                                        cls : 'x-btn-text-icon',
+                                        icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
+                                        xns : Roo.Toolbar,
+                                        listeners : {
+                                               click : function()
+                                                  {
+                                                  
+                                                     Pman.Dialog.XtupleTerms.show( { id : 0 } , function() {
+                                                          _this.grid.footer.onClick('first');
+                                                     }); 
+                                                  }
+                                        }
+                                    },
+                                       {
+                                        '|xns' : 'Roo.Toolbar',
+                                        xtype : 'Separator',
+                                        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()
+                                                  {
+                                                      var sel = _this.grid.getSelectionModel().getSelected();
+                                                  
+                                                      if(!sel || sel.data.terms_id * 1 < 1){
+                                                          Roo.MessageBox.alert("Error", "Please select a terms");
+                                                          return;
+                                                      }
+                                                      
+                                                      Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete the terms?",
+                                                          function(r) {
+                                                              if (r != 'yes') {
+                                                                  return;
+                                                              }
+                                                             new Pman.Request({
+                                                                  url : baseURL + '/Roo/terms.php',
+                                                                  method : 'POST',
+                                                                  params : {
+                                                                      _delete : sel.data.terms_id * 1
+                                                                  }, 
+                                                                  success : function(res) {
+                                                                      _this.grid.footer.onClick('first');
+                                                                  }
+                                                              }); 
+                                                              
+                                                              return;
+                                                          }
+                                                      );
+                                                      
+                                                  }
+                                        }
                                     }
                                 ]
 
@@ -84,8 +157,8 @@ Pman.Tab.XtupleTerms = new Roo.XComponent({
                                 proxy : {
                                     '|xns' : 'Roo.data',
                                     url : baseURL + '/Roo/terms.php',
-                                    xtype : 'HttpProxy',
                                     method : 'GET',
+                                    xtype : 'HttpProxy',
                                     xns : Roo.data
                                 },
                                 reader : {
@@ -113,7 +186,7 @@ Pman.Tab.XtupleTerms = new Roo.XComponent({
                                 '|xns' : 'Roo.data',
                                 xtype : 'Store',
                                 remoteSort : true,
-                                sortInfo : { field : 'crdate', direction: 'ASC' },
+                                sortInfo : { field : 'terms_id', direction: 'ASC' },
                                 xns : Roo.data,
                                 listeners : {
                                        beforeload : function (_self, o)
@@ -152,8 +225,8 @@ Pman.Tab.XtupleTerms = new Roo.XComponent({
                                 {
                                        '|xns' : 'Roo.grid',
                                        xtype : 'ColumnModel',
+                                       width : 75,
                                        header : 'ID#',
-                                       width : 200,
                                        renderer : function(v) { return String.format('{0}', v ? v : ''); },
                                        xns : Roo.grid,
                                        sortable : true,
@@ -162,8 +235,8 @@ Pman.Tab.XtupleTerms = new Roo.XComponent({
 {
                                        '|xns' : 'Roo.grid',
                                        xtype : 'ColumnModel',
-                                       width : 150,
                                        header : 'Code',
+                                       width : 150,
                                        renderer : function(v) { return String.format('{0}', v ? v : ''); },
                                        xns : Roo.grid,
                                        sortable : true,
@@ -172,8 +245,8 @@ Pman.Tab.XtupleTerms = new Roo.XComponent({
 {
                                        '|xns' : 'Roo.grid',
                                        xtype : 'ColumnModel',
-                                       header : 'Description',
                                        width : 150,
+                                       header : 'Description',
                                        renderer : function(v) { return String.format('{0}', v ? v : ''); },
                                        xns : Roo.grid,
                                        sortable : true,
@@ -182,8 +255,8 @@ Pman.Tab.XtupleTerms = new Roo.XComponent({
 {
                                        '|xns' : 'Roo.grid',
                                        xtype : 'ColumnModel',
-                                       width : 150,
                                        header : 'Type',
+                                       width : 75,
                                        renderer : function(v) { 
                                            var t = (v == 'D') ? 'Days' : 'Proximo';
                                            
@@ -191,14 +264,17 @@ Pman.Tab.XtupleTerms = new Roo.XComponent({
                                        },
                                        xns : Roo.grid,
                                        sortable : true,
-                                       dataIndex : 'term_type'
+                                       dataIndex : 'terms_type'
                                    },
 {
                                        '|xns' : 'Roo.grid',
                                        xtype : 'ColumnModel',
-                                       width : 150,
                                        header : 'Due Days',
-                                       renderer : function(v) { return String.format('{0}', v ? v : ''); },
+                                       width : 100,
+                                       renderer : function(v) { 
+                                           return String.format('{0}', v); 
+                                           
+                                       },
                                        xns : Roo.grid,
                                        sortable : true,
                                        dataIndex : 'terms_duedays'
@@ -206,9 +282,12 @@ Pman.Tab.XtupleTerms = new Roo.XComponent({
 {
                                        '|xns' : 'Roo.grid',
                                        xtype : 'ColumnModel',
-                                       width : 150,
                                        header : 'Discount Days',
-                                       renderer : function(v) { return String.format('{0}', v ? v : ''); },
+                                       width : 100,
+                                       renderer : function(v) { 
+                                           return String.format('{0}', v); 
+                                           
+                                       },
                                        xns : Roo.grid,
                                        sortable : true,
                                        dataIndex : 'terms_discdays'
@@ -216,15 +295,61 @@ Pman.Tab.XtupleTerms = new Roo.XComponent({
 {
                                        '|xns' : 'Roo.grid',
                                        xtype : 'ColumnModel',
-                                       header : 'Discount Days',
-                                       width : 150,
-                                       renderer : function(v) { return String.format('{0}', v ? v : ''); },
+                                       header : 'Cut Off Days',
+                                       width : 100,
+                                       renderer : function(v) { 
+                                           return String.format('{0}', v); 
+                                           
+                                       },
                                        xns : Roo.grid,
                                        sortable : true,
                                        dataIndex : 'terms_cutoffday'
+                                   },
+{
+                                       '|xns' : 'Roo.grid',
+                                       xtype : 'ColumnModel',
+                                       header : 'Used in Payables',
+                                       width : 150,
+                                       renderer : function(v) {  
+                                           var state = v  ?  '-checked' : '';
+                                       
+                                           return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
+                                                       
+                                        },
+                                       xns : Roo.grid,
+                                       sortable : true,
+                                       dataIndex : 'terms_ap'
+                                   },
+{
+                                       '|xns' : 'Roo.grid',
+                                       xtype : 'ColumnModel',
+                                       width : 150,
+                                       header : 'Used in Receivables',
+                                       renderer : function(v) {  
+                                           var state = v  ?  '-checked' : '';
+                                       
+                                           return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
+                                                       
+                                        },
+                                       xns : Roo.grid,
+                                       sortable : true,
+                                       dataIndex : 'terms_ar'
                                    }
                             ],
                             listeners : {
+                               rowdblclick : function (_self, rowIndex, e)
+                                  {
+                                      var id = this.getDataSource().getAt(rowIndex).data.terms_id * 1;
+                                  
+                                      if(id < 1){
+                                          Roo.MessageBox.alert('Error', 'Please select a row');
+                                          return;
+                                      }
+                                      
+                                      Pman.Dialog.XtupleTerms.show( {id : id}, function() {
+                                          _this.grid.footer.onClick('refresh');
+                                      }); 
+                                  },
                                render : function() 
                                   {
                                       _this.grid = this; 
@@ -240,9 +365,9 @@ Pman.Tab.XtupleTerms = new Roo.XComponent({
 
                         },
                         '|xns' : 'Roo',
+                        region : 'center',
                         fitToframe : true,
                         background : false,
-                        region : 'center',
                         title : "Terms",
                         xtype : 'GridPanel',
                         fitContainer : true,