{ "name" : "Pman.Tab.XtupleStock", "parent" : "Pman.Tab.XtupleManage", "title" : "Pman.Tab.XtupleStock", "path" : "/home/alan/gitlive/Pman.Xtuple/Pman.Tab.XtupleStock.bjs", "permname" : "", "modOrder" : "001", "items" : [ { "listeners" : { "render" : "function (_self)\n{\n _this.toppanel = _self;\n}" }, "background" : true, "region" : "center", "title" : "Locations /Stock ", "xtype" : "NestedLayoutPanel", "$ xns" : "Roo", "items" : [ { "xtype" : "BorderLayout", "$ xns" : "Roo", "* prop" : "layout", "items" : [ { "xtype" : "LayoutRegion", "$ xns" : "Roo", "* prop" : "center" }, { "title" : "Stock", "xtype" : "LayoutRegion", "width" : 250, "$ xns" : "Roo", "split" : true, "* prop" : "east" }, { "listeners" : { "|activate" : "function() {\n _this.panel = this;\n if (_this.grid) {\n _this.grid.footer.onClick('first');\n }\n}" }, "fitToframe" : true, "background" : true, "region" : "center", "title" : "location", "xtype" : "GridPanel", "fitContainer" : true, "$ xns" : "Roo", "tableName" : "location", "items" : [ { "listeners" : { "|rowdblclick" : "function (_self, rowIndex, e)\n{\n \n Pman.Dialog.XtupleLocation.show( this.getDataSource().getAt(rowIndex).data, function() {\n _this.grid.footer.onClick('first');\n }); \n}\n", "cellclick" : "function (_self, rowIndex, col, e)\n{\n \n var ix = this.colModel.getDataIndex(col);\n var rec = _this.grid.ds.getAt(rowIndex);\n \n \n \n if (ix == 'location_restrict') {\n \n var nv = rec.data.location_restrict ? 0 : 1;\n new Pman.Request({\n mask : 'Saving',\n url : baseURL + '/Roo/Location',\n params : {\n location_id : rec.data.location_id,\n location_restrict : nv\n },\n success : function() {\n rec.set('location_restrict', nv);\n }\n });\n return;\n \n \n }\n \n \n \n \n _this.itemgrid.viewtype = 1;\n \n \n if ('location_qty_neg' == ix || 'location_netsuite_stock_neg' == ix ) {\n _this.itemgrid.viewtype = -1;\n }\n if ('location_netsuite_stock' == ix || 'location_netsuite_stock_neg' == ix ) {\n _this.itemgrid.viewtype *= 2;\n }\n \n (function() { _this.itemgrid.footer.onClick('first'); }).defer(100);\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n}", "|render" : "function() \n{\n _this.grid = this; \n //_this.dialog = Pman.Dialog.FILL_IN\n if (_this.panel.active) {\n this.footer.onClick('first');\n }\n}" }, "autoExpandColumn" : "location_name", "xtype" : "Grid", "loadMask" : true, "$ xns" : "Roo.grid", "* prop" : "grid", "items" : [ { "listeners" : { "selectionchange" : "function (_self)\n{\n \n // _this.toppanel.layout.getRegion('east').expand();\n}" }, "xtype" : "RowSelectionModel", "$ xns" : "Roo.grid", "* prop" : "sm" }, { "listeners" : { "beforeload" : "function (_self, o)\n{\n \n o.params._as_of = _this.dateTo.getValue();\n\n if (!o.params._as_of.length) {\n return false;\n }\n o.params._with_stock_and_value = 1;\n \n o.params._viewType = _this.viewType.getValue();\n}", "load" : "function (_self, records, options)\n{\n // build index.\n \n var dt = Date.parseDate(_this.dateTo.getValue(), 'Y-m-d');\n var maxd = Date.parseDate('2012-11-01', 'Y-m-d');\n \n if (!records.length) {\n return;\n }\n \n var map = {};\n \n Roo.each(records, function(r) {\n map[r.data.location_id] = r;\n r.set('location_qty',undefined);\n r.set('location_qty_neg', undefined);\n r.set('location_value', undefined);\n \n });\n var pqty = 0;\n var nqty = 0;\n var tval = 0.0;\n var overlaydata = function (type, data) {\n Roo.each(data, function(r) {\n var rec= map[r.location_id];\n \n //switch(type) { \n //case 'netsuite':\n rec.set('location_netsuite_stock', r.location_netsuite_stock);\n rec.set('location_netsuite_stock_neg', r.location_netsuite_stock_neg); \n // break;\n // case 'dragon':\n rec.set('location_qty', r.location_qty);\n pqty += r.location_qty *1; \n rec.set('location_qty_neg', r.location_qty_neg);\n nqty += r.location_qty_neg *1;\n rec.set('location_value', r.location_value);\n tval += r.location_value * 1.0;\n // break;\n \n \n //}\n })\n \n \n \n };\n \n var i = 0; \n \n var loadoverlay = function(type) {\n \n \n new Pman.Request({\n method : 'GET',\n //mask : 'Loading ' + type + ' stock levels (takes around 30s)',\n timeout: 60000,\n url : baseURL + '/Roo/Location',\n params : {\n _as_of : _this.dateTo.getValue(),\n _with_stock_and_value : 'both',\n location_id : records[i++].data.location_id \n },\n success : function( res ) {\n \n overlaydata(type, res.data);\n \n if (i >= records.length) {\n _this.grid.footer.displayEl.update(String.format(\"Total: pos={0} neg={1} eq={2} val={3}\", \n Roo.util.Format.number(pqty,0), \n Roo.util.Format.number(nqty,0), \n Roo.util.Format.number(pqty+nqty,0), \n Roo.util.Format.number(tval,0)\n ));\n return;\n } \n loadoverlay(type);\n //if (type == 'dragon' && dt < maxd ) {\n // loadoverlay('netsuite');\n // } else {\n //\n // }\n \n \n },\n failure : function( ) {\n Roo.MessageBox.alert('Error' , 'Loading data failed, try again');\n }\n });\n \n };\n \n loadoverlay('dragon');\n \n \n}" }, "xtype" : "Store", "remoteSort" : true, "$ sortInfo" : "{ field : 'location_name', direction: 'ASC' }", "$ xns" : "Roo.data", "* prop" : "dataSource", "items" : [ { "$ url" : "baseURL + '/Roo/location.php'", "xtype" : "HttpProxy", "method" : "GET", "$ xns" : "Roo.data", "* prop" : "proxy" }, { "id" : "id", "root" : "data", "xtype" : "JsonReader", "$ xns" : "Roo.data", "$ fields" : "[\n {\n 'name': 'location_id',\n 'type': 'int'\n },\n {\n 'name': 'location_warehous_id',\n 'type': 'int'\n },\n {\n 'name': 'location_name',\n 'type': 'string'\n },\n {\n 'name': 'location_descrip',\n 'type': 'string'\n },\n {\n 'name': 'location_restrict',\n 'type': 'int'\n },\n {\n 'name': 'location_netable',\n 'type': 'int'\n },\n {\n 'name': 'location_whsezone_id',\n 'type': 'int'\n },\n {\n 'name': 'location_aisle',\n 'type': 'string'\n },\n {\n 'name': 'location_rack',\n 'type': 'string'\n },\n {\n 'name': 'location_bin',\n 'type': 'string'\n }\n]", "* prop" : "reader", "totalProperty" : "total" } ] }, { "pageSize" : 999, "xtype" : "PagingToolbar", "emptyMsg" : "No location found", "$ xns" : "Roo", "displayMsg" : "Displaying location{0} - {1} of {2}", "displayInfo" : true, "* prop" : "footer", "items" : [ { "listeners" : { "click" : "function (_self, e)\n{\n Roo.MessageBox.progress (\"Syncing Balances\", \"Sending\");\n \n var offset = 0;\n \n function runSync() {\n \n new Pman.Request( {\n url : baseURL+'/Roo/Locbal',\n method : 'GET',\n params : {\n _sync : 1,\n offset : offset\n },\n success : function(res) {\n // Roo.log(res);\n if (!res.data.total) {\n Roo.MessageBox.hide();\n return;\n }\n offset += res.data.limit;\n Roo.MessageBox.updateProgress ( offset / res.data.total, \"Done \" + offset + '/' + res.data.total);\n runSync();\n }\n \n });\n }\n runSync();\n}" }, "text" : "Sync Stock Balances", "hidden" : true, "xtype" : "Button", "$ xns" : "Roo.Toolbar" }, { "listeners" : { "click" : "function (_self, e)\n{\n Pman.Dialog.Image.show(\n {\n _url : baseURL+'/Xtuple/Import/Products'\n \n },\n function (data) {\n var msg = [];\n \n if (data.updated) {\n msg.push(\"Updated \" + data.updated + \" Products(s)\");\n } \n if (data.inserted) {\n msg.push(\"Added \" + data.inserted + \" Products(s)\");\n }\n if (data.skipped) {\n msg.push(\"Skipped \" + data.skipped);\n }\n \n if (!msg.length) {\n msg.push(\"No data changed\");\n }\n Roo.MessageBox.alert(\"Notice\", msg.join(\"\\n\"));\n\n }\n );\n}" }, "text" : "Upload new products and costs", "hidden" : true, "xtype" : "Button", "$ xns" : "Roo.Toolbar", "items" : [ { "xtype" : "Menu", "$ xns" : "Roo.menu", "* prop" : "menu", "items" : [ { "listeners" : { "click" : "function (_self, e)\n{\n var l = _this.grid.selModel ? _this.grid.selModel.getSelected() : false;\n if (!l) {\n Roo.MessageBox.alert(\"Error\", \"Select location\");\n return;\n }\n \n Pman.Dialog.XtupleTransfer.show({\n id : 0,\n _ns_autofill : 1,\n invhist_transfer_to : l.data.location_id,\n invhist_transfer_to_location_descrip : l.data.location_descrip,\n \n invhist_transfer_transdate : _this.dateTo.getValue(),\n invhist_transfer_arrivaldate : _this.dateTo.getValue()\n \n \n }, function() { _this.grid.ds.load({}); }\n );\n \n \n}" }, "text" : "Transfer to Fix +ve number", "xtype" : "Item", "$ xns" : "Roo.menu" }, { "listeners" : { "click" : "function (_self, e)\n{\n var l = _this.grid.selModel ? _this.grid.selModel.getSelected() : false;\n if (!l) {\n Roo.MessageBox.alert(\"Error\", \"Select location\");\n return;\n }\n \n Pman.Dialog.XtupleTransfer.show({\n id : 0,\n _ns_autofill : -1,\n invhist_transfer_from : l.data.location_id,\n invhist_transfer_from_location_descrip : l.data.location_descrip,\n \n invhist_transfer_transdate : _this.dateTo.getValue(),\n invhist_transfer_arrivaldate : _this.dateTo.getValue()\n \n \n }, function() { _this.grid.ds.load({}); }\n );\n \n \n}\n " }, "text" : "Transfer to Fix -ve number", "xtype" : "Item", "$ xns" : "Roo.menu" } ] } ] } ] }, { "xtype" : "Toolbar", "$ xns" : "Roo", "* prop" : "toolbar", "items" : [ { "text" : "As of:", "xtype" : "TextItem", "$ xns" : "Roo.Toolbar" }, { "listeners" : { "render" : "function (_self)\n{\n _this.dateTo = _self;\n}", "select" : "function (combo, date)\n{\n _this.grid.footer.onClick('first');\n}" }, "format" : "d/M/Y", "useIso" : 1, "xtype" : "DateField", "width" : 120, "$ xns" : "Roo.form" }, { "listeners" : { "render" : "function (_self)\n{\n _this.viewType = _self;\n}", "select" : "function (combo, record, index)\n{\n _this.grid.footer.onClick('first');\n}" }, "listWidth" : 200, "triggerAction" : "all", "fieldLabel" : "Status", "displayField" : "fname", "hiddenName" : "loctype", "value" : "local", "valueField" : "ftype", "xtype" : "ComboBox", "allowBlank" : false, "editable" : false, "width" : 100, "$ xns" : "Roo.form", "mode" : "local", "name" : "loctype_name", "items" : [ { "xtype" : "SimpleStore", "$ data" : "[ ['local', \"Local\"],[ 'remote' , \"Remote\"],[ 'disabled', \"Disabled\"] ]\n", "$ fields" : "[ 'ftype', 'fname']", "$ xns" : "Roo.data", "* prop" : "store" } ] }, { "xtype" : "Fill", "$ xns" : "Roo.Toolbar" }, { "listeners" : { "|click" : "function()\n{\n // work out last \n Pman.Dialog.XtupleLocation.show( { }, function() {\n _this.grid.footer.onClick('first');\n }); \n}\n", "render" : "function (_self)\n{\n _this.addItemBtn = _self;\n}" }, "text" : "Add", "xtype" : "Button", "cls" : "x-btn-text-icon", "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'", "$ xns" : "Roo.Toolbar" }, { "text" : "Download Reports", "xtype" : "Button", "$ xns" : "Roo.Toolbar", "items" : [ { "xtype" : "Menu", "$ xns" : "Roo.menu", "* prop" : "menu", "items" : [ { "listeners" : { "click" : "function (_self, e)\n{\n\n var ret= [];\n var hr = [];\n var cols = [];\n Roo.each( _this.grid.colModel.config, function(h) {\n hr.push(h.header);\n cols.push(h.dataIndex);\n });\n ret.push(hr);\n _this.grid.ds.each(function(rec) {\n hr = [];\n for(var i =0;i 0 ? '' : '-checked' ;\n\n return '';\n \n }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "location_restrict" }, { "xtype" : "ColumnModel", "header" : "Name", "width" : 200, "$ renderer" : "function(v) { return String.format('{0}', v); }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "location_name" }, { "xtype" : "ColumnModel", "header" : "Description", "width" : 200, "$ renderer" : "function(v) { return String.format('{0}', v); }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "location_descrip" }, { "xtype" : "ColumnModel", "header" : "Customer", "width" : 200, "$ renderer" : "function(v,x,r) { \n\n if (!r.data.location_cust_id_char_internalcompany.length) {\n return String.format('{0}', v); \n }\n return String.format('[Internal Company : {0}] {1} ', \n r.data.location_cust_id_char_internalcompany, v); \n \n}\n", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "location_cust_id_cust_name" }, { "align" : "right", "xtype" : "ColumnModel", "header" : "Qty", "width" : 75, "$ renderer" : "function(v,x,r) { return typeof(v) == 'undefined' ? '...' : String.format('{0} ', (v*1).toFixed(0) ); }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "location_qty" }, { "align" : "right", "xtype" : "ColumnModel", "header" : "Missing TX", "width" : 75, "$ renderer" : "function(v,x,r) { \n if ( typeof(v) == 'undefined') {\n return '';\n }\n if (v == 0) {\n return '';\n }\n \n return String.format('{0}', (v*1).toFixed(0) ); \n}", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "location_qty_neg" }, { "align" : "right", "xtype" : "ColumnModel", "header" : "Est. Net Qty", "width" : 75, "$ renderer" : "function(v,x,r) { \n \n return typeof(v) == 'undefined' ? '...' : \n String.format('{0}', ((v*1) + (r.data.location_qty_neg*1)).toFixed(0) ); \n}", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "location_qty" }, { "align" : "right", "hidden" : true, "xtype" : "ColumnModel", "header" : "NS Qty", "width" : 75, "$ renderer" : "function(v,x,r) {\n var f= '{0}';\n if ((r.data.location_qty) *1 != (v*1)) {\n f = '{0}';\n }\n return typeof(v) == 'undefined' ? '...' : String.format(f, (v*1).toFixed(0) );\n \n }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "location_netsuite_stock" }, { "align" : "right", "hidden" : true, "xtype" : "ColumnModel", "header" : "NS -ve Qty", "width" : 75, "$ renderer" : "function(v,x,r) { \n var f= '{0}';\n if ((r.data.location_qty_neg) *1 != (v*1)) {\n f = '{0}';\n }\n return typeof(v) == 'undefined' ? '...' : String.format(f, (v*1).toFixed(0) ); \n }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "location_netsuite_stock_neg" }, { "align" : "right", "xtype" : "ColumnModel", "header" : "Value", "width" : 200, "$ renderer" : "function(v) { return typeof(v) == 'undefined' ? '...' : Roo.util.Format.usMoney( v); }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "location_value" } ] } ] }, { "listeners" : { "|activate" : "function() {\n _this.itempanel = this;\n if (_this.itemgrid) {\n // _this.itemgrid.footer.onClick('first');\n }\n}" }, "fitToframe" : true, "background" : true, "region" : "east", "title" : "itemloc", "xtype" : "GridPanel", "fitContainer" : true, "$ xns" : "Roo", "tableName" : "itemloc", "items" : [ { "listeners" : { "|rowdblclick" : "function (_self, rowIndex, e)\n{ \n var rec =this.getDataSource().getAt(rowIndex);\n\n var loc = _this.grid.selModel.getSelected();\n \n var dt = _this.dateTo.getValue();\n \n Pman.Dialog.XtupleInvHistory.show({\n itemsite_item_id_item_number : rec.data.itemsite_item_id_item_number,\n \n location_name : loc.data.location_name,\n location_descrip : loc.data.location_descrip,\n \n invhist_transdate : typeof(dt) == 'string' ? dt : dt.format('Y-m-d')\n }); \n \n \n\n}\n", "cellclick" : "function (_self, row, col, e)\n{\n\n if ('netsuite_qty' == this.colModel.getDataIndex(col)) {\n var d = this.ds.getAt(row); \n var loc = _this.grid.selModel.getSelected();\n \n new Pman.Download({\n url: baseURL + '/Xtuple/NetsuiteFix/StockCheck',\n params : {\n item_id : d.data.itemsite_item_id,\n location_id : loc.data.location_id\n }\n \n \n });\n }\n}", "|render" : "function() \n{\n _this.itemgrid = this; \n //_this.dialog = Pman.Dialog.FILL_IN\n if (_this.itempanel.active) {\n // this.footer.onClick('first');\n }\n}" }, "autoExpandColumn" : "itemsite_item_id_item_number", "xtype" : "Grid", "loadMask" : true, "$ xns" : "Roo.grid", "* prop" : "grid", "items" : [ { "listeners" : { "beforeload" : "function (_self, o)\n{\n var l = _this.grid.selModel ? _this.grid.selModel.getSelected() : false;\n if (!l) {\n return false;\n }\n o.params.location_id = l.data.location_id;\n o.params._as_of = _this.dateTo.getValue();\n o.params._with_stock_and_value = 1;\n o.params._viewtype = _this.itemgrid.viewtype;\n}" }, "xtype" : "Store", "remoteSort" : true, "$ sortInfo" : "{ field : 'itemsite_item_id_item_number', direction: 'ASC' }", "$ xns" : "Roo.data", "* prop" : "dataSource", "items" : [ { "$ url" : "baseURL + '/Roo/itemsite.php'", "method" : "GET", "xtype" : "HttpProxy", "timeout" : 120000, "$ xns" : "Roo.data", "* prop" : "proxy" }, { "id" : "id", "root" : "data", "xtype" : "JsonReader", "$ xns" : "Roo.data", "$ fields" : "[\n {\n 'name': 'itemloc_id',\n 'type': 'int'\n },\n {\n 'name': 'itemloc_itemsite_id',\n 'type': 'int'\n },\n {\n 'name': 'itemloc_location_id',\n 'type': 'int'\n },\n {\n 'name': 'itemloc_qty',\n 'type': 'float'\n },\n {\n 'name': 'itemloc_expiration',\n 'type': 'date',\n 'dateFormat': 'Y-m-d'\n },\n {\n 'name': 'itemloc_consolflag',\n 'type': 'int'\n },\n {\n 'name': 'itemloc_ls_id',\n 'type': 'int'\n },\n {\n 'name': 'itemloc_warrpurc',\n 'type': 'date',\n 'dateFormat': 'Y-m-d'\n }\n]", "* prop" : "reader", "totalProperty" : "total" } ] }, { "pageSize" : 25, "xtype" : "PagingToolbar", "emptyMsg" : "No itemloc found", "$ xns" : "Roo", "displayMsg" : "{0} - {1} of {2}", "displayInfo" : true, "* prop" : "footer" }, { "xtype" : "ColumnModel", "header" : "Item", "width" : 75, "$ renderer" : "function(v) { return String.format('{0}', v); }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "itemsite_item_id_item_number" }, { "align" : "right", "xtype" : "ColumnModel", "header" : "Qty", "width" : 55, "$ renderer" : "function(v) { return String.format('{0}', (v*1).toFixed(0)); }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "itemsite_qty" }, { "align" : "right", "hidden" : true, "xtype" : "ColumnModel", "header" : "NS Qty", "width" : 50, "$ renderer" : "function(v,x,r) { \n var f= '{0}';\n if ((r.data.itemsite_qty) *1 != (v*1)) {\n f = '{0}';\n }\n return String.format(f, (v*1).toFixed(0) ); \n}", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "netsuite_qty" }, { "align" : "right", "xtype" : "ColumnModel", "header" : "Value", "width" : 75, "$ renderer" : "function(v) { return Roo.util.Format.usMoney(v); }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "itemsite_value" } ] } ] } ] } ] } ] }