Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Dialog.XtuplePurchaseOrder.bjs
index 9ad4f53..9955b43 100644 (file)
@@ -1,9 +1,9 @@
 {
-    "id": "roo-file-341",
+    "id": "roo-file-21",
     "name": "Pman.Dialog.XtuplePurchaseOrder",
     "parent": "",
     "title": "",
-    "path": "/home/alan/gitlive/web.xtuple/Pman/Xtuple/Pman.Dialog.XtuplePurchaseOrder.bjs",
+    "path": "/home/edward/gitlive/web.xtuple/Pman/Xtuple/Pman.Dialog.XtuplePurchaseOrder.bjs",
     "items": [
         {
             "listeners": {
@@ -90,7 +90,7 @@
                     "items": [
                         {
                             "listeners": {
-                                "|actioncomplete": "function(_self,action)\n{\n    if (action.type == 'setdata') {\n        _this.uploadBtn.disabled = false;\n        if(!_this.data.pohead_id && Pman.Login.authUser.name.length){\n            _this.saveBtn.show();\n            _this.form.findField('pohead_agent_username').setValue(Pman.Login.authUser.name);\n            _this.form.findField('pohead_orderdate').setValue(new Date());\n            return;\n        }\n        _this.dialog.setTitle(\"Edit Purchase Order\");\n        var params = {\n            '_id' : _this.data.pohead_id\n        }\n        if(_this.data.office){\n            params['_roo_office'] = _this.data.office;\n        }\n        \n        this.load({ method: 'GET', params: params});\n        return;\n    }\n    if (action.type == 'load') {\n         _this.dontClose = false;\n        if(_this.data.office){\n            _this.uploadBtn.disabled = true;\n        }\n        _this.saveBtn.hide();\n        if (action.result.data.pohead_status == 'U') {\n            _this.saveBtn.show();\n        }\n        var cn = _this.form.findField('pohead_curr_id');\n        cn.setDisabled(true);\n        if (action.result.data.pohead_id * 1 < 1) {\n            cn.setDisabled(false);\n        }\n        \n        if(_this.grid){\n            _this.grid.footer.onClick('first');\n        }\n        \n        return;\n    }\n    if (action.type =='submit') {\n    \n\n        var cid = this.findField('pohead_id').getValue()*1;\n        if (cid && !_this.dontClose) {\n        \n          _this.dialog.hide();\n        \n             if (_this.callback) {\n                _this.callback.call(_this, _this.form.getValues());\n             }\n             _this.form.reset();\n             return;\n         }\n         Roo.log(action);\n         _this.dontClose = false;\n         _this.data.pohead_id = action.result.data.pohead_id;\n         this.fireEvent('actioncomplete', this,   { \n                type: 'setdata', \n                data: { \n                    pohead_id : action.result.data.pohead_id\n                 } \n         });\n\n         \n    }\n}\n",
+                                "|actioncomplete": "function(_self,action)\n{\n    if (action.type == 'setdata') {\n        _this.uploadBtn.disabled = false;\n        if(!_this.data.pohead_id && Pman.Login.authUser.name.length){\n            _this.saveBtn.show();\n            _this.form.findField('pohead_agent_username').setValue(Pman.Login.authUser.name);\n            _this.form.findField('pohead_orderdate').setValue(new Date());\n            _this.form.findField('pohead_bg_arrival_est_day').setValue(new Date());\n            _this.form.findField('pohead_bg_available_est_day').setValue(new Date());\n            _this.form.findField('pohead_bg_available_latest_day').setValue(new Date());\n            return;\n        }\n        _this.dialog.setTitle(\"Edit Purchase Order\");\n        var params = {\n            '_id' : _this.data.pohead_id\n        }\n        if(_this.data.office){\n            params['_roo_office'] = _this.data.office;\n        }\n        \n        this.load({ method: 'GET', params: params});\n        return;\n    }\n    if (action.type == 'load') {\n         _this.dontClose = false;\n        if(_this.data.office){\n            _this.uploadBtn.disabled = true;\n        }\n        _this.saveBtn.hide();\n        if (action.result.data.pohead_status == 'U') {\n            _this.saveBtn.show();\n        }\n        var cn = _this.form.findField('pohead_curr_id');\n        cn.setDisabled(true);\n        if (action.result.data.pohead_id * 1 < 1) {\n            cn.setDisabled(false);\n        }\n        \n        if(_this.grid){\n            _this.grid.footer.onClick('first');\n        }\n        \n        return;\n    }\n    if (action.type =='submit') {\n    \n\n        var cid = this.findField('pohead_id').getValue()*1;\n        if (cid && !_this.dontClose) {\n        \n          _this.dialog.hide();\n        \n             if (_this.callback) {\n                _this.callback.call(_this, _this.form.getValues());\n             }\n             _this.form.reset();\n             return;\n         }\n         Roo.log(action);\n         _this.dontClose = false;\n         _this.data.pohead_id = action.result.data.pohead_id;\n         this.fireEvent('actioncomplete', this,   { \n                type: 'setdata', \n                data: { \n                    pohead_id : action.result.data.pohead_id\n                 } \n         });\n\n         \n    }\n}\n",
                                 "|rendered": "function (form)\n{\n    _this.form= form;\n}\n",
                                 "actionfailed": "function (_self, action)\n{\n    _this.dialog.el.unmask();\n    if (action.failureType == 'client') {\n        Roo.MessageBox.alert(\"Error\", \"Please fill in all the required fields\");\n    }\n    if (action.failureType == 'server') {\n        Roo.MessageBox.alert(\"Error\", action.result.errorMsg);\n    }\n    _this.dialog.layout.getRegion('center').showPanel(0);\n\n}"
                             },
                                         },
                                         {
                                             "listeners": {
-                                                "|click": "function ()\n{\n    var status = _this.form.findField('pohead_status').getValue();\n    \n    if(status == 'C'){\n        Roo.MessageBox.alert(\"Error\", \"This PO has been closed\");\n        return;\n    }\n    \n    var cs = _this.grid.getSelectionModel().getSelectedCell();\n    if (!cs) {\n        Roo.MessageBox.alert(\"Error\", \"Select a cell\");\n        return;\n    }\n    _this.grid.stopEditing()\n    var r = _this.grid.ds.getAt(cs[0]);\n    \n    if(r.data.poitem_qty_received * 1 > 0){\n        Roo.MessageBox.alert(\"Error\", \"This item has been receipted\");\n        return;\n    }\n    \n    \n    _this.grid.ds.remove(r);\n   \n}"
+                                                "|click": "function ()\n{\n    var status = _this.form.findField('pohead_status').getValue();\n    \n    if(status == 'C'){\n        Roo.MessageBox.alert(\"Error\", \"This PO has been closed\");\n        return;\n    }\n    \n    var cs = _this.grid.getSelectionModel().getSelectedCell();\n    if (!cs) {\n        Roo.MessageBox.alert(\"Error\", \"Select a cell\");\n        return;\n    }\n    _this.grid.stopEditing();\n    var r = _this.grid.ds.getAt(cs[0]);\n    \n    if(r.data.poitem_qty_received * 1 > 0){\n        Roo.MessageBox.alert(\"Error\", \"This item has been receipted\");\n        return;\n    }\n    \n    \n    _this.grid.ds.remove(r);\n   \n}"
                                             },
                                             "cls": "x-btn-text-icon",
                                             "text": "Remove",
                                             "items": [
                                                 {
                                                     "*prop": "field",
+                                                    "allowBlank": false,
                                                     "allowDecimals": false,
                                                     "decimalPrecision": 0,
                                                     "minValue": 1,
                                                 },
                                                 {
                                                     "listeners": {
-                                                        "beforeload": "function (_self, o)\n{\n    o.params = o.params || {};\n    var hid = _this.form.findField('pohead_id').getValue();\n    \n    if(!hid.length){\n        return false;\n    }\n    \n    o.params.poitem_pohead_id = hid;\n    \n    o.params._with_item = 1;\n    \n}"
+                                                        "beforeload": "function (_self, o)\n{\n    o.params = o.params || {};\n    var hid = _this.form.findField('pohead_id').getValue();\n    \n    if(!hid.length){\n        return false;\n    }\n    \n    o.params.poitem_pohead_id = hid;\n    \n    o.params._with_item = 1;\n    \n}",
+                                                        "load": "function (_self, records, options)\n{\n    _this.gltransgrid.footer.onClick('first');\n}"
                                                     },
                                                     "*prop": "dataSource",
                                                     "remoteSort": true,
                                                     "header": "Received",
                                                     "width": 50,
                                                     "xtype": "ColumnModel",
-                                                    "|renderer": "function(v,x,r) \n{\n    return String.format('{0}', (v- r.data.poitem_qty_returned)) ;  \n    \n}",
+                                                    "|renderer": "function(v,x,r) \n{\n    \n\n    var recv = (v- r.data.poitem_qty_returned);\n    if (recv !=  r.data.tx_qty) {\n        return String.format('<s style=\"color:red;font-weight:bold\">{0}</s>{1} ', recv, \n            (r.data.tx_qty *1).toFixed(0)        ) ;      \n    }\n    return String.format('{0}', (v- r.data.poitem_qty_returned)) ;  \n    \n}",
                                                     "|xns": "Roo.grid"
                                                 },
                                                 {
                                                 },
                                                 {
                                                     "listeners": {
-                                                        "beforeload": "function (_self, o)\n{\n    o.params = o.params || {};\n    \n    var s = _this.itemgrid.getSelectionModel().getSelected();\n    if(!s){\n        Roo.MessageBox.alert('Error', 'Please select a item');\n        return false;\n    }\n    \n    o.params._poview = 1;\n    o.params.gltrans_deleted = 0;\n    o.params.gltrans_doctype = 'PO';\n    o.params._linenumber = s.data.poitem_linenumber;\n    o.params._item = s.data.item_number;\n    o.params._ponumber = _this.form.findField('pohead_number').getValue();\n    \n}"
+                                                        "beforeload": "function (_self, o)\n{\n    o.params = o.params || {};\n    \n    var s = _this.itemgrid.getSelectionModel().getSelected();\n    if(!s){\n        this.removeAll();\n        return false;\n    }\n    \n    o.params._poview = 1;\n    o.params.gltrans_deleted = 0;\n    o.params.gltrans_doctype = 'PO';\n    o.params._linenumber = s.data.poitem_linenumber;\n    o.params._item = s.data.item_number;\n    o.params._ponumber = _this.form.findField('pohead_number').getValue();\n    \n}"
                                                     },
                                                     "*prop": "dataSource",
                                                     "remoteSort": true,
                                                             "xtype": "Fill"
                                                         },
                                                         {
-                                                            "text": "Varience",
+                                                            "text": "Apply fixes",
                                                             "xtype": "Button",
                                                             "|xns": "Roo.Toolbar",
                                                             "items": [
                                                                     "xtype": "Menu",
                                                                     "*prop": "menu",
                                                                     "items": [
+                                                                        {
+                                                                            "listeners": {
+                                                                                "|click": "function()\n{\n   var pohead_number = _this.form.findField('pohead_number').getValue();\n    var pohead_id = _this.form.findField('pohead_id').getValue();\n        \n    \n        new Pman.Request({\n            url : baseURL + '/Roo/pohead.php',\n            mask : 'sending',\n            method :'POST',\n            params : {\n                pohead_id : pohead_id,\n                _recv_fix : 1\n                \n            },\n            success : function(res) {\n                Roo.MessageBox.alert('Notice', 'DONE');\n            }\n        });\n    \n    \n    \n    \n    \n}\n"
+                                                                            },
+                                                                            "cls": "x-btn-text-icon",
+                                                                            "text": "Repost goods reciept",
+                                                                            "xtype": "Item",
+                                                                            "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
+                                                                            "|xns": "Roo.menu"
+                                                                        },
+                                                                        {
+                                                                            "|xns": "Roo.menu",
+                                                                            "xtype": "Separator"
+                                                                        },
+                                                                        {
+                                                                            "listeners": {
+                                                                                "|click": "function()\n{\n    var pohead_number = _this.form.findField('pohead_number').getValue();\n    var pohead_id = _this.form.findField('pohead_id').getValue();\n        \n    var fixit = function(){\n        new Pman.Request({\n            url : baseURL + '/Roo/pohead.php',\n            method :'POST',\n            params : {\n                pohead_id : pohead_id,\n                _unitcost : 1\n                \n            },\n            success : function(res) {\n                Roo.MessageBox.alert('Notice', 'DONE');\n            }\n        });\n    }\n    \n    Roo.MessageBox.confirm(\n        \"Confirm\",\n        \"Are you sure to fix the unit cost of \" + pohead_number + \" ?\",\n        function(r) {\n            if (r != 'yes') {\n                return;\n            }\n\n            fixit();\n            return;\n        }\n    ); \n    \n    \n}\n"
+                                                                            },
+                                                                            "cls": "x-btn-text-icon",
+                                                                            "text": "Fix Unit Cost",
+                                                                            "xtype": "Item",
+                                                                            "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
+                                                                            "|xns": "Roo.menu"
+                                                                        },
+                                                                        {
+                                                                            "|xns": "Roo.menu",
+                                                                            "xtype": "Separator"
+                                                                        },
                                                                         {
                                                                             "listeners": {
                                                                                 "|click": "function()\n{\n    var pohead_number = _this.form.findField('pohead_number').getValue();\n    var pohead_id = _this.form.findField('pohead_id').getValue();\n        \n    var addv = function(){\n        new Pman.Request({\n            url : baseURL + '/Roo/pohead.php',\n            method :'POST',\n            params : {\n                pohead_id : pohead_id,\n                _variance : 1\n                \n            },\n            success : function(res) {\n                Roo.MessageBox.alert('Notice', 'DONE');\n            }\n        });\n    }\n    \n    Roo.MessageBox.confirm(\n        \"Confirm\",\n        \"Are you sure to add all the variance for \" + pohead_number + \" ?\",\n        function(r) {\n            if (r != 'yes') {\n                return;\n            }\n\n            addv();\n            return;\n        }\n    ); \n    \n    \n}\n"
                                                                             "xtype": "Item",
                                                                             "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
                                                                             "|xns": "Roo.menu"
+                                                                        },
+                                                                        {
+                                                                            "|xns": "Roo.menu",
+                                                                            "xtype": "Separator"
+                                                                        },
+                                                                        {
+                                                                            "listeners": {
+                                                                                "|click": "function()\n{\n    var pohead_number = _this.form.findField('pohead_number').getValue();\n    var pohead_id = _this.form.findField('pohead_id').getValue();\n        \n    var addv = function(){\n        new Pman.Request({\n            url : baseURL + '/Roo/pohead.php',\n            method :'POST',\n            params : {\n                pohead_id : pohead_id,\n                _fix_voids : 1\n                \n            },\n            success : function(res) {\n                Roo.MessageBox.alert('Notice', 'DONE');\n            }\n        });\n    }\n    \n    Roo.MessageBox.confirm(\n        \"Confirm\",\n        \"Are you sure to add all the fix the voids for \" + pohead_number + \" ?\",\n        function(r) {\n            if (r != 'yes') {\n                return;\n            }\n\n            addv();\n            return;\n        }\n    ); \n    \n    \n}\n"
+                                                                            },
+                                                                            "cls": "x-btn-text-icon",
+                                                                            "text": "Recalculate voids",
+                                                                            "xtype": "Item",
+                                                                            "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'",
+                                                                            "|xns": "Roo.menu"
                                                                         }
                                                                     ]
                                                                 }
                                                             ]
                                                         },
-                                                        {
-                                                            "listeners": {
-                                                                "|click": "function()\n{\n    var pohead_number = _this.form.findField('pohead_number').getValue();\n    var pohead_id = _this.form.findField('pohead_id').getValue();\n        \n    var fixit = function(){\n        new Pman.Request({\n            url : baseURL + '/Roo/pohead.php',\n            method :'POST',\n            params : {\n                pohead_id : pohead_id,\n                _unitcost : 1\n                \n            },\n            success : function(res) {\n                Roo.MessageBox.alert('Notice', 'DONE');\n            }\n        });\n    }\n    \n    Roo.MessageBox.confirm(\n        \"Confirm\",\n        \"Are you sure to fix the unit cost of \" + pohead_number + \" ?\",\n        function(r) {\n            if (r != 'yes') {\n                return;\n            }\n\n            fixit();\n            return;\n        }\n    ); \n    \n    \n}\n"
-                                                            },
-                                                            "cls": "x-btn-text-icon",
-                                                            "text": "Fix Unit Cost",
-                                                            "xtype": "Button",
-                                                            "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
-                                                            "|xns": "Roo.Toolbar"
-                                                        },
                                                         {
                                                             "listeners": {
                                                                 "|click": "function()\n{\n    var s = _this.gltransgrid.selModel.getSelected();\n    if (!s) {\n        Roo.MessageBox.alert(\"Error\", \"Select an item to reverse\");\n        return;\n    }\n    \n    var fixit = function(){\n        new Pman.Request({\n            url : baseURL + '/Roo/invdetail.php',\n            method :'POST',\n            params : {\n               \n                _reverse :  s.data.invdetail_id \n            },\n            success : function(res) {\n                Roo.MessageBox.alert('Notice', 'DONE');\n            }\n        });\n    }\n    \n    Roo.MessageBox.confirm(\n        \"Confirm\",\n        \"Are you sure to reverse that line\",\n        function(r) {\n            if (r != 'yes') {\n                return;\n            }\n\n            fixit();\n            return;\n        }\n    ); \n    \n    \n}\n"
                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
                                                     "|xns": "Roo.grid"
                                                 },
+                                                {
+                                                    "*prop": "colModel[]",
+                                                    "align": "right",
+                                                    "dataIndex": "location_name",
+                                                    "header": "Location",
+                                                    "width": 60,
+                                                    "xtype": "ColumnModel",
+                                                    "|renderer": "function(v,x,r) {\n  \n   \n    return String.format('{0}', v); \n\n}",
+                                                    "|xns": "Roo.grid"
+                                                },
                                                 {
                                                     "*prop": "colModel[]",
                                                     "align": "right",
                                                 },
                                                 {
                                                     "listeners": {
-                                                        "beforeload": "function (_self, o)\n{\n    o.params.pohead_id = _this.form.findField('pohead_id').getValue();\n    if (! o.params.pohead_id ) {\n        this.removeAll();\n        return false;\n    }\n    o.params._split_sales = _this.glsalesbtn.pressed ? 1 : 0;\n}"
+                                                        "beforeload": "function (_self, o)\n{\n    o.params.pohead_id = _this.form.findField('pohead_id').getValue();\n    if (! o.params.pohead_id ) {\n        this.removeAll();\n        return false;\n    }\n    o.params._split_sales = _this.glsalesbtn.pressed ? 1 : 0;\n}",
+                                                        "load": "function (_self, records, options)\n{\n _this.gltxdgrid.footer.onClick('first');\n}"
                                                     },
                                                     "*prop": "dataSource",
                                                     "remoteSort": true,
                                                             "xtype": "Button",
                                                             "|xns": "Roo.Toolbar"
                                                         },
+                                                        {
+                                                            "|xns": "Roo.Toolbar",
+                                                            "xtype": "Fill"
+                                                        },
                                                         {
                                                             "listeners": {
-                                                                "click": "function (_self, e)\n{\n    new Pman.Request( {\n        url : baseURL + '/Roo/Gltrans',\n        method : 'GET',\n        mask:  'sending',\n        params : {\n            pohead_id : _this.form.findField('pohead_id').getValue(),\n            _autovoid : 1,\n        },\n        success : function() {\n            _this.gltxdgrid.footer.onClick('first');\n        }\n            \n    \n    });\n}"
+                                                                "click": "function (_self, e)\n{\n    new Pman.Request( {\n        url : baseURL + '/Roo/Gltrans',\n        method : 'GET',\n        mask:  'sending',\n        params : {\n            pohead_id : _this.form.findField('pohead_id').getValue(),\n            _autovoid : 1\n        },\n        success : function() {\n            _this.gltxpanel.footer.onClick('first');\n        }\n            \n    \n    });\n}"
                                                             },
                                                             "text": "AutoVoid",
                                                             "xtype": "Button",
                                                             "text": "Download",
                                                             "xtype": "Button",
                                                             "|xns": "Roo.Toolbar"
-                                                        },
-                                                        {
-                                                            "listeners": {
-                                                                "render": "function (_self)\n{\n    _this.glvoidshow = _self;\n}",
-                                                                "click": "function (_self, e)\n{\n    (function()  { _this.gltxgrid.footer.onClick('first'); }).defer(100);\n}"
-                                                            },
-                                                            "enableToggle": true,
-                                                            "pressed": true,
-                                                            "text": "Hide Void",
-                                                            "xtype": "Button",
-                                                            "|xns": "Roo.Toolbar"
-                                                        },
-                                                        {
-                                                            "listeners": {
-                                                                "click": "function (_self, e)\n{\n    new Pman.Request( {\n        url : baseURL + '/Roo/Gltrans',\n        method : 'GET',\n        mask:  'sending',\n        params : {\n            pohead_id : _this.form.findField('pohead_id').getValue(),\n            _autovoid : 1,\n        },\n        success : function() {\n            _this.gltxdgrid.footer.onClick('first');\n        }\n            \n    \n    });\n}"
-                                                            },
-                                                            "text": "AutoVoid",
-                                                            "xtype": "Button",
-                                                            "|xns": "Roo.Toolbar"
                                                         }
                                                     ]
                                                 },
                 },
                 {
                     "listeners": {
-                        "click": "function (_self, e)\n{\n    if(_this.grid){\n        var ar = [];\n\n        _this.grid.ds.each(function(r) {\n            ar.push({\n                poitem_id : r.data.poitem_id,\n                poitem_itemsite_id : r.data.poitem_itemsite_id,\n                poitem_unitprice : r.data.poitem_unitprice,\n                poitem_qty_ordered : r.data.poitem_qty_ordered\n            });\n                \n        });\n        \n        _this.form.findField('items').setValue(JSON.stringify(ar));\n    }\n        \n    _this.form.doAction(\"submit\");\n\n}",
+                        "click": "function (_self, e)\n{\n    if(_this.grid){\n        var ar = [];\n        var err = false;\n        _this.grid.ds.each(function(r) {\n            if(r.data.poitem_unitprice < 1){\n                err = true;\n                return;\n            }\n            ar.push({\n                poitem_id : r.data.poitem_id,\n                poitem_itemsite_id : r.data.poitem_itemsite_id,\n                poitem_unitprice : r.data.poitem_unitprice,\n                poitem_qty_ordered : r.data.poitem_qty_ordered\n            });\n                \n        });\n \n        if(err){\n            Roo.MessageBox.alert('Error','Unit Price does not allow $0' );\n            return;\n        }   \n               \n        _this.form.findField('items').setValue(JSON.stringify(ar));\n    }\n        \n    _this.form.doAction(\"submit\");\n\n}",
                         "render": "function (_self)\n{\n    _this.saveBtn = _self;\n}"
                     },
                     "*prop": "buttons[]",