Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Dialog.XtupleVendorEdit.js
index 3e50238..797cec0 100644 (file)
@@ -42,7 +42,7 @@ Pman.Dialog.XtupleVendorEdit = {
             modal : true,
             resizable : false,
             title : "Edit / Create Vendor",
-            width : 550,
+            width : 600,
             items : [
                 {
                     xtype: 'ContentPanel',
@@ -531,6 +531,10 @@ Pman.Dialog.XtupleVendorEdit = {
                                 beforeload : function (_self, options)
                                 {
                                     options.params.itemsrc_vend_id =   _this.form.findField('vend_id').getValue();
+                                    var s = _this.searchBox.getValue();
+                                    if (s.length) {
+                                        options.params['search[name]'] = s;
+                                    }
                                 }
                             },
                             remoteSort : true,
@@ -634,10 +638,10 @@ Pman.Dialog.XtupleVendorEdit = {
                         footer : {
                             xtype: 'PagingToolbar',
                             xns: Roo,
-                            pageSize : 25,
                             displayInfo : true,
                             displayMsg : "Displaying itemsrc{0} - {1} of {2}",
-                            emptyMsg : "No itemsrc found"
+                            emptyMsg : "No itemsrc found",
+                            pageSize : 100
                         },
                         toolbar : {
                             xtype: 'Toolbar',
@@ -650,6 +654,10 @@ Pman.Dialog.XtupleVendorEdit = {
                                         render : function (_self)
                                         {
                                             _this.searchBox = _self;
+                                        },
+                                        specialkey : function (_self, e)
+                                        {
+                                            _this.grid.footer.onClick('first');
                                         }
                                     }
                                 },
@@ -672,12 +680,6 @@ Pman.Dialog.XtupleVendorEdit = {
                                         click : function (_self, e)
                                         {
                                             _this.searchBox.setValue('');
-                                            _this.publication_name_combo.setValue('');
-                                            _this.publication_lang_combo.setValue('');
-                                            _this.country_combo.setValue('');
-                                            _this.category_media_id_combo.setValue('');
-                                            _this.role_combo.setValue('');      
-                                        
                                             
                                             _this.grid.footer.onClick('first');
                                         }
@@ -805,6 +807,241 @@ Pman.Dialog.XtupleVendorEdit = {
                             }
                         ]
                     }
+                },
+                {
+                    xtype: 'GridPanel',
+                    xns: Roo,
+                    listeners : {
+                        activate : function() {
+                            _this.apanel = this;
+                            if (_this.agrid) {
+                                _this.agrid.footer.onClick('first');
+                            }
+                        }
+                    },
+                    background : true,
+                    fitContainer : true,
+                    fitToframe : true,
+                    region : 'center',
+                    tableName : 'vendaddrinfo',
+                    title : "Addresses",
+                    grid : {
+                        xtype: 'Grid',
+                        xns: Roo.grid,
+                        listeners : {
+                            render : function() 
+                            {
+                                _this.agrid = this; 
+                                //_this.dialog = Pman.Dialog.FILL_IN
+                                if (_this.apanel.active) {
+                                   this.footer.onClick('first');
+                                }
+                            }
+                        },
+                        autoExpandColumn : 'vendaddr_addr_id_addr_line1',
+                        loadMask : true,
+                        sm : {
+                            xtype: 'RowSelectionModel',
+                            xns: Roo.grid,
+                            singleSelect : true
+                        },
+                        dataSource : {
+                            xtype: 'Store',
+                            xns: Roo.data,
+                            listeners : {
+                                beforeload : function (_self, options)
+                                {
+                                    options.params = options.params || {};
+                                    
+                                    var id = _this.form.findField('vend_id').getValue();
+                                    
+                                    if(id * 1 < 1){
+                                        return false;
+                                    }
+                                    
+                                    options.params.vendaddr_vend_id = id;
+                                }
+                            },
+                            remoteSort : true,
+                            sortInfo : { field : 'vendaddr_id', direction: 'ASC' },
+                            proxy : {
+                                xtype: 'HttpProxy',
+                                xns: Roo.data,
+                                method : 'GET',
+                                url : baseURL + '/Roo/vendaddrinfo.php'
+                            },
+                            reader : {
+                                xtype: 'JsonReader',
+                                xns: Roo.data,
+                                id : 'vendaddr_id',
+                                root : 'data',
+                                totalProperty : 'total',
+                                fields : [
+                                    {
+                                        'name': 'vendaddr_id',
+                                        'type': 'int'
+                                    },
+                                    {
+                                        'name': 'vendaddr_vend_id',
+                                        'type': 'int'
+                                    },
+                                    {
+                                        'name': 'vendaddr_code',
+                                        'type': 'string'
+                                    }
+                                ]
+                            }
+                        },
+                        footer : {
+                            xtype: 'PagingToolbar',
+                            xns: Roo,
+                            displayInfo : true,
+                            displayMsg : "Displaying address{0} - {1} of {2}",
+                            emptyMsg : "Nothing found",
+                            pageSize : 100
+                        },
+                        toolbar : {
+                            xtype: 'Toolbar',
+                            xns: Roo,
+                            items : [
+                                {
+                                    xtype: 'Fill',
+                                    xns: Roo.Toolbar
+                                },
+                                {
+                                    xtype: 'Button',
+                                    xns: Roo.Toolbar,
+                                    listeners : {
+                                        click : function (_self, e)
+                                        {
+                                            var id = _this.form.findField('vend_id').getValue();
+                                            
+                                            if(id * 1 < 1){
+                                                Roo.MessageBox.alert('Error', 'Please save the vendor first');
+                                                return;
+                                            }
+                                            
+                                            Pman.Dialog.Image.show(
+                                               {
+                                                    _url : baseURL+'/Xtuple/Import/VendAddrInfo?' + Roo.urlEncode({'vend_id' : id})
+                                                
+                                               },
+                                               function (data) {
+                                                    _this.agrid.footer.onClick('first');
+                                               }
+                                           );
+                                        }
+                                    },
+                                    text : "Upload"
+                                },
+                                {
+                                    xtype: 'Button',
+                                    xns: Roo.Toolbar,
+                                    listeners : {
+                                        click : function()
+                                        {
+                                             var s = _this.agrid.getSelectionModel().getSelected();
+                                             
+                                             if(!s || s.data.vendaddr_id * 1 < 1){
+                                                Roo.MessageBox.alert('Error', 'Please select a row');
+                                                return;
+                                             }
+                                             
+                                             Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete that?",
+                                                function(v) {
+                                                    if (v != 'yes') {
+                                                        return;
+                                                    }
+                                                     new Pman.Request({
+                                                        method: 'POST',
+                                                        url: baseURL+ '/Roo/vendaddrinfo',
+                                                        params : {
+                                                            _delete : s.data.vendaddr_id
+                                                        },
+                                                        success : function() {
+                                                            _this.agrid.footer.onClick('refresh');
+                                                        }
+                                                    });
+                                            });
+                                        }
+                                    },
+                                    cls : 'x-btn-text-icon',
+                                    text : "Delete",
+                                    icon : rootURL + '/Pman/templates/images/trash.gif'
+                                },
+                                {
+                                    xtype: 'Button',
+                                    xns: Roo.Toolbar,
+                                    listeners : {
+                                        click : function()
+                                        {
+                                             var s = _this.form.findField('vend_id').getValue() * 1;
+                                             
+                                             if(!s || s * 1 < 1){
+                                                Roo.MessageBox.alert('Error', 'Save first!');
+                                                return;
+                                             }
+                                             
+                                             Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete all the address?",
+                                                function(v) {
+                                                    if (v != 'yes') {
+                                                        return;
+                                                    }
+                                                     new Pman.Request({
+                                                        method: 'POST',
+                                                        url: baseURL+ '/Roo/vendinfo',
+                                                        params : {
+                                                            vend_id : s,
+                                                            _remove_addr : 1
+                                                        },
+                                                        success : function() {
+                                                            _this.agrid.footer.onClick('refresh');
+                                                        }
+                                                    });
+                                            });
+                                        }
+                                    },
+                                    cls : 'x-btn-text-icon',
+                                    text : "Delete All",
+                                    icon : rootURL + '/Pman/templates/images/trash.gif'
+                                }
+                            ]
+                        },
+                        colModel : [
+                            {
+                                xtype: 'ColumnModel',
+                                xns: Roo.grid,
+                                dataIndex : 'vendaddr_code',
+                                header : 'Code',
+                                width : 75,
+                                renderer : function(v) { return String.format('{0}', v); }
+                            },
+                            {
+                                xtype: 'ColumnModel',
+                                xns: Roo.grid,
+                                dataIndex : 'vendaddr_addr_id_addr_city',
+                                header : 'District',
+                                width : 100,
+                                renderer : function(v) { return String.format('{0}', v); }
+                            },
+                            {
+                                xtype: 'ColumnModel',
+                                xns: Roo.grid,
+                                dataIndex : 'vendaddr_addr_id_addr_line1',
+                                header : 'Address Line 1',
+                                width : 200,
+                                renderer : function(v) { return String.format('{0}', v); }
+                            },
+                            {
+                                xtype: 'ColumnModel',
+                                xns: Roo.grid,
+                                dataIndex : 'vendaddr_addr_id_addr_line2',
+                                header : 'Address Line 2',
+                                width : 200,
+                                renderer : function(v) { return String.format('{0}', v); }
+                            }
+                        ]
+                    }
                 }
             ],
             center : {