Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Tab.XtupleStock.bjs
1 {
2     "name" : "Pman.Tab.XtupleStock",
3     "parent" : "Pman.Tab.XtupleManage",
4     "title" : "Pman.Tab.XtupleStock",
5     "path" : "/home/alan/gitlive/Pman.Xtuple/Pman.Tab.XtupleStock.bjs",
6     "permname" : "",
7     "modOrder" : "001",
8     "items" : [
9         {
10             "listeners" : {
11                 "render" : "function (_self)\n{\n _this.toppanel = _self;\n}"
12             },
13             "background" : true,
14             "region" : "center",
15             "title" : "Locations /Stock ",
16             "xtype" : "NestedLayoutPanel",
17             "$ xns" : "Roo",
18             "items" : [
19                 {
20                     "xtype" : "BorderLayout",
21                     "$ xns" : "Roo",
22                     "* prop" : "layout",
23                     "items" : [
24                         {
25                             "xtype" : "LayoutRegion",
26                             "$ xns" : "Roo",
27                             "* prop" : "center"
28                         },
29                         {
30                             "title" : "Stock",
31                             "xtype" : "LayoutRegion",
32                             "width" : 250,
33                             "$ xns" : "Roo",
34                             "split" : true,
35                             "* prop" : "east"
36                         },
37                         {
38                             "listeners" : {
39                                 "|activate" : "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
40                             },
41                             "fitToframe" : true,
42                             "background" : true,
43                             "region" : "center",
44                             "title" : "location",
45                             "xtype" : "GridPanel",
46                             "fitContainer" : true,
47                             "$ xns" : "Roo",
48                             "tableName" : "location",
49                             "items" : [
50                                 {
51                                     "listeners" : {
52                                         "|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",
53                                         "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}",
54                                         "|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}"
55                                     },
56                                     "autoExpandColumn" : "location_name",
57                                     "xtype" : "Grid",
58                                     "loadMask" : true,
59                                     "$ xns" : "Roo.grid",
60                                     "* prop" : "grid",
61                                     "items" : [
62                                         {
63                                             "listeners" : {
64                                                 "selectionchange" : "function (_self)\n{\n   \n   // _this.toppanel.layout.getRegion('east').expand();\n}"
65                                             },
66                                             "xtype" : "RowSelectionModel",
67                                             "$ xns" : "Roo.grid",
68                                             "* prop" : "sm"
69                                         },
70                                         {
71                                             "listeners" : {
72                                                 "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}",
73                                                 "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}"
74                                             },
75                                             "xtype" : "Store",
76                                             "remoteSort" : true,
77                                             "$ sortInfo" : "{ field : 'location_name', direction: 'ASC' }",
78                                             "$ xns" : "Roo.data",
79                                             "* prop" : "dataSource",
80                                             "items" : [
81                                                 {
82                                                     "$ url" : "baseURL + '/Roo/location.php'",
83                                                     "xtype" : "HttpProxy",
84                                                     "method" : "GET",
85                                                     "$ xns" : "Roo.data",
86                                                     "* prop" : "proxy"
87                                                 },
88                                                 {
89                                                     "id" : "id",
90                                                     "root" : "data",
91                                                     "xtype" : "JsonReader",
92                                                     "$ xns" : "Roo.data",
93                                                     "$ 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]",
94                                                     "* prop" : "reader",
95                                                     "totalProperty" : "total"
96                                                 }
97                                             ]
98                                         },
99                                         {
100                                             "pageSize" : 999,
101                                             "xtype" : "PagingToolbar",
102                                             "emptyMsg" : "No location found",
103                                             "$ xns" : "Roo",
104                                             "displayMsg" : "Displaying location{0} - {1} of {2}",
105                                             "displayInfo" : true,
106                                             "* prop" : "footer",
107                                             "items" : [
108                                                 {
109                                                     "listeners" : {
110                                                         "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}"
111                                                     },
112                                                     "text" : "Sync Stock Balances",
113                                                     "hidden" : true,
114                                                     "xtype" : "Button",
115                                                     "$ xns" : "Roo.Toolbar"
116                                                 },
117                                                 {
118                                                     "listeners" : {
119                                                         "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}"
120                                                     },
121                                                     "text" : "Upload new products and costs",
122                                                     "hidden" : true,
123                                                     "xtype" : "Button",
124                                                     "$ xns" : "Roo.Toolbar",
125                                                     "items" : [
126                                                         {
127                                                             "xtype" : "Menu",
128                                                             "$ xns" : "Roo.menu",
129                                                             "* prop" : "menu",
130                                                             "items" : [
131                                                                 {
132                                                                     "listeners" : {
133                                                                         "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}"
134                                                                     },
135                                                                     "text" : "Transfer to Fix +ve number",
136                                                                     "xtype" : "Item",
137                                                                     "$ xns" : "Roo.menu"
138                                                                 },
139                                                                 {
140                                                                     "listeners" : {
141                                                                         "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 "
142                                                                     },
143                                                                     "text" : "Transfer to Fix -ve number",
144                                                                     "xtype" : "Item",
145                                                                     "$ xns" : "Roo.menu"
146                                                                 }
147                                                             ]
148                                                         }
149                                                     ]
150                                                 }
151                                             ]
152                                         },
153                                         {
154                                             "xtype" : "Toolbar",
155                                             "$ xns" : "Roo",
156                                             "* prop" : "toolbar",
157                                             "items" : [
158                                                 {
159                                                     "text" : "As of:",
160                                                     "xtype" : "TextItem",
161                                                     "$ xns" : "Roo.Toolbar"
162                                                 },
163                                                 {
164                                                     "listeners" : {
165                                                         "render" : "function (_self)\n{\n    _this.dateTo = _self;\n}",
166                                                         "select" : "function (combo, date)\n{\n  _this.grid.footer.onClick('first');\n}"
167                                                     },
168                                                     "format" : "d/M/Y",
169                                                     "useIso" : 1,
170                                                     "xtype" : "DateField",
171                                                     "width" : 120,
172                                                     "$ xns" : "Roo.form"
173                                                 },
174                                                 {
175                                                     "listeners" : {
176                                                         "render" : "function (_self)\n{\n    _this.viewType = _self;\n}",
177                                                         "select" : "function (combo, record, index)\n{\n    _this.grid.footer.onClick('first');\n}"
178                                                     },
179                                                     "listWidth" : 200,
180                                                     "triggerAction" : "all",
181                                                     "fieldLabel" : "Status",
182                                                     "displayField" : "fname",
183                                                     "hiddenName" : "loctype",
184                                                     "value" : "local",
185                                                     "valueField" : "ftype",
186                                                     "xtype" : "ComboBox",
187                                                     "allowBlank" : false,
188                                                     "editable" : false,
189                                                     "width" : 100,
190                                                     "$ xns" : "Roo.form",
191                                                     "mode" : "local",
192                                                     "name" : "loctype_name",
193                                                     "items" : [
194                                                         {
195                                                             "xtype" : "SimpleStore",
196                                                             "$ data" : "[ ['local', \"Local\"],[ 'remote' , \"Remote\"],[ 'disabled', \"Disabled\"] ]\n",
197                                                             "$ fields" : "[  'ftype', 'fname']",
198                                                             "$ xns" : "Roo.data",
199                                                             "* prop" : "store"
200                                                         }
201                                                     ]
202                                                 },
203                                                 {
204                                                     "xtype" : "Fill",
205                                                     "$ xns" : "Roo.Toolbar"
206                                                 },
207                                                 {
208                                                     "listeners" : {
209                                                         "|click" : "function()\n{\n    // work out last \n    Pman.Dialog.XtupleLocation.show( { }, function() {\n        _this.grid.footer.onClick('first');\n    }); \n}\n",
210                                                         "render" : "function (_self)\n{\n    _this.addItemBtn = _self;\n}"
211                                                     },
212                                                     "text" : "Add",
213                                                     "xtype" : "Button",
214                                                     "cls" : "x-btn-text-icon",
215                                                     "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
216                                                     "$ xns" : "Roo.Toolbar"
217                                                 },
218                                                 {
219                                                     "text" : "Download Reports",
220                                                     "xtype" : "Button",
221                                                     "$ xns" : "Roo.Toolbar",
222                                                     "items" : [
223                                                         {
224                                                             "xtype" : "Menu",
225                                                             "$ xns" : "Roo.menu",
226                                                             "* prop" : "menu",
227                                                             "items" : [
228                                                                 {
229                                                                     "listeners" : {
230                                                                         "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<cols.length;i++) {\n            hr.push(rec.get(cols[i]));\n        }\n        ret.push(hr);\n    });\n   \n       new Pman.Download({\n            url : baseURL + '/Core/JsonToExcel',\n            method : 'POST',\n            params : {\n                _json : Roo.encode(ret) \n            }\n        });\n     \n}"
231                                                                     },
232                                                                     "text" : "Summary of Stock in all Locatoins",
233                                                                     "xtype" : "Item",
234                                                                     "$ xns" : "Roo.menu"
235                                                                 },
236                                                                 {
237                                                                     "xtype" : "Separator",
238                                                                     "$ xns" : "Roo.menu"
239                                                                 },
240                                                                 {
241                                                                     "listeners" : {
242                                                                         "click" : "function (_self, e)\n{\n \n    \n\n       new Pman.Download({\n            url : baseURL + '/Roo/Invdetail',\n            method : 'GET',\n            timeout: 60000,\n            params : {\n                _summary_at_date : _this.dateTo.getValue(),\n                'csvCols[0]' : 'location_name',               \n                'csvCols[1]' :  'item_number',\n                'csvCols[2]' :  'item_descrip1',                \n                'csvCols[3]' : 'stock_qty',\n                'csvCols[4]' : 'stdcost_value',\n                'csvCols[5]' : 'fifo_value',                                \n                'csvTitles[0]' :'Location',                \n                'csvTitles[1]' :  'Item Number',\n                'csvTitles[2]' :  'Item Description',                \n                'csvTitles[3]' : 'Qty', \n                'csvTitles[4]' : 'Std Cost Valued',\n                'csvTitles[5]' : 'FIFO Value',                                \n                'sort' : 'location_name,item_number',\n                'dir' : 'ASC',  \n                _with_empty_stock : 1,      \n                limit : 99999\n                           \n            }\n        });\n        Roo.MessageBox.alert(\"Notice\", \"Report will download shortly (around 30s)\");\n     \n}\n"
243                                                                     },
244                                                                     "text" : "All Stock in all locations (active)",
245                                                                     "xtype" : "Item",
246                                                                     "$ xns" : "Roo.menu"
247                                                                 },
248                                                                 {
249                                                                     "listeners" : {
250                                                                         "click" : "function (_self, e)\n{\n    var p = {\n            'csvCols[0]' : 'itemsite_item_id_item_number',\n            'csvCols[1]' : 'item_brand_name',\n            'csvCols[2]' : 'itemsite_item_id_item_descrip1',\n            'csvCols[3]' : 'itemsite_qty_before',\n            'csvCols[4]' : 'itemsite_sold_atdate'  ,\n            'csvCols[5]' : 'itemsite_qty',          \n            'csvCols[6]' : 'itemsite_sold_after',   \n            'csvCols[7]' : 'last_transaction',\n            'csvCols[8]' : 'customer_price_each',                           \n            'csvCols[9]' : 'customer_total_value',                                    \n            'csvCols[10]' : 'itemsite_value',\n            'csvCols[11]' : 'item_last_purchase_price',\n            \n            'csvTitles[0]' : 'SKU',\n            'csvTitles[1]' : 'Brand'  ,\n            'csvTitles[2]' : 'Description',            \n            'csvTitles[3]' : 'Qty Before'  , \n            'csvTitles[4]' : 'Total Sold'  , \n            'csvTitles[5]' : 'Qty'  , \n            'csvTitles[6]' : 'Sold After'  , \n            'csvTitles[7]' : 'Last Transaction'  ,\n            'csvTitles[8]' : 'Customer unit price'  ,\n            'csvTitles[9]' : 'Customer Total Value'  ,\n            'csvTitles[10]' : 'FIFO value'  ,\n            'csvTitles[11]' : 'Last Purchase Price'  ,       \n\n\n            \n            \n            'sort' : 'itemsite_item_id_item_number',\n            'dir' : 'ASC',        \n            limit : 9999\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    p.location_id = l.data.location_id;\n    p._as_of = _this.dateTo.getValue();\n    p._with_stock_and_value = 1;\n    p._viewtype = 1;\n    p._with_brand = 1;\n    p._with_last_purchase_price = 1;\n    p._with_qty_detail = 1;\n    \n        new Pman.Download({\n            url : baseURL + '/Roo/itemsite',\n            timeout : 60000,\n            \n            method : 'GET',\n            params : p\n\n        \n        });\n        Roo.MessageBox.alert(\"Notice\", \"Report will download shortly\");\n}"
251                                                                     },
252                                                                     "text" : "Stock at Selected Location (inc. empty)",
253                                                                     "xtype" : "Item",
254                                                                     "$ xns" : "Roo.menu"
255                                                                 },
256                                                                 {
257                                                                     "xtype" : "Separator",
258                                                                     "$ xns" : "Roo.menu"
259                                                                 },
260                                                                 {
261                                                                     "listeners" : {
262                                                                         "click" : "function (_self, e)\n{\n     \n     var p = {\n        _group : 'itemsite',\n        _name : 'stockatlocation',\n        csvCols : '*',\n        limit : 99999\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    p['location_id:number'] = l.data.location_id;\n    p['as_of:text'] = _this.dateTo.getValue();\n    \n        new Pman.Download({\n            url : baseURL + '/Roo/Metasql',\n            newWindow : 1,\n            timeout : 60000,\n            \n            method : 'GET',\n            params : p\n\n        \n        });\n        Roo.MessageBox.alert(\"Notice\", \"Report will download shortly\");\n}"
263                                                                     },
264                                                                     "text" : "Stock at Selected Location (inc. empty) with Adjustment details",
265                                                                     "xtype" : "Item",
266                                                                     "$ xns" : "Roo.menu"
267                                                                 }
268                                                             ]
269                                                         }
270                                                     ]
271                                                 }
272                                             ]
273                                         },
274                                         {
275                                             "xtype" : "ColumnModel",
276                                             "header" : "Active",
277                                             "width" : 50,
278                                             "$ renderer" : "function(v) {  \n    var state = v * 1 > 0 ?  '' :  '-checked' ;\n\n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n                \n }",
279                                             "$ xns" : "Roo.grid",
280                                             "* prop" : "colModel[]",
281                                             "dataIndex" : "location_restrict"
282                                         },
283                                         {
284                                             "xtype" : "ColumnModel",
285                                             "header" : "Name",
286                                             "width" : 200,
287                                             "$ renderer" : "function(v) { return String.format('{0}', v); }",
288                                             "$ xns" : "Roo.grid",
289                                             "* prop" : "colModel[]",
290                                             "dataIndex" : "location_name"
291                                         },
292                                         {
293                                             "xtype" : "ColumnModel",
294                                             "header" : "Description",
295                                             "width" : 200,
296                                             "$ renderer" : "function(v) { return String.format('{0}', v); }",
297                                             "$ xns" : "Roo.grid",
298                                             "* prop" : "colModel[]",
299                                             "dataIndex" : "location_descrip"
300                                         },
301                                         {
302                                             "xtype" : "ColumnModel",
303                                             "header" : "Customer",
304                                             "width" : 200,
305                                             "$ 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('<span style=\"color:red\">[Internal Company : {0}] {1} </span>', \n        r.data.location_cust_id_char_internalcompany,        v); \n    \n}\n",
306                                             "$ xns" : "Roo.grid",
307                                             "* prop" : "colModel[]",
308                                             "dataIndex" : "location_cust_id_cust_name"
309                                         },
310                                         {
311                                             "align" : "right",
312                                             "xtype" : "ColumnModel",
313                                             "header" : "Qty",
314                                             "width" : 75,
315                                             "$ renderer" : "function(v,x,r) { return  typeof(v) == 'undefined' ? '...' : String.format('{0} ', (v*1).toFixed(0) ); }",
316                                             "$ xns" : "Roo.grid",
317                                             "* prop" : "colModel[]",
318                                             "dataIndex" : "location_qty"
319                                         },
320                                         {
321                                             "align" : "right",
322                                             "xtype" : "ColumnModel",
323                                             "header" : "Missing TX",
324                                             "width" : 75,
325                                             "$ 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('<span style=\"color:red;\">{0}</span>', (v*1).toFixed(0) ); \n}",
326                                             "$ xns" : "Roo.grid",
327                                             "* prop" : "colModel[]",
328                                             "dataIndex" : "location_qty_neg"
329                                         },
330                                         {
331                                             "align" : "right",
332                                             "xtype" : "ColumnModel",
333                                             "header" : "Est. Net Qty",
334                                             "width" : 75,
335                                             "$ 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}",
336                                             "$ xns" : "Roo.grid",
337                                             "* prop" : "colModel[]",
338                                             "dataIndex" : "location_qty"
339                                         },
340                                         {
341                                             "align" : "right",
342                                             "hidden" : true,
343                                             "xtype" : "ColumnModel",
344                                             "header" : "NS Qty",
345                                             "width" : 75,
346                                             "$ renderer" : "function(v,x,r) {\n    var f= '{0}';\n    if ((r.data.location_qty) *1 != (v*1)) {\n        f = '<span style=\"color:red;font-weight:bold\">{0}</span>';\n    }\n     return typeof(v) == 'undefined' ? '...' : String.format(f, (v*1).toFixed(0) );\n     \n  }",
347                                             "$ xns" : "Roo.grid",
348                                             "* prop" : "colModel[]",
349                                             "dataIndex" : "location_netsuite_stock"
350                                         },
351                                         {
352                                             "align" : "right",
353                                             "hidden" : true,
354                                             "xtype" : "ColumnModel",
355                                             "header" : "NS -ve Qty",
356                                             "width" : 75,
357                                             "$ renderer" : "function(v,x,r) {     \n    var f= '{0}';\n    if ((r.data.location_qty_neg) *1 != (v*1)) {\n        f = '<span style=\"color:red;font-weight:bold\">{0}</span>';\n    }\n     return typeof(v) == 'undefined' ? '...' : String.format(f, (v*1).toFixed(0) ); \n }",
358                                             "$ xns" : "Roo.grid",
359                                             "* prop" : "colModel[]",
360                                             "dataIndex" : "location_netsuite_stock_neg"
361                                         },
362                                         {
363                                             "align" : "right",
364                                             "xtype" : "ColumnModel",
365                                             "header" : "Value",
366                                             "width" : 200,
367                                             "$ renderer" : "function(v) { return typeof(v) == 'undefined' ? '...' :  Roo.util.Format.usMoney(  v); }",
368                                             "$ xns" : "Roo.grid",
369                                             "* prop" : "colModel[]",
370                                             "dataIndex" : "location_value"
371                                         }
372                                     ]
373                                 }
374                             ]
375                         },
376                         {
377                             "listeners" : {
378                                 "|activate" : "function() {\n    _this.itempanel = this;\n    if (_this.itemgrid) {\n       // _this.itemgrid.footer.onClick('first');\n    }\n}"
379                             },
380                             "fitToframe" : true,
381                             "background" : true,
382                             "region" : "east",
383                             "title" : "itemloc",
384                             "xtype" : "GridPanel",
385                             "fitContainer" : true,
386                             "$ xns" : "Roo",
387                             "tableName" : "itemloc",
388                             "items" : [
389                                 {
390                                     "listeners" : {
391                                         "|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",
392                                         "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}",
393                                         "|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}"
394                                     },
395                                     "autoExpandColumn" : "itemsite_item_id_item_number",
396                                     "xtype" : "Grid",
397                                     "loadMask" : true,
398                                     "$ xns" : "Roo.grid",
399                                     "* prop" : "grid",
400                                     "items" : [
401                                         {
402                                             "listeners" : {
403                                                 "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}"
404                                             },
405                                             "xtype" : "Store",
406                                             "remoteSort" : true,
407                                             "$ sortInfo" : "{ field : 'itemsite_item_id_item_number', direction: 'ASC' }",
408                                             "$ xns" : "Roo.data",
409                                             "* prop" : "dataSource",
410                                             "items" : [
411                                                 {
412                                                     "$ url" : "baseURL + '/Roo/itemsite.php'",
413                                                     "method" : "GET",
414                                                     "xtype" : "HttpProxy",
415                                                     "timeout" : 120000,
416                                                     "$ xns" : "Roo.data",
417                                                     "* prop" : "proxy"
418                                                 },
419                                                 {
420                                                     "id" : "id",
421                                                     "root" : "data",
422                                                     "xtype" : "JsonReader",
423                                                     "$ xns" : "Roo.data",
424                                                     "$ 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]",
425                                                     "* prop" : "reader",
426                                                     "totalProperty" : "total"
427                                                 }
428                                             ]
429                                         },
430                                         {
431                                             "pageSize" : 25,
432                                             "xtype" : "PagingToolbar",
433                                             "emptyMsg" : "No itemloc found",
434                                             "$ xns" : "Roo",
435                                             "displayMsg" : "{0} - {1} of {2}",
436                                             "displayInfo" : true,
437                                             "* prop" : "footer"
438                                         },
439                                         {
440                                             "xtype" : "ColumnModel",
441                                             "header" : "Item",
442                                             "width" : 75,
443                                             "$ renderer" : "function(v) { return String.format('{0}', v); }",
444                                             "$ xns" : "Roo.grid",
445                                             "* prop" : "colModel[]",
446                                             "dataIndex" : "itemsite_item_id_item_number"
447                                         },
448                                         {
449                                             "align" : "right",
450                                             "xtype" : "ColumnModel",
451                                             "header" : "Qty",
452                                             "width" : 55,
453                                             "$ renderer" : "function(v) { return String.format('{0}', (v*1).toFixed(0)); }",
454                                             "$ xns" : "Roo.grid",
455                                             "* prop" : "colModel[]",
456                                             "dataIndex" : "itemsite_qty"
457                                         },
458                                         {
459                                             "align" : "right",
460                                             "hidden" : true,
461                                             "xtype" : "ColumnModel",
462                                             "header" : "NS Qty",
463                                             "width" : 50,
464                                             "$ renderer" : "function(v,x,r) {     \n    var f= '<span style=\"color:blue;text-decoration:underline;cursor:pointer;\">{0}</span>';\n    if ((r.data.itemsite_qty) *1 != (v*1)) {\n        f = '<span style=\"color:red;font-weight:bold;text-decoration:underline;cursor:pointer;\">{0}</span>';\n    }\n    return String.format(f, (v*1).toFixed(0) ); \n}",
465                                             "$ xns" : "Roo.grid",
466                                             "* prop" : "colModel[]",
467                                             "dataIndex" : "netsuite_qty"
468                                         },
469                                         {
470                                             "align" : "right",
471                                             "xtype" : "ColumnModel",
472                                             "header" : "Value",
473                                             "width" : 75,
474                                             "$ renderer" : "function(v) { return Roo.util.Format.usMoney(v); }",
475                                             "$ xns" : "Roo.grid",
476                                             "* prop" : "colModel[]",
477                                             "dataIndex" : "itemsite_value"
478                                         }
479                                     ]
480                                 }
481                             ]
482                         }
483                     ]
484                 }
485             ]
486         }
487     ]
488 }