{ "id": "roo-file-73", "name": "Pman.Tab.XtupleTransfer", "parent": "Pman.Tab.XtupleSales", "title": "", "path": "/home/edward/gitlive/web.xtuple/Pman/Xtuple/Pman.Tab.XtupleTransfer.bjs", "items": [ { "listeners": { "|activate": "function() {\n _this.panel = this;\n if (_this.grid) {\n _this.grid.footer.onClick('first');\n }\n}" }, "background": true, "fitContainer": true, "fitToframe": true, "region": "center", "tableName": "invhist_transfer", "title": "Transfers", "xtype": "GridPanel", "|xns": "Roo", "items": [ { "listeners": { "|render": "function() \n{\n _this.grid = this; \n _this.dialog =Pman.Dialog.XtupleTransfer;\n if (_this.panel.active) {\n this.footer.onClick('first');\n }\n}", "|rowdblclick": "function (_self, rowIndex, e)\n{\n var sel = _this.postedCombo.getValue();\n \n var tdb = baseURL.split('/').pop().split('.').shift();\n \n \n if (sel.match(/^office-/)) {\n tdb = sel.split('-').pop();\n \n }\n \n \n if (!_this.dialog) return;\n \n var data = this.getDataSource().getAt(rowIndex).data;\n \n \n _this.dialog.show( {\n invhist_transfer_id : data.invhist_transfer_id,\n _roo_office : tdb\n }, function() {\n _this.grid.footer.onClick('first');\n }); \n}\n", "rowclass": "function (gridview, rowcfg)\n{\n if(rowcfg.record.data.invhist_transfer_void){\n rowcfg.rowClass = 'strikethrough';\n }\n}" }, "*prop": "grid", "autoExpandColumn": "invhist_transfer_descrip", "loadMask": true, "xtype": "Grid", "|xns": "Roo.grid", "items": [ { "listeners": { "beforeload": "function (_self, o)\n{\n var tdb = baseURL.split('/').pop().split('.').shift(); \n o.params._roo_office = tdb;\n o.params['query[location_id]'] = _this.locCombo.getValue();\n o.params['query[invhist_transfer_number]'] = _this.searchBox.getValue();\n var sel = _this.postedCombo.getValue();\n switch (sel) {\n case 'VOIDED': \n o.params.invhist_transfer_void = 1; \n break;\n case 'POSTED': \n o.params.invhist_transfer_posted = 1; \n break;\n case 'UNPOSTED': \n o.params.invhist_transfer_posted = 0; \n o.params.invhist_transfer_void = 0; \n break; \n case 'ALL': \n break;\n default: \n if (!sel.match(/^office-/)) {\n break;\n }\n delete o.params['query[location_id]'];\n \n o.params._roo_office= sel.replace(/^office-/,'');\n o.params.cust_to_internalcompany = tdb;\n break;\n }\n var dt = _this.dateSel.getValue();\n \n o.params['query[dateSel]'] = typeof(dt) == 'string' ? dt : dt.format('Y-m-d');\n \n\n \n \n}" }, "*prop": "dataSource", "remoteSort": true, "xtype": "Store", "|sortInfo": "{ field : 'invhist_transfer_transdate', direction: 'DESC' }", "|xns": "Roo.data", "items": [ { "*prop": "proxy", "method": "GET", "xtype": "HttpProxy", "|url": "baseURL + '/Xtuple/Roo/invhist_transfer.php'", "|xns": "Roo.data" }, { "|xns": "Roo.data", "xtype": "JsonReader", "totalProperty": "total", "root": "data", "*prop": "reader", "id": "id", "|fields": "[\n {\n 'name': 'invhist_transfer_id',\n 'type': 'int'\n },\n {\n 'name': 'invhist_transfer_transdate',\n 'type': 'date',\n 'dateFormat': 'Y-m-d'\n },\n {\n 'name': 'invhist_transfer_number',\n 'type': 'string'\n },\n {\n 'name': 'invhist_transfer_from',\n 'type': 'int'\n },\n {\n 'name': 'invhist_transfer_to',\n 'type': 'int'\n },\n {\n 'name': 'invhist_transfer_descrip',\n 'type': 'string'\n }\n]" } ] }, { "*prop": "footer", "xtype": "PagingToolbar", "pageSize": 25, "displayInfo": true, "displayMsg": "Displaying invhist_transfer{0} - {1} of {2}", "emptyMsg": "No invhist_transfer found", "|xns": "Roo", "items": [ { "listeners": { "click": "function (_self, e)\n{\n new Pman.Download({\n grid : _this.grid\n });\n Roo.MessageBox.alert(\"Downloading\", \"Report is downloading\");\n}" }, "text": "Download", "xtype": "Button", "|xns": "Roo.Toolbar" } ] }, { "*prop": "toolbar", "xtype": "Toolbar", "|xns": "Roo", "items": [ { "listeners": { "render": "function (_self)\n{\n _this.searchBox = _self;\n}", "specialkey": "function (_self, e)\n{\n _this.grid.footer.onClick('first');\n}" }, "xtype": "TextField", "|xns": "Roo.form" }, { "listeners": { "select": "function (combo, record, index)\n{\n _this.grid.footer.onClick('first');\n}", "render": "function (_self)\n{\n _this.locCombo = _self;\n}" }, "allowBlank": true, "displayField": "location_name", "editable": true, "emptyText": "Select location", "fieldLabel": "location", "forceSelection": true, "hiddenName": "location_id", "listWidth": 400, "loadingText": "Searching...", "minChars": 2, "name": "location_id", "pageSize": 200, "qtip": "Select location", "queryParam": "query[location_name]", "selectOnFocus": true, "tpl": "
{location_name} - {location_cust_id_char_internalcompany} {location_descrip}
", "triggerAction": "all", "typeAhead": true, "valueField": "location_id", "width": 250, "xtype": "ComboBox", "|xns": "Roo.form", "items": [ { "listeners": { "|beforeload": "function (_self, o){\n o.params = o.params || {};\n // set more here\n o.params.location_restrict = 0;\n \n}\n" }, "*prop": "store", "remoteSort": true, "xtype": "Store", "|sortInfo": "{ direction : 'ASC', field: 'location_name' }", "|xns": "Roo.data", "items": [ { "*prop": "proxy", "method": "GET", "xtype": "HttpProxy", "|url": "baseURL + '/Roo/location.php'", "|xns": "Roo.data" }, { "*prop": "reader", "xtype": "JsonReader", "|xns": "Roo.data", "id": "id", "root": "data", "totalProperty": "total", "|fields": "[{\"name\":\"id\",\"type\":\"int\"},{\"name\":\"location_name\",\"type\":\"string\"}]" } ] } ] }, { "listeners": { "|select": "function (combo, record, index)\n{\n _this.grid.footer.onClick('first');\n}", "|render": "function (_self)\n{\n _this.postedCombo = _self;\n}" }, "allowBlank": false, "displayField": "title", "editable": false, "emptyText": "Select Action", "forceSelection": true, "listWidth": 300, "loadingText": "Searching...", "minChars": 2, "name": "action", "pageSize": 20, "qtip": "Select Action", "selectOnFocus": true, "tpl": "
{title}
", "triggerAction": "all", "typeAhead": true, "value": "ALL", "valueField": "code", "width": 150, "xtype": "ComboBox", "|xns": "Roo.form", "items": [ { "*prop": "store", "isLocal": true, "xtype": "SimpleStore", "|data": "(function() { \n var ret = [\n [ 'ALL', 'All Transactions' ],\n [ 'UNPOSTED', 'Unposted' ],\n [ 'POSTED', 'Posted' ],\n [ 'VOIDED', 'Voided' ],\n [ '--', '-----------------' ] \n ];\n var c = baseURL.split('/').pop().split('.').shift(); \n Roo.each(uiConfig.xtuple_offices, function(o) {\n if (o == c) {\n return;\n }\n ret.push( [ 'office-' + o, \"Transfers from \" + Pman.Xtuple.offices[o] ] );\n\n });\n \n return ret;\n \n \n})()", "|fields": "[ 'code', 'title' ]", "|xns": "Roo.data" } ] }, { "listeners": { "render": "function (_self)\n{\n _this.dateSel = _self;\n}", "select": "function (combo, date)\n{\n _this.grid.footer.onClick('first');\n}" }, "allowBlank": true, "fieldLabel": "Date", "format": "Y-m-d", "width": 150, "xtype": "DateField", "|xns": "Roo.form" }, { "listeners": { "|click": "function (_self, e)\n{\n_this.grid.footer.onClick('first');\n}" }, "cls": "x-btn-icon", "xtype": "Button", "|icon": "rootURL + '/Pman/templates/images/search.gif'", "|xns": "Roo.Toolbar" }, { "listeners": { "|click": "function (_self, e)\n{\n _this.searchBox.setValue('');\n \n _this.locCombo.setValue(''); \n\n \n _this.grid.footer.onClick('first');\n}" }, "cls": "x-btn-icon", "xtype": "Button", "|icon": "rootURL + '/Pman/templates/images/edit-clear.gif'", "|xns": "Roo.Toolbar" }, { "|xns": "Roo.Toolbar", "xtype": "Fill" }, { "listeners": { "|click": "function()\n{\n \n var sel = _this.postedCombo.getValue();\n if (sel.match(/^office-/)) {\n Roo.Msg.alert('Error', \"You can create transfers for another office\");\n return;\n }\n \n var s = _this.grid.selModel.getSelected();\n if (!s) {\n Roo.MessageBox.alert(\"Error\", \"Select a row to copy\");\n return;\n }\n \n new Pman.Request({\n url : baseURL + '/Roo/invhist_transfer',\n method : 'POST',\n mask: 'Processing',\n timeout : 1200000, //20 minutes...! - big xfer should be 10mins.\n params : {\n invhist_transfer_id : s.data.invhist_transfer_id,\n _copy : 1\n },\n success : function () \n {\n _this.grid.footer.onClick('refresh');\n }\n });\n \n}\n" }, "cls": "x-btn-text-icon", "text": "Copy Transfer", "xtype": "Button", "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'", "|xns": "Roo.Toolbar" }, { "|xns": "Roo.Toolbar", "xtype": "Separator" }, { "listeners": { "|click": "function()\n{\n \n var sel = _this.postedCombo.getValue();\n if (sel.match(/^office-/)) {\n Roo.Msg.alert('Error', \"You can create transfers for another office\");\n return;\n }\n \n if (!_this.dialog) return;\n _this.dialog.show( { id : 0, _roo_office : baseURL.split('/').pop().split('.').shift() } , function() {\n _this.grid.footer.onClick('first');\n }); \n}\n" }, "cls": "x-btn-text-icon", "text": "Add", "xtype": "Button", "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'", "|xns": "Roo.Toolbar" }, { "|xns": "Roo.Toolbar", "xtype": "Separator" }, { "listeners": { "|click": "function()\n{\n \n var sel = _this.postedCombo.getValue();\n if (sel.match(/^office-/)) {\n Roo.Msg.alert('Error', 'You can not create reversals of transfer from another office');\n return;\n }\n \n \n var s = _this.grid.getSelectionModel().getSelected();\n if(!s){\n Roo.Msg.alert('Error', 'Please select a row!');\n return;\n }\n Roo.log(s);\n if(s.data.cust_to_internalcompany.length > 0){\n Roo.Msg.confirm(\"Comfirm\", \"Are you sure?
\" + \n \"This will create a transfer in the other company dragon, you will need to log to that company and post for it to happen.
\" +\n \"Otherwise, it just creates a transfer, and then opens the dialog to edit it.\", \n function(r) {\n if (r != 'yes') {\n return;\n }\n \n Roo.Msg.alert('Warnning', 'Sorry, it is comming soon !!');\n }\n );\n \n return;\n }\n \n \n Roo.Msg.confirm(\"Comfirm\", \"Are you sure?
\" + \n \"You can void a transfer, however if you need to reverse a transfer at a different date press 'yes', and a new transfer will be created.\", \n function(r) {\n if (r != 'yes') {\n return;\n }\n var data = {\n invhist_transfer_transdate : new Date(),\n invhist_transfer_arrivaldate : new Date(),\n invhist_transfer_to : s.data.invhist_transfer_from_location_id,\n invhist_transfer_to_location_descrip : s.data.invhist_transfer_from_location_descrip,\n invhist_transfer_from : s.data.invhist_transfer_to_location_id,\n invhist_transfer_from_location_descrip : s.data.invhist_transfer_to_location_descrip,\n invhist_transfer_price : s.data.invhist_transfer_price,\n invhist_transfer_descrip : s.data.invhist_transfer_descrip,\n _createReverse : s.data.invhist_transfer_id\n \n };\n _this.dialog.show( data, function() {\n _this.grid.footer.onClick('first');\n }); \n \n }\n );\n return;\n \n}\n" }, "cls": "x-btn-text-icon", "text": "Create Reverse Transfer", "xtype": "Button", "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'", "|xns": "Roo.Toolbar" }, { "|xns": "Roo.Toolbar", "xtype": "Separator" }, { "listeners": { "|click": "function()\n{\n var sel = _this.postedCombo.getValue();\n if (sel.match(/^office-/)) {\n Roo.Msg.alert('Error', \"You can not Post transfer from another office\");\n return;\n }\n var s = _this.grid.selModel.getSelected();\n if (!s) {\n Roo.MessageBox.alert(\"Error\", \"Select a row to post\");\n return;\n }\n \n if(s.data.invhist_transfer_void){\n Roo.MessageBox.alert(\"Error\", \"You can not post a voided transfer\");\n return;\n }\n \n var msg = \"Posting\";\n \n if (s.data.cust_from_internalcompany.length || s.data.cust_to_internalcompany.length) {\n msg += \" Cross company transfer - large orders may take some time, so do not cancel or reload\";\n }\n \n \n new Pman.Request({\n url : baseURL + '/Roo/invhist_transfer',\n method : 'POST',\n mask: msg,\n timeout : 1200000, //20 minutes...! - big xfer should be 10mins.\n params : {\n invhist_transfer_id : s.data.invhist_transfer_id,\n _post : 1\n },\n success : function () \n {\n _this.grid.footer.onClick('refresh');\n }\n });\n \n}\n " }, "cls": "x-btn-text-icon", "text": "Post", "xtype": "Button", "|icon": "rootURL + '/Pman/templates/images/mail-close.gif'", "|xns": "Roo.Toolbar" }, { "|xns": "Roo.Toolbar", "xtype": "Separator" }, { "listeners": { "|click": "function()\n{\n var sel = _this.postedCombo.getValue();\n if (sel.match(/^office-/)) {\n Roo.Msg.alert('Error', \"You can not Post transfer from coid office\");\n return;\n }\n \n var s = _this.grid.selModel.getSelected();\n if (!s) {\n Roo.MessageBox.alert(\"Error\", \"Select a row to void\");\n return;\n }\n \n var voidposted = function(){\n new Pman.Request({\n url : baseURL + '/Roo/invhist_transfer',\n method : 'POST',\n mask : \"Voiding\",\n timeout : 90000,\n params : {\n invhist_transfer_id : s.data.invhist_transfer_id,\n _void : 1\n },\n success : function () \n {\n _this.grid.footer.onClick('refresh');\n }\n });\n }\n \n var voidunposted = function(){\n new Pman.Request({\n url : baseURL + '/Roo/invhist_transfer',\n method : 'POST',\n mask : \"Voiding\",\n params : {\n invhist_transfer_id : s.data.invhist_transfer_id,\n invhist_transfer_void : 1\n },\n success : function () \n {\n _this.grid.footer.onClick('refresh');\n }\n });\n }\n \n \n var posted = s.data.invhist_transfer_posted;\n \n Roo.MessageBox.confirm(\"Confirm\", \"Are you sure you want to void that\", \n function(r) {\n if (r != 'yes') {\n return;\n }\n if(posted){\n voidposted();\n return;\n } \n voidunposted();\n }\n )\n \n}\n " }, "cls": "x-btn-text-icon", "text": "Void", "xtype": "Button", "|icon": "rootURL + '/Pman/templates/images/trash.gif'", "|xns": "Roo.Toolbar" } ] }, { "*prop": "colModel[]", "dataIndex": "invhist_transfer_posted", "header": "Posted", "width": 75, "xtype": "ColumnModel", "|renderer": "function(v) { \n var state = v * 1 > 0 ? '-checked' : '';\n\n return '';\n \n }", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "dataIndex": "invhist_transfer_transdate", "header": "Date", "sortable": true, "width": 75, "xtype": "ColumnModel", "|renderer": "function(v) { \n\n return String.format('{0}', v ? Date.parseDate(v.split(' ').shift(),'Y-m-d').format('d/M/Y') : '');\n }", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "dataIndex": "invhist_transfer_arrivaldate", "header": "Arrival", "sortable": true, "width": 75, "xtype": "ColumnModel", "|renderer": "function(v) { \n\n return String.format('{0}', v ? Date.parseDate(v.split(' ').shift(),'Y-m-d').format('d/M/Y') : '');\n }", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "dataIndex": "invhist_transfer_number", "header": "reference#", "sortable": true, "width": 100, "xtype": "ColumnModel", "|renderer": "function(v,x,r) { \n\n var sel = _this.postedCombo.getValue();\n var p = baseURL.split('/').pop().split('.').shift().toUpperCase();;\n if (sel.match(/^office-/)) {\n p = sel.split('-').pop().toUpperCase();\n }\n \n return String.format(r.data.invhist_transfer_void ? '{0}' : '{0}', p+':'+v); \n \n}", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "dataIndex": "invhist_transfer_from_location_name", "header": "From", "sortable": true, "width": 150, "xtype": "ColumnModel", "|renderer": "function(v,x,r) { \n\n var lv = _this.locCombo.getValue();\n var fmt = lv == r.data.invhist_transfer_from ? '{0}' : '{0}';\n if (r.data.cust_from_internalcompany.length) {\n fmt = '[Intercompany {1}] ' + fmt + '';\n }\n \n return String.format(fmt, v,r.data.cust_from_internalcompany ); \n}", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "dataIndex": "invhist_transfer_to_location_name", "header": "To", "sortable": true, "width": 150, "xtype": "ColumnModel", "|renderer": "function(v,x,r) { \n\n var lv = _this.locCombo.getValue();\n var fmt = lv == r.data.invhist_transfer_to ? '{0}' : '{0}';\n if (r.data.cust_to_internalcompany.length) {\n fmt = '[Intercompany {1}] ' + fmt + '';\n }\n \n return String.format(fmt, v, r.data.cust_to_internalcompany); \n}", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "dataIndex": "qty", "header": "Quantity Moved", "width": 100, "xtype": "ColumnModel", "|renderer": "function(v,x,r) \n{\n if(\n r.data.cust_to_internalcompany.length \n || \n (r.data.invhist_transfer_void && r.data.moved_qty == 0)\n ||\n (!r.data.invhist_transfer_void && !r.data.invhist_transfer_posted)\n ){\n return String.format('{0}', v); \n }\n \n var diff = v * 1 - r.data.moved_qty * 1;\n var flag = ''\n \n if(diff != 0){\n flag = ' ({1}) '\n }\n\n return String.format('{0}' + flag, v, r.data.moved_qty); \n\n \n}", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "dataIndex": "invhist_transfer_salesrep_id_salesrep_name", "header": "Sales Rep", "width": 100, "xtype": "ColumnModel", "|renderer": "function(v) { return String.format('{0}', v); }", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "dataIndex": "invhist_transfer_descrip", "header": "Notes", "width": 200, "xtype": "ColumnModel", "|renderer": "function(v) { return String.format('{0}', v); }", "|xns": "Roo.grid" } ] } ] } ], "permname": "", "modOrder": "700" }