Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Tab.XtuplePurchaseRecv.bjs
index 7855558..6cced41 100644 (file)
@@ -1,9 +1,9 @@
 {
-    "id": "roo-file-361",
+    "id": "roo-file-57",
     "name": "Pman.Tab.XtuplePurchaseRecv",
     "parent": "Pman.Tab.XtuplePurchases",
     "title": "Pman.Tab.XtuplePurchaseRecv",
-    "path": "/home/alan/gitlive/web.xtuple/Pman/Xtuple/Pman.Tab.XtuplePurchaseRecv.bjs",
+    "path": "/home/edward/gitlive/web.xtuple/Pman/Xtuple/Pman.Tab.XtuplePurchaseRecv.bjs",
     "items": [
         {
             "background": true,
@@ -45,8 +45,8 @@
                                 {
                                     "listeners": {
                                         "|render": "function() \n{\n    _this.grid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.ppanel.active) {\n       this.footer.onClick('first');\n    }\n}",
-                                        "|rowdblclick": "function (_self, rowIndex, e)\n{\n    var r = _this.grid.ds.getAt(rowIndex);\n    \n    Pman.Dialog.XtuplePurchaseOrder.show( { pohead_id : r.data.pohead_id }, function() {\n        _this.grid.footer.onClick('refresh');\n    }); \n}\n",
-                                        "rowclick": "function (_self, rowIndex, e)\n{\n    _this.rggrid.ds.load({});\n}"
+                                        "cellclick": "function (_self, rowIndex, columnIndex, e)\n{\n\n    var applyVoucher = function(){\n        Roo.MessageBox.confirm(\"Confirm\", \"Are you sure to apply voucher for the selected PO completely?\",\n            function(v) {\n                if (v != 'yes') {\n                    return;\n                }\n                                \n                Pman.request({\n                    url: baseURL+'/Roo/Pohead.php',\n                    method :'POST',\n                    mask : 'Processing',\n                    params : {\n                        'pohead_id' : s.data.pohead_id,\n                        '_applyVoucher' : 1\n                    },\n                    success : function  () {\n                        _this.grid.footer.onClick('refresh');\n                        return;\n                    }\n                });\n            });\n            return;\n    }\n    \n    var di = _this.grid.getColumnModel().getDataIndex(columnIndex);\n    var s = _this.grid.ds.getAt(rowIndex);\n    \n    if(di == 'pohead_vouchered'){\n        if(s.data.pohead_status != 'O'){\n            Roo.MessageBox.alert('Error', 'Please Open this PO first');\n            return;\n        }\n        if(Math.round(s.data.pohead_vouchered*100) > Math.round(s.data.pohead_val*100)){\n            //Roo.MessageBox.alert('Error', 'This PO has been apply completely!');\n            return;\n        }\n        applyVoucher();\n        \n        return;\n    }\n    \n    if(di == 'pohead_paid'){ // comming soon...\n        return;\n    }\n    \n    \n    \n    _this.rggrid.ds.load({});\n}",
+                                        "rowdblclick": "function (_self, rowIndex, e)\n{\n\n    \n    var r = _this.grid.ds.getAt(rowIndex);\n    \n    Pman.Dialog.XtuplePurchaseOrder.show( { pohead_id : r.data.pohead_id }, function() {\n        _this.grid.footer.onClick('refresh');\n    });  \n}"
                                     },
                                     "*prop": "grid",
                                     "autoExpandColumn": "pohead_vend_id_vend_name",
@@ -63,7 +63,7 @@
                                         },
                                         {
                                             "listeners": {
-                                                "beforeload": "function (_self, o)\n{\n    o.params._with_recv = 1;\n\n    \n    o.params['query[number]'] = _this.searchBox.getValue();\n    \n    // only filter by type if the number is empty..\n    if (!o.params['query[number]'].length) {\n        o.params.pohead_status = _this.status.getValue();\n    }\n    \n    \n}",
+                                                "beforeload": "function (_self, o)\n{\n    o.params._with_recv = 1;\n\n    \n    o.params['query[number]'] = _this.searchBox.getValue();\n    \n    // only filter by type if the number is empty..\n    if (!o.params['query[number]'].length) {\n        if (_this.status.getValue() != 'E') {\n            o.params._status = _this.status.getValue();\n        }\n    }\n    if (_this.status.getValue() == 'E') {\n        o.params['!pohead_has_error'] = 0;\n    }\n    \n    \n}",
                                                 "load": "function (_self, records, options)\n{\n    \n    (function() { _this.rggrid.ds.load({}); }).defer(100);\n}"
                                             },
                                             "*prop": "dataSource",
                                                 {
                                                     "listeners": {
                                                         "render": "function (_self)\n{\n  _this.status = _self;\n}",
-                                                        "select": "function (combo, record, index)\n{\n    Roo.log('select');\n    _this.grid.footer.onClick('first');\n}"
+                                                        "select": "function (combo, record, index)\n{\n\n    _this.grid.footer.onClick('first');\n}"
                                                     },
                                                     "allowBlank": false,
                                                     "displayField": "fname",
                                                     "mode": "local",
                                                     "name": "cm_status_name",
                                                     "triggerAction": "all",
-                                                    "value": "O",
+                                                    "value": "OU",
                                                     "valueField": "ftype",
                                                     "width": 150,
                                                     "xtype": "ComboBox",
                                                         {
                                                             "*prop": "store",
                                                             "xtype": "SimpleStore",
-                                                            "|data": "[ \n    [ 'O', \"Open\"],\n    [ 'C' , \"Closed\"],\n    [ 'U', \"Unreleased\"] \n]\n",
+                                                            "|data": "[ \n    [ 'OU', \"Open And Unreleased\"],\n    [ 'O', \"Open\"],\n    [ 'C' , \"Closed\"],\n    [ 'U', \"Unreleased\"],\n    [ 'E' , \"Has Errors\" ]\n]\n",
                                                             "|fields": "[  'ftype', 'fname']",
                                                             "|xns": "Roo.data"
                                                         }
                                                             "items": [
                                                                 {
                                                                     "listeners": {
-                                                                        "click": "function (_self, e)\n{\n    var sel = _this.grid.selModel.getSelected();\n    if (!sel) {\n        Roo.MessageBox.alert(\"Error\", \"Select a row\");\n        return;\n    }\n    if (sel.data.pohead_status == 'C') {\n        Roo.MessageBox.alert(\"Error\", \"Purchase order is already closed\");\n        return;\n    }\n    \n    new Pman.Request({\n        url : baseURL + '/Roo/pohead',\n        mask : 'Closing',\n        method : 'POST',\n        params : {\n            pohead_id : sel.data.pohead_id,\n            _close : 1\n        },\n        success : function() {\n            _this.grid.footer.onClick('refresh');\n        }\n    });\n       \n    \n}"
+                                                                        "click": "function (_self, e)\n{\n    var sel = _this.grid.selModel.getSelected();\n    if (!sel) {\n        Roo.MessageBox.alert(\"Error\", \"Select a row\");\n        return;\n    }\n    \n    if (sel.data.pohead_status == 'C') {\n        Roo.MessageBox.alert(\"Error\", \"Purchase order is already closed\");\n        return;\n    }\n    \n    new Pman.Request({\n        url : baseURL + '/Roo/pohead',\n        mask : 'Closing',\n        method : 'POST',\n        params : {\n            pohead_id : sel.data.pohead_id,\n            _close : 1\n        },\n        success : function() {\n            _this.grid.footer.onClick('refresh');\n        }\n    });\n       \n    \n}"
                                                                     },
                                                                     "text": "Close Selected",
                                                                     "xtype": "Item",
                                                                 },
                                                                 {
                                                                     "listeners": {
-                                                                        "click": "function (_self, e)\n{\n    var sel = _this.grid.selModel.getSelected();\n    if (!sel) {\n        Roo.MessageBox.alert(\"Error\", \"Select a row\");\n        return;\n    }\n    if (sel.data.pohead_status != 'O') {\n        Roo.MessageBox.alert(\"Error\", \"Purchase order is not Open\");\n        return;\n    }\n    \n    new Pman.Request({\n        url : baseURL + '/Roo/pohead',\n        mask : 'Unreleasing',\n        method : 'POST',\n        params : {\n            pohead_id : sel.data.pohead_id,\n            _unrelease : 1\n        },\n        success : function() {\n            _this.grid.footer.onClick('refresh');\n        }\n    });\n       \n    \n}"
+                                                                        "click": "function (_self, e)\n{\n    var sel = _this.grid.selModel.getSelected();\n    if (!sel) {\n        Roo.MessageBox.alert(\"Error\", \"Select a row\");\n        return;\n    }\n    \n    \n    if (sel.data.pohead_status != 'O') {\n        Roo.MessageBox.alert(\"Error\", \"Purchase order is not Open\");\n        return;\n    }\n    \n    new Pman.Request({\n        url : baseURL + '/Roo/pohead',\n        mask : 'Unreleasing',\n        method : 'POST',\n        params : {\n            pohead_id : sel.data.pohead_id,\n            _unrelease : 1\n        },\n        success : function() {\n            _this.grid.footer.onClick('refresh');\n        }\n    });\n       \n    \n}"
                                                                     },
-                                                                    "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'",
                                                                     "text": "Unrelease Selected",
                                                                     "xtype": "Item",
+                                                                    "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'",
                                                                     "|xns": "Roo.menu"
                                                                 },
                                                                 {
                                                                     "listeners": {
-                                                                        "click": "function (_self, e)\n{\n    var sel = _this.grid.selModel.getSelected();\n    if (!sel) {\n        Roo.MessageBox.alert(\"Error\", \"Select a row\");\n        return;\n    }\n    if (sel.data.pohead_status == 'O') {\n        Roo.MessageBox.alert(\"Error\", \"Purchase order is already Open\");\n        return;\n    }\n    \n    new Pman.Request({\n        url : baseURL + '/Roo/pohead',\n        mask : 'Reopening',\n        method : 'POST',\n        params : {\n            pohead_id : sel.data.pohead_id,\n            _reopen : 1\n        },\n        success : function() {\n            _this.grid.footer.onClick('refresh');\n        }\n    });\n       \n    \n}"
+                                                                        "click": "function (_self, e)\n{\n    var sel = _this.grid.selModel.getSelected();\n    if (!sel) {\n        Roo.MessageBox.alert(\"Error\", \"Select a row\");\n        return;\n    }\n    \n    if (sel.data.pohead_status == 'O') {\n        Roo.MessageBox.alert(\"Error\", \"Purchase order is already Open\");\n        return;\n    }\n    \n    new Pman.Request({\n        url : baseURL + '/Roo/pohead',\n        mask : 'Reopening',\n        method : 'POST',\n        params : {\n            pohead_id : sel.data.pohead_id,\n            _reopen : 1\n        },\n        success : function() {\n            _this.grid.footer.onClick('refresh');\n        }\n    });\n       \n    \n}"
                                                                     },
                                                                     "text": "Reopen",
                                                                     "xtype": "Item",
                                                 },
                                                 {
                                                     "listeners": {
-                                                        "render": "function (_self)\n{\n    _this.reportSince = _self;\n}"
+                                                        "render": "function (_self)\n{\n    _this.reportSince = _self;\n    \n    this.setValue((new Date()).add(Date.MONTH, -1)) ; //.format('Y-m-d');\n}"
                                                     },
+                                                    "format": "d/M/Y",
                                                     "useIso": true,
+                                                    "width": 100,
                                                     "xtype": "DateField",
                                                     "|xns": "Roo.form"
                                                 },
                                                                                 },
                                                                                 {
                                                                                     "listeners": {
-                                                                                        "click": "function (_self, e)\n{\n \n    var params  =   {\n        template: 'APAging',\n        filename : 'ARAging-' + (new Date()).format('Y-m-d'),\n        'param[0]':   \"relDate:string='\" + (new Date()).format('Y-m-d') + \"'\",\n        'param[1]':   \"useDocDate:number=1\"\n    };\n    \n    var s = _this.grid.getSelectionModel().getSelected();\n    \n    if(s){\n        if(s.data.pohead_vend_id > 0){\n            params['param[2]'] = 'vend_id:number=' + s.data.pohead_vend_id;\n        }\n    }\n    \n    new Pman.Download({\n      url : baseURL + '/Xtuple/Print',\n      params :   params,\n      method : 'GET'\n    });\n    Roo.MessageBox.alert(\"Notice\", \"Report will download shortly\");\n}"
+                                                                                        "click": "function (_self, e)\n{\n \n    var params  =   {\n        template: 'APAging',\n        filename : 'ARAging-' + (new Date()).format('Y-m-d'),\n        'param[0]':   \"relDate:string='\" + (new Date()).format('Y-m-d') + \"'\",\n        'param[1]':   \"useDocDate:number=1\"\n    };\n    \n    var s = _this.grid.getSelectionModel().getSelected();\n    \n    if(s){\n        if(s.data.pohead_vend_id > 0){\n            params['param[2]'] = 'vend_id:number=' + s.data.pohead_vend_id;\n        }\n    }\n    \n    \n    new Pman.Download({\n      url : baseURL + '/Xtuple/Print',\n      params :   params,\n      method : 'GET'\n    });\n    Roo.MessageBox.alert(\"Notice\", \"Report will download shortly\");\n}"
                                                                                     },
                                                                                     "text": "as PDF",
                                                                                     "xtype": "Item",
                                                                             "*prop": "menu",
                                                                             "items": [
                                                                                 {
-                                                                                    "|xns": "Roo.menu",
-                                                                                    "xtype": "Item"
+                                                                                    "listeners": {
+                                                                                        "click": "function (_self, e)\n{\n    var dt = Date.parseDate( _this.reportSince.getValue(), 'Y-m-d');\n    \n    var params = {\n        '_group' : 'recvgrp',\n        '_name' : 'byorder',\n        'limit' : 99999,\n        'startDate:text' : dt.format('Y-m-d'),\n        'endDate:text' : dt.add(Date.MONTH,1).format('Y-m-d'),\n        'csvTitles' : '*',\n        'csvCols' : '*'\n    };\n    \n    new Pman.Download({\r\n      url : baseURL + '/Roo/Metasql',\r\n      params :   params,\r\n      method : 'GET'\r\n    });\r\n    Roo.MessageBox.alert(\"Notice\", \"Report will download shortly\");\r\n    \r\n}"
+                                                                                    },
+                                                                                    "text": "For 1 month",
+                                                                                    "xtype": "Item",
+                                                                                    "|xns": "Roo.menu"
+                                                                                },
+                                                                                {
+                                                                                    "listeners": {
+                                                                                        "click": "function (_self, e)\n{\n    var dt = Date.parseDate( _this.reportSince.getValue(), 'Y-m-d');\n    \n    var params = {\n        '_group' : 'recvgrp',\n        '_name' : 'byorder',\n        'limit' : 99999,\n        'startDate:text' : dt.format('Y-m-d'),\n        'endDate:text' : dt.add(Date.YEAR,1).format('Y-m-d'),\n        'csvTitles' : '*',\n        'csvCols' : '*'\n    };\n    \n    new Pman.Download({\r\n      url : baseURL + '/Roo/Metasql',\r\n      params :   params,\r\n      method : 'GET'\r\n    });\r\n    Roo.MessageBox.alert(\"Notice\", \"Report will download shortly\");\r\n    \r\n}"
+                                                                                    },
+                                                                                    "text": "For 1 year",
+                                                                                    "xtype": "Item",
+                                                                                    "|xns": "Roo.menu"
                                                                                 }
                                                                             ]
                                                                         }
                                             "header": "Vouchered",
                                             "width": 75,
                                             "xtype": "ColumnModel",
-                                            "|renderer": "function(v,x,r) { \n\n    var f =  (Math.round(v*100) != Math.round(r.data.pohead_paid*100)) ? '<span style=\"color:red;font-weight:bold\">{0}</span>' : '{0}';\n    return String.format(f,  v ? Roo.util.Format.usMoney( v) : '' ); \n }",
+                                            "|renderer": "function(v,x,r) { \n\n    Roo.log(v*1);\n    var f =  '<span style=\"{0}\">{1}</span>';\n    \n    var style = '';\n    \n    if(Math.round(v*100) != Math.round(r.data.pohead_paid*100)){\n        style = 'color:red;font-weight:bold';\n    }\n    \n    if(Math.round(v*100) < Math.round(r.data.pohead_val*100)){\n        f = '<img class=\"x-grid-check-icon\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/> &nbsp;' +\n             '<span style=\"{0}\">{1}</span>';\n    }\n    \n    return String.format(f,  style, v * 1 ? Roo.util.Format.usMoney(v) : '' ); \n }",
                                             "|xns": "Roo.grid"
                                         },
                                         {
                                             "align": "right",
                                             "dataIndex": "pohead_qty_in_transit",
                                             "header": "In Transit",
+                                            "hidden": true,
                                             "width": 75,
                                             "xtype": "ColumnModel",
                                             "|renderer": "function(v,x,r) {\n     var vv = v - (1*r.data.pohead_qty_transfered_unposted) -\n         (1*r.data.pohead_qty_transfered) ;\n     return String.format('{0}',vv ? (1*vv).toFixed(0) : ''); \n     \n }",
                                             "*prop": "colModel[]",
                                             "align": "right",
                                             "dataIndex": "pohead_qty_recv",
-                                            "header": "Recieved",
+                                            "header": "Received",
                                             "width": 75,
                                             "xtype": "ColumnModel",
-                                            "|renderer": "function(v,x,r) {\n   \n    // total recieved = recv + recv_transfered - intransit?\n    \n    // old style = 0 in transit\n    // all delivered direct to warehouse\n    // 0 in \n    \n    // new style = 100 in transit\n    // it will record 100 in transit, and 100 recieved\n    // and \n    \n    // recv 610,unposted = 0 , transfer 610, in transit 610\n   \n     var recv = (1*r.data.pohead_qty_recv) +\n           (1*r.data.pohead_qty_transfered_unposted) +\n             (1*r.data.pohead_qty_transfered) - \n             (1*r.data.pohead_qty_in_transit) ;\n                         \n    \n    if(r.data.pohead_qty_transfered_unposted * 1 > 0){\n        return String.format('<b style=\"color:red\" qtip=\"{1} are Unposted\">{0}</b>', recv ? (1*recv).toFixed(0) : '',\n        r.data.pohead_qty_transfered_unposted); \n    }\n    \n    var format = '{0}';\n    if(recv != r.data.pohead_qty){\n        format = '<span style=\"color:red\">{0}</span>';\n    }\n    \n    return String.format(format, recv ? (1*recv).toFixed(0) : '');\n     \n }",
+                                            "|renderer": "function(v,x,r) {\n   \n    // total recieved = recv + recv_transfered - intransit?\n    \n    // old style = 0 in transit\n    // all delivered direct to warehouse\n    // 0 in \n    \n    // new style = 100 in transit\n    // it will record 100 in transit, and 100 recieved\n    // and \n    \n    // recv 610,unposted = 0 , transfer 610, in transit 610\n   \n     var recv = (1*r.data.pohead_qty_recv) +\n           (1*r.data.pohead_qty_transfered_unposted) +\n             (1*r.data.pohead_qty_transfered)  ;\n                         \n    \n    if(r.data.pohead_qty_transfered_unposted * 1 > 0){\n        return String.format('<b style=\"color:red\" qtip=\"{1} are Unposted\">{0}</b>', recv ? (1*recv).toFixed(0) : '',\n        r.data.pohead_qty_transfered_unposted); \n    }\n    \n    var format = '{0}';\n    if(recv != r.data.pohead_qty){\n        format = '<span style=\"color:red\">{0}</span>';\n    }\n    \n    return String.format(format, recv ? (1*recv).toFixed(0) : '');\n     \n }",
                                             "|xns": "Roo.grid"
                                         }
                                     ]
                                                     "items": [
                                                         {
                                                             "listeners": {
-                                                                "beforeload": "function (_self, options)\n{\n    if (!_this.grid || !_this.grid.selModel.getSelected()) {\n         this.removeAll();\n         if (_this.rgrid) {\n            _this.rgrid.ds.removeAll();\n        }\n        return false;\n    }\n    var r = _this.grid.selModel.getSelected();\n    options.params = options.params || {};\n    options.params.recvgrp_pohead_id = _this.grid.selModel.getSelected().data.pohead_id;\n    \n}",
+                                                                "beforeload": "function (_self, options)\n{\n    if (!_this.grid || !_this.grid.selModel.getSelected()) {\n         this.removeAll();\n         if (_this.rgrid) {\n            _this.rgrid.ds.removeAll();\n        }\n        return false;\n    }\n    var r = _this.grid.selModel.getSelected();\n    \n     \n    options.params = options.params || {};\n    options.params.recvgrp_pohead_id = r.data.pohead_id;\n    \n}",
                                                                 "load": "function (_self, records, options)\n{\n    _this.rgrid.footer.onClick('first');\n}"
                                                             },
                                                             "*prop": "dataSource",
                                                                 },
                                                                 {
                                                                     "listeners": {
-                                                                        "|click": "function()\n{\n     var s  = _this.grid.selModel.getSelected();\n     if (!s) {\n        Roo.MessageBox.alert(\"Error\", \"Select a purchase order\");\n        return\n    }\n    Pman.Dialog.XtupleRecvGrp.show( {\n         recvgrp_pohead_id : s.data.pohead_id ,\n         recvgrp_pohead_id_pohead_number : s.data.pohead_number\n     } , function() {\n        _this.grid.footer.onClick('refresh');\n   }); \n}\n"
+                                                                        "|click": "function()\n{\n     var s  = _this.grid.selModel.getSelected();\n     if (!s) {\n        Roo.MessageBox.alert(\"Error\", \"Select a purchase order\");\n        return\n    }\n    \n    Pman.Dialog.XtupleRecvGrp.show( {\n         recvgrp_pohead_id : s.data.pohead_id ,\n         recvgrp_pohead_id_pohead_number : s.data.pohead_number\n     } , function() {\n        _this.grid.footer.onClick('refresh');\n   }); \n}\n"
                                                                     },
                                                                     "cls": "x-btn-text-icon",
                                                                     "text": "Add Receipt",
                                                     "items": [
                                                         {
                                                             "listeners": {
-                                                                "beforeload": "function (_self, options)\n{\n    if (!_this.grid || !_this.grid.selModel.getSelected()) {\n        return false;\n    }\n    var r = _this.grid.selModel.getSelected();\n    options.params.poitem_pohead_id = _this.grid.selModel.getSelected().data.pohead_id;\n    var rr = _this.rggrid.selModel.getSelected();\n\n    options.params.recvgrp_id = 0;\n    if (rr) {\n        options.params.recvgrp_id = rr.data.recvgrp_id;\n    }\n    \n    options.params._with_item  = 1;\n        options.params.item_type = 'P';\n}"
+                                                                "beforeload": "function (_self, options)\n{\n    if (!_this.grid || !_this.grid.selModel.getSelected()) {\n        return false;\n    }\n     \n    var r = _this.grid.selModel.getSelected();\n    \n    \n    \n    options.params.poitem_pohead_id = r.data.pohead_id;\n    \n    var rr = _this.rggrid.selModel.getSelected();\n\n    options.params.recvgrp_id = 0;\n    if (rr) {\n        options.params.recvgrp_id = rr.data.recvgrp_id;\n    }\n    \n    options.params._with_item  = 1;\n    options.params.item_type = 'P';\n}"
                                                             },
                                                             "*prop": "dataSource",
                                                             "remoteSort": true,