Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Dialog.XtupleTransfer.js
index 7206add..a4728d7 100644 (file)
@@ -69,6 +69,7 @@ Pman.Dialog.XtupleTransfer = {
                                                    Roo.log('setdata');
                                                    Roo.log(_this.data);       
                                                    // reversal...
+                                                   _this.toLocation._is_internalcompany = false;
                                                    _this.grid.setColumns();
                                                    _this.saveBtn.show();            
                                                    if (_this.data.createFromRev) {
@@ -225,6 +226,12 @@ Pman.Dialog.XtupleTransfer = {
                                                     this.findField('_roo_office').setValue(  _this.data._roo_office );
                                                     Roo.log(action);
                                                     _this.data = action.result.data;
+                                                    
+                                                    _this.toLocation._is_internalcompany = true;
+                                                    if(!_this.data.cust_to_internalcompany || !_this.data.cust_to_internalcompany.length){
+                                                        _this.toLocation._is_internalcompany = false;
+                                                    }
+                                                    
                                                     if(_this.data.invhist_transfer_void){
                                                         _this.saveBtn.hide();
                                                     }
@@ -518,6 +525,7 @@ Pman.Dialog.XtupleTransfer = {
                                                             {
                                                                 xtype: 'ComboBox',
                                                                 xns: Roo.form,
+                                                                actionMode : 'fieldEl',
                                                                 allowBlank : true,
                                                                 displayField : 'desc',
                                                                 editable : false,
@@ -633,11 +641,13 @@ Pman.Dialog.XtupleTransfer = {
                                         if((!_this.data.cust_to_internalcompany || !_this.data.cust_to_internalcompany.length) && !_this.toLocation._is_internalcompany){
                                             cm.setHidden(cid('invhist_transfer_item_unit_price'), true);
                                             cm.setHidden(cid('invhist_transfer_item_unit_price_default'), true);
+                                            _this.form.findField('invhist_transfer_price').hide();
                                             return;
                                         }
                                         
                                         cm.setHidden(cid('invhist_transfer_item_unit_price'), false);
                                         cm.setHidden(cid('invhist_transfer_item_unit_price_default'), false);
+                                        _this.form.findField('invhist_transfer_price').show();
                                     },
                                     sm : {
                                         xtype: 'CellSelectionModel',
@@ -690,6 +700,7 @@ Pman.Dialog.XtupleTransfer = {
                                             xtype: 'HttpProxy',
                                             xns: Roo.data,
                                             method : 'GET',
+                                            timeout : 180000,
                                             url : baseURL + '/Xtuple/Roo/invhist_transfer_item.php'
                                         },
                                         reader : {
@@ -1553,7 +1564,7 @@ Pman.Dialog.XtupleTransfer = {
                         activate : function() {
                             _this.tpanel = this;
                             if (_this.tgrid) {
-                                _this.tgrid.footer.onClick('first');
+                                _this.tgrid.ds.load({});
                             }
                         }
                     },
@@ -1571,12 +1582,71 @@ Pman.Dialog.XtupleTransfer = {
                             {
                                 _this.tgrid = this; 
                                 if (_this.tpanel.active) {
-                                   this.footer.onClick('first');
+                                   this.ds.load({});
                                 }
                             }
                         },
                         autoExpandColumn : 'item_number',
                         loadMask : true,
+                        toolbar : {
+                            xtype: 'Toolbar',
+                            xns: Roo,
+                            items : [
+                                {
+                                    xtype: 'Button',
+                                    xns: Roo.Toolbar,
+                                    listeners : {
+                                        click : function()
+                                        {
+                                            var id = _this.form.findField('invhist_transfer_id').getValue();
+                                        
+                                            if(id * 1 < 1){
+                                                return;
+                                            }
+                                            
+                                            var err = false;
+                                            
+                                            _this.tgrid.ds.each(function (r) {
+                                                if (_this.data.invhist_transfer_void && r.data.transfered_qty * 1 == 0 && r.data.expected_qty * 1 == 0) {
+                                                    return;
+                                                }
+                                                if(!_this.data.invhist_transfer_void && r.data.transfered_qty * 1 - r.data.expected_qty * 1 == 0){
+                                                    return;
+                                                }
+                                                
+                                                err = true;
+                                           });
+                                           
+                                           if(!err){
+                                                Roo.MessageBox.alert("Notice", "Nothing Wrong!");
+                                                return;
+                                           }
+                                           
+                                            new Pman.Request({
+                                                url : baseURL + '/Roo/invhist_transfer',
+                                                method : 'POST',
+                                                mask: 'Fixing',
+                                                timeout : 1200000, //20 minutes...! - big xfer should be 10mins.
+                                                params : {
+                                                    invhist_transfer_id : id,
+                                                    _fix : 1
+                                                },
+                                                success : function () 
+                                                {
+                                                    _this.tgrid.ds.load({});
+                                                }
+                                            });
+                                            
+                                            
+                                            
+                                        }
+                                    },
+                                    cls : 'x-btn-text-icon',
+                                    text : "Fix Transfer",
+                                    icon : Roo.rootURL + 'images/default/tree/leaf.gif'
+                                }
+                            ]
+                        },
                         dataSource : {
                             xtype: 'Store',
                             xns: Roo.data,
@@ -1584,7 +1654,7 @@ Pman.Dialog.XtupleTransfer = {
                                 beforeload : function (_self, options)
                                 {
                                     options.params = options.params || {};
-                                
+                                    options.params.limit = 9999;
                                     if(_this.data.cust_to_internalcompany.length){
                                         this.removeAll();
                                         return false;
@@ -1592,9 +1662,14 @@ Pman.Dialog.XtupleTransfer = {
                                     
                                     var id = _this.form.findField('invhist_transfer_id').getValue();
                                     
+                                    if(id * 1 < 1){
+                                        this.removeAll();
+                                        return false;
+                                    }
+                                    
                                     options.params.invhist_transfer_item_invhist_transfer_id = id;
                                     
-                                    options.params._with_moved = 1;
+                                    options.params._with_expected = 1;
                                     
                                 }
                             },
@@ -1628,14 +1703,6 @@ Pman.Dialog.XtupleTransfer = {
                                 ]
                             }
                         },
-                        footer : {
-                            xtype: 'PagingToolbar',
-                            xns: Roo,
-                            displayInfo : true,
-                            displayMsg : "Displaying Transfer Items{0} - {1} of {2}",
-                            emptyMsg : "Nothing found",
-                            pageSize : 25
-                        },
                         colModel : [
                             {
                                 xtype: 'ColumnModel',
@@ -1648,18 +1715,31 @@ Pman.Dialog.XtupleTransfer = {
                             {
                                 xtype: 'ColumnModel',
                                 xns: Roo.grid,
-                                dataIndex : 'invhist_transfer_item_qty',
-                                header : 'transfered',
+                                dataIndex : 'transfered_qty',
+                                header : 'Transfered',
                                 width : 100,
-                                renderer : function(v) { return String.format('{0}', v); }
+                                renderer : function(v,x,r) 
+                                { 
+                                    if(v && r.data.transfered_qty * 1 != r.data.expected_qty * 1){
+                                        return String.format('<span style="color:red">{0}</span>', v); 
+                                    }
+                                    return String.format('{0}', v ? v : 0);  
+                                }
                             },
                             {
                                 xtype: 'ColumnModel',
                                 xns: Roo.grid,
-                                dataIndex : 'moved_qty',
-                                header : 'Moved Qty',
+                                dataIndex : 'expected_qty',
+                                header : 'Expected',
                                 width : 100,
-                                renderer : function(v) { return String.format('{0}', v ? v : 0); }
+                                renderer : function(v,x,r) 
+                                { 
+                                    
+                                    if(v && r.data.transfered_qty * 1 != r.data.expected_qty * 1){
+                                        return String.format('<span style="color:red">{0}</span>', v); 
+                                    }
+                                    return String.format('{0}', v ? v : 0); 
+                                }
                             }
                         ]
                     }
@@ -1750,6 +1830,7 @@ Pman.Dialog.XtupleTransfer = {
                            new Pman.Download({
                                 url : baseURL + '/Xtuple/Roo/invhist_transfer',
                                 method : 'GET',
+                                timeout : 90000,
                                 params : {
                                     _roo_office : _this.form.findField('_roo_office').getValue(),
                                    _download : _this.data.invhist_transfer_id