Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Dialog.XtupleVendorEdit.js
index 173435f..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',
@@ -831,15 +831,20 @@ Pman.Dialog.XtupleVendorEdit = {
                         listeners : {
                             render : function() 
                             {
-                                _this.sgrid = this; 
+                                _this.agrid = this; 
                                 //_this.dialog = Pman.Dialog.FILL_IN
-                                if (_this.spanel.active) {
+                                if (_this.apanel.active) {
                                    this.footer.onClick('first');
                                 }
                             }
                         },
-                        autoExpandColumn : 'vendaddr_code',
+                        autoExpandColumn : 'vendaddr_addr_id_addr_line1',
                         loadMask : true,
+                        sm : {
+                            xtype: 'RowSelectionModel',
+                            xns: Roo.grid,
+                            singleSelect : true
+                        },
                         dataSource : {
                             xtype: 'Store',
                             xns: Roo.data,
@@ -907,43 +912,62 @@ Pman.Dialog.XtupleVendorEdit = {
                                     xtype: 'Button',
                                     xns: Roo.Toolbar,
                                     listeners : {
-                                        click : function()
+                                        click : function (_self, e)
                                         {
-                                           
-                                            Pman.Dialog.XtupleSalesProductList.show({
-                                                exclude_itemsrc_vendor : _this.form.findField('vend_id').getValue(),
-                                                multi_select : true
+                                            var id = _this.form.findField('vend_id').getValue();
                                             
-                                            }, function(sels) {
-                                               Roo.log(sels); 
-                                        
-                                               var ids = [];
-                                               Roo.each(sels,function(rec) {
-                                                    ids.push(rec.data.item_id);
-                                                });
-                                                new Pman.Request({
-                                                    mask: "Adding",
-                                                    url : baseURL + '/Roo/Itemsrc',
-                                                    method: 'POST',
-                                                    params : {
-                                                        add_multiple : ids.join(','),
-                                                        itemsrc_vend_id : _this.form.findField('vend_id').getValue()
-                                                    },
-                                                    success : function() { 
-                                                        
-                                                    
-                                                          _this.grid.footer.onClick('first');
-                                                  }
-                                              });
-                                                      
+                                            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 : "Add",
-                                    icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
+                                    text : "Delete",
+                                    icon : rootURL + '/Pman/templates/images/trash.gif'
                                 },
                                 {
                                     xtype: 'Button',
@@ -951,11 +975,34 @@ Pman.Dialog.XtupleVendorEdit = {
                                     listeners : {
                                         click : function()
                                         {
-                                             Pman.genericDelete(_this, 'itemsrc'); 
+                                             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",
+                                    text : "Delete All",
                                     icon : rootURL + '/Pman/templates/images/trash.gif'
                                 }
                             ]
@@ -964,57 +1011,33 @@ Pman.Dialog.XtupleVendorEdit = {
                             {
                                 xtype: 'ColumnModel',
                                 xns: Roo.grid,
-                                dataIndex : 'itemsrc_item_id_item_number',
-                                header : 'Item',
-                                width : 120,
+                                dataIndex : 'vendaddr_code',
+                                header : 'Code',
+                                width : 75,
                                 renderer : function(v) { return String.format('{0}', v); }
                             },
                             {
                                 xtype: 'ColumnModel',
                                 xns: Roo.grid,
-                                dataIndex : 'itemsrc_vend_item_number',
-                                header : 'Vendor item number',
-                                width : 120,
+                                dataIndex : 'vendaddr_addr_id_addr_city',
+                                header : 'District',
+                                width : 100,
                                 renderer : function(v) { return String.format('{0}', v); }
                             },
                             {
                                 xtype: 'ColumnModel',
                                 xns: Roo.grid,
-                                dataIndex : 'itemsrc_vend_item_descrip',
-                                header : 'Vendor item description',
+                                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 : 'itemsrc_vend_uom',
-                                header : 'Uom',
-                                width : 50,
-                                renderer : function(v) { return String.format('{0}', v); }
-                            },
-                            {
-                                xtype: 'ColumnModel',
-                                xns: Roo.grid,
-                                dataIndex : 'itemsrc_minordqty',
-                                header : 'Min ord qty',
-                                width : 50,
-                                renderer : function(v) { return String.format('{0}', v); }
-                            },
-                            {
-                                xtype: 'ColumnModel',
-                                xns: Roo.grid,
-                                dataIndex : 'itemsrc_leadtime',
-                                header : 'Lead time',
-                                width : 75,
-                                renderer : function(v) { return String.format('{0}', v); }
-                            },
-                            {
-                                xtype: 'ColumnModel',
-                                xns: Roo.grid,
-                                dataIndex : 'itemsrc_active',
-                                header : 'Active',
-                                width : 75,
+                                dataIndex : 'vendaddr_addr_id_addr_line2',
+                                header : 'Address Line 2',
+                                width : 200,
                                 renderer : function(v) { return String.format('{0}', v); }
                             }
                         ]