Pman.Tab.XtuplePriceLists.bjs
[Pman.Xtuple] / Pman.Tab.XtuplePriceLists.bjs
1 {
2     "id": "roo-file-56",
3     "name": "Pman.Tab.XtuplePriceLists",
4     "parent": "Pman.Tab.XtupleManage",
5     "title": "Pman.Tab.XtuplePriceLists",
6     "path": "/home/edward/gitlive/web.xtuple/Pman/Xtuple/Pman.Tab.XtuplePriceLists.bjs",
7     "items": [
8         {
9             "background": true,
10             "fitContainer": true,
11             "fitToFrame": true,
12             "region": "center",
13             "title": "Price List",
14             "xtype": "NestedLayoutPanel",
15             "|xns": "Roo",
16             "items": [
17                 {
18                     "|xns": "Roo",
19                     "xtype": "BorderLayout",
20                     "*prop": "layout",
21                     "items": [
22                         {
23                             "*prop": "center",
24                             "xtype": "LayoutRegion",
25                             "|xns": "Roo"
26                         },
27                         {
28                             "*prop": "east",
29                             "split": true,
30                             "xtype": "LayoutRegion",
31                             "|xns": "Roo"
32                         },
33                         {
34                             "listeners": {
35                                 "|activate": "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
36                             },
37                             "background": true,
38                             "fitContainer": true,
39                             "fitToframe": true,
40                             "region": "center",
41                             "tableName": "ipshead",
42                             "title": "Price Lists",
43                             "xtype": "GridPanel",
44                             "|xns": "Roo",
45                             "items": [
46                                 {
47                                     "listeners": {
48                                         "|render": "function() \n{\n    _this.grid = this; \n    _this.dialog = Pman.Dialog.XtuplePriceList\n    if (_this.panel.active) {\n       this.footer.onClick('first');\n    }\n}",
49                                         "|rowdblclick": "function (_self, rowIndex, e)\n{\n    if (!_this.dialog) return;\n    _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {\n        _this.grid.footer.onClick('first');\n    }); \n    \n}\n"
50                                     },
51                                     "*prop": "grid",
52                                     "autoExpandColumn": "ipshead_descrip",
53                                     "loadMask": true,
54                                     "xtype": "Grid",
55                                     "|xns": "Roo.grid",
56                                     "items": [
57                                         {
58                                             "*prop": "sm",
59                                             "singleSelect": true,
60                                             "xtype": "RowSelectionModel",
61                                             "|xns": "Roo.grid"
62                                         },
63                                         {
64                                             "*prop": "dataSource",
65                                             "xtype": "Store",
66                                             "remoteSort": true,
67                                             "|sortInfo": "{ field : 'ipshead_name', direction: 'ASC' }",
68                                             "|xns": "Roo.data",
69                                             "items": [
70                                                 {
71                                                     "*prop": "proxy",
72                                                     "xtype": "HttpProxy",
73                                                     "method": "GET",
74                                                     "|url": "baseURL + '/Roo/ipshead.php'",
75                                                     "|xns": "Roo.data"
76                                                 },
77                                                 {
78                                                     "|xns": "Roo.data",
79                                                     "xtype": "JsonReader",
80                                                     "totalProperty": "total",
81                                                     "root": "data",
82                                                     "*prop": "reader",
83                                                     "id": "id",
84                                                     "|fields": "[\n    {\n        'name': 'ipshead_id',\n        'type': 'int'\n    },\n    {\n        'name': 'ipshead_name',\n        'type': 'string'\n    },\n    {\n        'name': 'ipshead_descrip',\n        'type': 'string'\n    },\n    {\n        'name': 'ipshead_effective',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'ipshead_expires',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'ipshead_curr_id',\n        'type': 'int'\n    },\n    {\n        'name': 'ipshead_updated',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'ipshead_curr_id_curr_id',\n        'type': 'int'\n    },\n    {\n        'name': 'ipshead_curr_id_curr_base',\n        'type': 'int'\n    },\n    {\n        'name': 'ipshead_curr_id_curr_name',\n        'type': 'string'\n    },\n    {\n        'name': 'ipshead_curr_id_curr_symbol',\n        'type': 'string'\n    },\n    {\n        'name': 'ipshead_curr_id_curr_abbr',\n        'type': 'string'\n    }\n]"
85                                                 }
86                                             ]
87                                         },
88                                         {
89                                             "*prop": "footer",
90                                             "displayInfo": true,
91                                             "displayMsg": "Displaying ipshead{0} - {1} of {2}",
92                                             "emptyMsg": "No ipshead found",
93                                             "pageSize": 25,
94                                             "xtype": "PagingToolbar",
95                                             "|xns": "Roo"
96                                         },
97                                         {
98                                             "*prop": "toolbar",
99                                             "xtype": "Toolbar",
100                                             "|xns": "Roo",
101                                             "items": [
102                                                 {
103                                                     "listeners": {
104                                                         "click": "function (_self, e)\n{\n   new Pman.Download({\n        method: 'GET',\n        url : baseURL + '/Roo/Ipsiteminfo',\n        params : {\n            _pricegrid : 1\n        }\n   });\n}"
105                                                     },
106                                                     "text": "Download Price Matrix",
107                                                     "xtype": "Button",
108                                                     "|xns": "Roo.Toolbar"
109                                                 },
110                                                 {
111                                                     "listeners": {
112                                                         "click": "function (_self, e)\n{\n   Pman.Dialog.Image.show(\n       {\n            _url : baseURL+'/Xtuple/Pricing'\n        \n       },\n       function (data) {\n            var msg = [];\n            if (data.deleted) {\n                msg.push(\"Deleted \" + data.deleted + \" Price(s)\");\n            }\n            if (data.updated) {\n                msg.push(\"Updated \" + data.updated + \" Price(s)\");\n            }            \n            if (data.inserted) {\n                msg.push(\"Added \" + data.inserted + \" Price(s)\");\n            }\n            if (!msg.length) {\n                msg.push(\"No data changed\");\n            }\n            Roo.MessageBox.alert(\"Notice\", msg.join(\"\\n\"));\n\n       }\n   );\n}"
113                                                     },
114                                                     "text": "Upload Price Matrix",
115                                                     "xtype": "Button",
116                                                     "|xns": "Roo.Toolbar"
117                                                 },
118                                                 {
119                                                     "|xns": "Roo.Toolbar",
120                                                     "xtype": "Fill"
121                                                 },
122                                                 {
123                                                     "text": "Add",
124                                                     "xtype": "Button",
125                                                     "cls": "x-btn-text-icon",
126                                                     "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
127                                                     "listeners": {
128                                                         "|click": "function()\n{\n    if (!_this.dialog) return;\n    _this.dialog.show( { id : 0 } , function() {\n        _this.grid.footer.onClick('first');\n   }); \n}\n"
129                                                     },
130                                                     "|xns": "Roo.Toolbar"
131                                                 },
132                                                 {
133                                                     "text": "Delete",
134                                                     "cls": "x-btn-text-icon",
135                                                     "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
136                                                     "xtype": "Button",
137                                                     "listeners": {
138                                                         "|click": "function()\n{\n     Pman.genericDelete(_this, 'ipshead'); \n}\n        "
139                                                     },
140                                                     "|xns": "Roo.Toolbar"
141                                                 }
142                                             ]
143                                         },
144                                         {
145                                             "*prop": "colModel[]",
146                                             "dataIndex": "ipshead_curr_id_curr_name",
147                                             "header": "Ipshead curr",
148                                             "sortable": true,
149                                             "width": 75,
150                                             "xtype": "ColumnModel",
151                                             "|renderer": "function(v) { return String.format('{0}', v); }",
152                                             "|xns": "Roo.grid"
153                                         },
154                                         {
155                                             "*prop": "colModel[]",
156                                             "dataIndex": "ipshead_name",
157                                             "header": "Ipshead name",
158                                             "sortable": true,
159                                             "width": 200,
160                                             "xtype": "ColumnModel",
161                                             "|renderer": "function(v) { return String.format('{0}', v); }",
162                                             "|xns": "Roo.grid"
163                                         },
164                                         {
165                                             "xtype": "ColumnModel",
166                                             "header": "Ipshead descrip",
167                                             "width": 200,
168                                             "dataIndex": "ipshead_descrip",
169                                             "|renderer": "function(v) { return String.format('{0}', v); }",
170                                             "|xns": "Roo.grid",
171                                             "*prop": "colModel[]"
172                                         },
173                                         {
174                                             "xtype": "ColumnModel",
175                                             "header": "Ipshead effective",
176                                             "width": 75,
177                                             "dataIndex": "ipshead_effective",
178                                             "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
179                                             "|xns": "Roo.grid",
180                                             "*prop": "colModel[]"
181                                         },
182                                         {
183                                             "*prop": "colModel[]",
184                                             "dataIndex": "ipshead_expires",
185                                             "header": "Ipshead expires",
186                                             "width": 75,
187                                             "xtype": "ColumnModel",
188                                             "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
189                                             "|xns": "Roo.grid"
190                                         },
191                                         {
192                                             "xtype": "ColumnModel",
193                                             "header": "Ipshead updated",
194                                             "width": 75,
195                                             "dataIndex": "ipshead_updated",
196                                             "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
197                                             "|xns": "Roo.grid",
198                                             "*prop": "colModel[]"
199                                         }
200                                     ]
201                                 }
202                             ]
203                         },
204                         {
205                             "listeners": {
206                                 "|activate": "function() {\n    _this.ipanel = this;\n    if (_this.igrid) {\n       // _this.igrid.footer.onClick('first');\n    }\n}"
207                             },
208                             "background": true,
209                             "fitContainer": true,
210                             "fitToframe": true,
211                             "region": "east",
212                             "tableName": "item",
213                             "title": "Products",
214                             "xtype": "GridPanel",
215                             "|xns": "Roo",
216                             "items": [
217                                 {
218                                     "listeners": {
219                                         "|render": "function() \n{\n    _this.igrid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.ipanel.active) {\n       //this.footer.onClick('first');\n    }\n}",
220                                         "cellclick": "function (_self, row, col, e)\n{\n     var di = _this.grid.colModel.getDataIndex(col);\n     \n     var rec = _this.grid.ds.getAt(row);\n     \n     if(di == 'item_image_filename'){\n        if(!rec.data.item_image_id){\n            return;\n        }\n        var u = baseURL;\n        if(rec.data.item_image_from_hk){\n            u = u.split('/');\n            u.pop();\n            u = u.join('/') + '/hk.php';\n        }\n        Pman.download( {\n           url: u + '/Images/Download/' + rec.data.item_image_id  + '/' + rec.data.item_image_filename\n       });\n       return;\n     }\n     \n     if (di == 'item_active') {\n     \n        var nv = rec.data.item_active ? 0 : 1;\n        new Pman.Request({\n            mask : 'Saving',\n            url : baseURL + '/Roo/Item',\n            params : {\n                item_id : rec.data.item_id,\n                item_active : nv\n            },\n            success : function() {\n                rec.set('item_active', nv);\n            }\n        });\n        return;\n        \n     \n     }\n     \n     if(di == 'itemsrc_active'){\n        if(!rec.data.itemsrc_active){\n            Roo.MessageBox.alert('Error','Please edit it on Xtuple tool');\n            return;\n        }\n        if(rec.data.itemsrc_active){\n            Roo.MessageBox.confirm(\"Confirm\", \"Are you sure this product is no longer purchased\",\n                function (res) {\n                    if(res!='yes') {\n                        return;\n                    }\n                    rec.commit();\n            });\n        }\n    }\n     \n     _this.locgrid.footer.onClick('first');\n     \n     \n     \n     \n}",
221                                         "afteredit": "function (e)\n{\n    \n    \n    Roo.log(e);\n    new Pman.Request({\n        url : baseURL +'/Roo/Charass',\n        params : {\n             charass_char_id_char_name : e.field.replace(/^item_char_/,'').toUpperCase(),\n             charass_value : e.value,\n             charass_target_type : 'I',\n             charass_default : 1,\n             charass_target_id : e.record.data.item_id\n         },\n         method : 'POST'\n     });\n    \n    \n    e.record.commit();\n    \n    \n    \n}",
222                                         "rowdblclick": "function (_self, rowIndex, e)\n{\n    if (!_this.dialog) return;\n    _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {\n        _this.grid.footer.onClick('first');\n    }); \n}\n"
223                                     },
224                                     "*prop": "grid",
225                                     "autoExpandColumn": "item_descrip1",
226                                     "clicksToEdit": 1,
227                                     "loadMask": true,
228                                     "xtype": "EditorGrid",
229                                     "|xns": "Roo.grid",
230                                     "items": [
231                                         {
232                                             "listeners": {
233                                                 "beforeload": "function (_self, o)\n{\n    o.params = o.params || {}\n    \n    var p = _this.grid.getSelectionModel().getSelected();\n    \n    if(!p || p.ipshead_id * 1 < 1){\n        this.ds.removeAll();\n        return;\n    }\n    \n    o.params.item_active = 1;\n\n}",
234                                                 "update": "function (_self, record, operation)\n{\n    if(operation != 'commit'){\n        return;\n    }\n    \n    var nv  = record.data.itemsrc_active ? 0 : 1;\n    new Pman.Request({\n        mask : 'Saving',\n        url : baseURL + '/Roo/Itemsrc',\n        params : {\n            _update_by_item : 1,\n            item_id : record.data.item_id,\n            itemsrc_active : nv\n        },\n        success : function(res) {\n            record.set('itemsrc_active', nv);\n        }\n    });\n}"
235                                             },
236                                             "*prop": "dataSource",
237                                             "remoteSort": true,
238                                             "xtype": "Store",
239                                             "|sortInfo": "{ field : 'item_number', direction: 'ASC' }",
240                                             "|xns": "Roo.data",
241                                             "items": [
242                                                 {
243                                                     "*prop": "proxy",
244                                                     "xtype": "HttpProxy",
245                                                     "method": "GET",
246                                                     "|url": "baseURL + '/Roo/item.php'",
247                                                     "|xns": "Roo.data"
248                                                 },
249                                                 {
250                                                     "|xns": "Roo.data",
251                                                     "xtype": "JsonReader",
252                                                     "totalProperty": "total",
253                                                     "root": "data",
254                                                     "*prop": "reader",
255                                                     "id": "id",
256                                                     "|fields": "[\n    {\n        'name': 'item_id',\n        'type': 'int'\n    },\n    {\n        'name': 'item_number',\n        'type': 'string'\n    },\n    {\n        'name': 'item_descrip1',\n        'type': 'string'\n    },\n    {\n        'name': 'item_descrip2',\n        'type': 'string'\n    },\n    {\n        'name': 'item_classcode_id',\n        'type': 'int'\n    },\n    {\n        'name': 'item_picklist',\n        'type': 'int'\n    },\n    {\n        'name': 'item_comments',\n        'type': 'string'\n    },\n    {\n        'name': 'item_sold',\n        'type': 'int'\n    },\n    {\n        'name': 'item_fractional',\n        'type': 'int'\n    },\n    {\n        'name': 'item_active',\n        'type': 'int'\n    },\n    {\n        'name': 'item_type',\n        'type': 'string'\n    },\n    {\n        'name': 'item_prodweight',\n        'type': 'float'\n    },\n    {\n        'name': 'item_packweight',\n        'type': 'float'\n    },\n    {\n        'name': 'item_prodcat_id',\n        'type': 'int'\n    },\n    {\n        'name': 'item_exclusive',\n        'type': 'int'\n    },\n    {\n        'name': 'item_listprice',\n        'type': 'float'\n    },\n    {\n        'name': 'item_config',\n        'type': 'int'\n    },\n    {\n        'name': 'item_extdescrip',\n        'type': 'string'\n    },\n    {\n        'name': 'item_upccode',\n        'type': 'string'\n    },\n    {\n        'name': 'item_maxcost',\n        'type': 'float'\n    },\n    {\n        'name': 'item_inv_uom_id',\n        'type': 'int'\n    },\n    {\n        'name': 'item_price_uom_id',\n        'type': 'int'\n    },\n    {\n        'name': 'item_warrdays',\n        'type': 'int'\n    },\n    {\n        'name': 'item_freightclass_id',\n        'type': 'int'\n    },\n    {\n        'name': 'item_tax_recoverable',\n        'type': 'int'\n    },\n    {\n        'name': 'item_price_uom_id_uom_id',\n        'type': 'int'\n    },\n    {\n        'name': 'item_price_uom_id_uom_name',\n        'type': 'string'\n    },\n    {\n        'name': 'item_price_uom_id_uom_descrip',\n        'type': 'string'\n    },\n    {\n        'name': 'item_price_uom_id_uom_item_weight',\n        'type': 'int'\n    },\n    {\n        'name': 'item_inv_uom_id_uom_id',\n        'type': 'int'\n    },\n    {\n        'name': 'item_inv_uom_id_uom_name',\n        'type': 'string'\n    },\n    {\n        'name': 'item_inv_uom_id_uom_descrip',\n        'type': 'string'\n    },\n    {\n        'name': 'item_inv_uom_id_uom_item_weight',\n        'type': 'int'\n    },\n    {\n        'name': 'item_freightclass_id_freightclass_id',\n        'type': 'int'\n    },\n    {\n        'name': 'item_freightclass_id_freightclass_code',\n        'type': 'string'\n    },\n    {\n        'name': 'item_freightclass_id_freightclass_descrip',\n        'type': 'string'\n    },\n    {\n        'name': 'item_classcode_id_classcode_id',\n        'type': 'int'\n    },\n    {\n        'name': 'item_classcode_id_classcode_code',\n        'type': 'string'\n    },\n    {\n        'name': 'item_classcode_id_classcode_descrip',\n        'type': 'string'\n    },\n    {\n        'name': 'item_classcode_id_classcode_mfg',\n        'type': 'int'\n    },\n    {\n        'name': 'item_classcode_id_classcode_creator',\n        'type': 'string'\n    },\n    {\n        'name': 'item_classcode_id_classcode_created',\n        'type': 'date'\n    },\n    {\n        'name': 'item_classcode_id_classcode_modifier',\n        'type': 'string'\n    },\n    {\n        'name': 'item_classcode_id_classcode_modified',\n        'type': 'date'\n    },\n    {\n        'name': 'item_classcode_id_classcode_type',\n        'type': 'string'\n    }\n]"
257                                                 }
258                                             ]
259                                         },
260                                         {
261                                             "|xns": "Roo",
262                                             "xtype": "Toolbar",
263                                             "*prop": "toolbar",
264                                             "items": [
265                                                 {
266                                                     "listeners": {
267                                                         "render": "function (_self)\n{\n  _this.brandSel = _self;\n}",
268                                                         "select": "function (combo, record, index)\n{\n    _this.grid.footer.onClick('first');\n}"
269                                                     },
270                                                     "allowBlank": true,
271                                                     "alwaysQuery": true,
272                                                     "displayField": "charass_value",
273                                                     "editable": true,
274                                                     "forceSelection": true,
275                                                     "listWidth": 300,
276                                                     "loadingText": "Searching...",
277                                                     "minChars": 2,
278                                                     "pageSize": 20,
279                                                     "qtip": "Select Brand",
280                                                     "queryParam": "query[charass_value]",
281                                                     "selectOnFocus": true,
282                                                     "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{charass_value}</b> </div>",
283                                                     "triggerAction": "all",
284                                                     "width": 150,
285                                                     "xtype": "ComboBox",
286                                                     "|xns": "Roo.form",
287                                                     "items": [
288                                                         {
289                                                             "listeners": {
290                                                                 "|beforeload": "function (_self, o)\n{\n    o.params = o.params || {};\n    // staff can see all logs, other companies can only see their own.\n    // look for all of the charass 's with the same type= eg. brand.\n    \n    o.params.charass_char_id_char_name = 'BRAND';\n    o.params.charass_target_type ='I';\n    o.params._distinct = 'charass_value';\n        o.params._columns = 'charass_value';\n\n}"
291                                                             },
292                                                             "*prop": "store",
293                                                             "remoteSort": true,
294                                                             "xtype": "Store",
295                                                             "|sortInfo": "{ field : 'charass_value' , direction : 'ASC' }",
296                                                             "|xns": "Roo.data",
297                                                             "items": [
298                                                                 {
299                                                                     "*prop": "proxy",
300                                                                     "method": "GET",
301                                                                     "xtype": "HttpProxy",
302                                                                     "|url": "baseURL + '/Roo/Charass.php'",
303                                                                     "|xns": "Roo.data"
304                                                                 },
305                                                                 {
306                                                                     "|xns": "Roo.data",
307                                                                     "xtype": "JsonReader",
308                                                                     "totalProperty": "total",
309                                                                     "root": "data",
310                                                                     "*prop": "reader",
311                                                                     "id": "id",
312                                                                     "|fields": "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_name',\n        'type': 'string'\n    },\n    {\n        'name': 'event_when',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'action',\n        'type': 'string'\n    },\n    {\n        'name': 'ipaddr',\n        'type': 'string'\n    },\n    {\n        'name': 'on_id',\n        'type': 'int'\n    },\n    {\n        'name': 'on_table',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id',\n        'type': 'int'\n    },\n    {\n        'name': 'remarks',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_office_id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_name',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_phone',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_fax',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_email',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_company_id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_role',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_active',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_remarks',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_passwd',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_owner_id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_lang',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_no_reset_sent',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_action_type',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_project_id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_deleted_by',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_deleted_dt',\n        'type': 'date'\n    }\n]"
313                                                                 }
314                                                             ]
315                                                         }
316                                                     ]
317                                                 },
318                                                 {
319                                                     "listeners": {
320                                                         "render": "function (_self)\n{\n  _this.search = _self;\n}",
321                                                         "specialkey": "function (_self, e)\n{\n    _this.grid.footer.onClick('first');\n}"
322                                                     },
323                                                     "xtype": "TextField",
324                                                     "|xns": "Roo.form"
325                                                 },
326                                                 {
327                                                     "listeners": {
328                                                         "|click": "function (_self, e)\n{\n_this.grid.footer.onClick('first');\n}"
329                                                     },
330                                                     "cls": "x-btn-icon",
331                                                     "xtype": "Button",
332                                                     "|icon": "rootURL + '/Pman/templates/images/search.gif'",
333                                                     "|xns": "Roo.Toolbar"
334                                                 },
335                                                 {
336                                                     "listeners": {
337                                                         "|click": "function (_self, e)\n{\n    _this.search.setValue('');\n    \n\n    \n    _this.grid.footer.onClick('first');\n}"
338                                                     },
339                                                     "cls": "x-btn-icon",
340                                                     "xtype": "Button",
341                                                     "|icon": "rootURL + '/Pman/templates/images/edit-clear.gif'",
342                                                     "|xns": "Roo.Toolbar"
343                                                 },
344                                                 {
345                                                     "|xns": "Roo.Toolbar",
346                                                     "xtype": "Separator"
347                                                 },
348                                                 {
349                                                     "listeners": {
350                                                         "toggle": "function (_self, pressed)\n{\n\n    this.setText(pressed ? \"Hide Inactive\" : \"Show Inactive\");\n    (function() { _this.grid.footer.onClick('first'); }).defer(100);\n}",
351                                                         "render": "function (_self)\n{\n    _this.active = _self;\n}"
352                                                     },
353                                                     "enableToggle": true,
354                                                     "text": "Show Inactive",
355                                                     "xtype": "Button",
356                                                     "|xns": "Roo.Toolbar"
357                                                 },
358                                                 {
359                                                     "|xns": "Roo.Toolbar",
360                                                     "xtype": "Fill"
361                                                 },
362                                                 {
363                                                     "text": "Report start :",
364                                                     "xtype": "TextItem",
365                                                     "|xns": "Roo.Toolbar"
366                                                 },
367                                                 {
368                                                     "listeners": {
369                                                         "render": "function (_self)\n{\n    _this.dateFrom = _self;\n}"
370                                                     },
371                                                     "format": "d/M/Y",
372                                                     "useIso": true,
373                                                     "xtype": "DateField",
374                                                     "|value": "(function() { return (new Date()).format('Y') + '-01-01'; })()",
375                                                     "|xns": "Roo.form"
376                                                 },
377                                                 {
378                                                     "listeners": {
379                                                         "render": "function (_self)\n{\n  _this.datespan  = _self;\n}"
380                                                     },
381                                                     "allowBlank": false,
382                                                     "displayField": "fname",
383                                                     "editable": false,
384                                                     "fieldLabel": "Status",
385                                                     "hiddenName": "cm_status",
386                                                     "listWidth": 200,
387                                                     "mode": "local",
388                                                     "name": "cm_status_name",
389                                                     "triggerAction": "all",
390                                                     "value": 12,
391                                                     "valueField": "ftype",
392                                                     "width": 150,
393                                                     "xtype": "ComboBox",
394                                                     "|xns": "Roo.form",
395                                                     "items": [
396                                                         {
397                                                             "*prop": "store",
398                                                             "xtype": "SimpleStore",
399                                                             "|data": "[ \n    [ '1', \"Single Month Sales\"],\n    [ '3', \"Quarter Sales\"],\n    [ '6', \"Half year Sales\"] ,\n    [ '12', \"Full Year Sales\"] \n]\n",
400                                                             "|fields": "[  'ftype', 'fname']",
401                                                             "|xns": "Roo.data"
402                                                         }
403                                                     ]
404                                                 },
405                                                 {
406                                                     "listeners": {
407                                                         "click": "function (_self, e)\n{\n    if (!_this.brandSel.getValue().length) {\n        Roo.MessageBox.alert(\"Error\", \"Select a brand to download\");\n        return;\n    }\n\n    new Pman.Download({\n        url : baseURL + '/Xtuple/Reports/SalesByCountryItemYear',\n        params: { \n            date_from : _this.dateFrom.getValue(),\n            brand : _this.brandSel.getValue(),\n            span : _this.datespan.getValue()\n        }\n    });\n        \n\n}"
408                                                     },
409                                                     "text": "Download Sales Report",
410                                                     "xtype": "Button",
411                                                     "|xns": "Roo.Toolbar"
412                                                 }
413                                             ]
414                                         },
415                                         {
416                                             "*prop": "footer",
417                                             "xtype": "PagingToolbar",
418                                             "pageSize": 25,
419                                             "displayInfo": true,
420                                             "displayMsg": "Displaying item{0} - {1} of {2}",
421                                             "emptyMsg": "No item found",
422                                             "|xns": "Roo",
423                                             "items": [
424                                                 {
425                                                     "listeners": {
426                                                         "click": "function (_self, e)\n{\n   new Pman.Download({\n        method: 'GET',\n        url : baseURL + '/Roo/item',\n        params : {\n            _costgrid : 1\n        }\n   });\n}"
427                                                     },
428                                                     "text": "Download Standard costs",
429                                                     "xtype": "Button",
430                                                     "|xns": "Roo.Toolbar"
431                                                 },
432                                                 {
433                                                     "listeners": {
434                                                         "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}"
435                                                     },
436                                                     "text": "Upload new products and costs",
437                                                     "xtype": "Button",
438                                                     "|xns": "Roo.Toolbar"
439                                                 },
440                                                 {
441                                                     "listeners": {
442                                                         "click": "function (_self, e)\n{\n    \n    var sel = _this.grid.selModel.getSelectedCell();\n    if (!sel) {\n        Roo.MessageBox.alert(\"Error\", \"Select a row\");\n        return;\n    }\n    \n    var rec = _this.grid.ds.getAt(sel[0]);\n    if(rec.data.item_id * 1 < 1){\n        return;\n    }\n    \n    Pman.Dialog.Image.show({\n            id : rec.data.item_image_id ? rec.data.item_image_id : 0,\n            onid : rec.data.item_id,\n            ontable : 'Item'\n        }, function(data) {\n            if (data) {\n                _this.grid.footer.onClick('first');\n                \n        }\n        \n    });\n}"
443                                                     },
444                                                     "text": "Upload an image",
445                                                     "xtype": "Button",
446                                                     "|xns": "Roo.Toolbar"
447                                                 },
448                                                 {
449                                                     "listeners": {
450                                                         "click": "function (_self, e)\n{\n  Roo.MessageBox.progress (\"Syncing Stock\", \"Sending\");\n  \n  var offset = 0;\n  \n   function runSync() {\n       \n       new Pman.Request( {\n            url : baseURL+'/Roo/Item',\n            method : 'GET',\n            params : {\n                _syncFromHK : 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   }\n   runSync();\n}"
451                                                     },
452                                                     "text": "Sync Product Data from HK",
453                                                     "xtype": "Button",
454                                                     "|hidden": "(function() {\n\n    return baseURL.match(/hk\\.php$/) ? true : false;\n})()",
455                                                     "|xns": "Roo.Toolbar"
456                                                 }
457                                             ]
458                                         },
459                                         {
460                                             "*prop": "colModel[]",
461                                             "dataIndex": "item_image_filename",
462                                             "header": "Image ( Click to download )",
463                                             "width": 150,
464                                             "xtype": "ColumnModel",
465                                             "|renderer": "function(v,x,r)\r\n{\n   if(!v){\n    return '';\n   }\n   if(r.data.item_image_from_hk){\n        var url = baseURL.split('/');\n        url.pop();\n        url = url.join('/');\n        return '<img src=\"' + url + '/hk.php/Images/Thumb/150x150/' + r.data.item_image_id + '/' + v + '\" width=\"150\" height=\"150\" />';     \n   }\r\n   return '<img src=\"' + baseURL + '/Images/Thumb/150x150/' + r.data.item_image_id + '/' + v + '\" width=\"150\" height=\"150\" />';\r\n}",
466                                             "|xns": "Roo.grid"
467                                         },
468                                         {
469                                             "*prop": "colModel[]",
470                                             "dataIndex": "item_char_brand",
471                                             "header": "Brand",
472                                             "sortable": true,
473                                             "width": 100,
474                                             "xtype": "ColumnModel",
475                                             "|renderer": "function(v) { return String.format('{0}', v); }",
476                                             "|xns": "Roo.grid",
477                                             "items": [
478                                                 {
479                                                     "|xns": "Roo.grid",
480                                                     "xtype": "GridEditor",
481                                                     "*prop": "editor",
482                                                     "items": [
483                                                         {
484                                                             "*prop": "field",
485                                                             "allowBlank": true,
486                                                             "alwaysQuery": true,
487                                                             "displayField": "charass_value",
488                                                             "editable": true,
489                                                             "forceSelection": false,
490                                                             "listWidth": 300,
491                                                             "loadingText": "Searching...",
492                                                             "minChars": 2,
493                                                             "pageSize": 20,
494                                                             "qtip": "Select Brand",
495                                                             "queryParam": "query[charass_value]",
496                                                             "selectOnFocus": true,
497                                                             "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{charass_value}</b> </div>",
498                                                             "triggerAction": "all",
499                                                             "width": 150,
500                                                             "xtype": "ComboBox",
501                                                             "|xns": "Roo.form",
502                                                             "items": [
503                                                                 {
504                                                                     "listeners": {
505                                                                         "|beforeload": "function (_self, o)\n{\n    o.params = o.params || {};\n    // staff can see all logs, other companies can only see their own.\n    // look for all of the charass 's with the same type= eg. brand.\n    \n    o.params.charass_char_id_char_name = 'BRAND';\n    o.params.charass_target_type ='I';\n    o.params._distinct = 'charass_value';\n        o.params._columns = 'charass_value';\n\n}"
506                                                                     },
507                                                                     "*prop": "store",
508                                                                     "remoteSort": true,
509                                                                     "xtype": "Store",
510                                                                     "|sortInfo": "{ field : 'charass_value' , direction : 'ASC' }",
511                                                                     "|xns": "Roo.data",
512                                                                     "items": [
513                                                                         {
514                                                                             "*prop": "proxy",
515                                                                             "method": "GET",
516                                                                             "xtype": "HttpProxy",
517                                                                             "|url": "baseURL + '/Roo/Charass.php'",
518                                                                             "|xns": "Roo.data"
519                                                                         },
520                                                                         {
521                                                                             "|xns": "Roo.data",
522                                                                             "xtype": "JsonReader",
523                                                                             "totalProperty": "total",
524                                                                             "root": "data",
525                                                                             "*prop": "reader",
526                                                                             "id": "id",
527                                                                             "|fields": "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_name',\n        'type': 'string'\n    },\n    {\n        'name': 'event_when',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'action',\n        'type': 'string'\n    },\n    {\n        'name': 'ipaddr',\n        'type': 'string'\n    },\n    {\n        'name': 'on_id',\n        'type': 'int'\n    },\n    {\n        'name': 'on_table',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id',\n        'type': 'int'\n    },\n    {\n        'name': 'remarks',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_office_id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_name',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_phone',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_fax',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_email',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_company_id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_role',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_active',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_remarks',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_passwd',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_owner_id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_lang',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_no_reset_sent',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_action_type',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_project_id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_deleted_by',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_deleted_dt',\n        'type': 'date'\n    }\n]"
528                                                                         }
529                                                                     ]
530                                                                 }
531                                                             ]
532                                                         }
533                                                     ]
534                                                 }
535                                             ]
536                                         },
537                                         {
538                                             "*prop": "colModel[]",
539                                             "dataIndex": "item_char_productgroup",
540                                             "header": "Product Group",
541                                             "width": 100,
542                                             "xtype": "ColumnModel",
543                                             "|renderer": "function(v) { return String.format('{0}', v); }",
544                                             "|xns": "Roo.grid",
545                                             "items": [
546                                                 {
547                                                     "|xns": "Roo.grid",
548                                                     "xtype": "GridEditor",
549                                                     "*prop": "editor",
550                                                     "items": [
551                                                         {
552                                                             "*prop": "field",
553                                                             "allowBlank": true,
554                                                             "alwaysQuery": true,
555                                                             "displayField": "charass_value",
556                                                             "editable": true,
557                                                             "forceSelection": false,
558                                                             "listWidth": 300,
559                                                             "loadingText": "Searching...",
560                                                             "minChars": 2,
561                                                             "pageSize": 20,
562                                                             "qtip": "Select Brand",
563                                                             "queryParam": "query[charass_value]",
564                                                             "selectOnFocus": true,
565                                                             "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{charass_value}</b> </div>",
566                                                             "triggerAction": "all",
567                                                             "width": 150,
568                                                             "xtype": "ComboBox",
569                                                             "|xns": "Roo.form",
570                                                             "items": [
571                                                                 {
572                                                                     "listeners": {
573                                                                         "|beforeload": "function (_self, o)\n{\n    o.params = o.params || {};\n    // staff can see all logs, other companies can only see their own.\n    // look for all of the charass 's with the same type= eg. brand.\n    \n    o.params.charass_char_id_char_name = 'PRODUCTGROUP';\n    o.params.charass_target_type ='I';\n    o.params._distinct = 'charass_value';\n        o.params._columns = 'charass_value';    \n}"
574                                                                     },
575                                                                     "*prop": "store",
576                                                                     "remoteSort": true,
577                                                                     "xtype": "Store",
578                                                                     "|sortInfo": "{ field : 'charass_value' , direction : 'ASC' }",
579                                                                     "|xns": "Roo.data",
580                                                                     "items": [
581                                                                         {
582                                                                             "*prop": "proxy",
583                                                                             "method": "GET",
584                                                                             "xtype": "HttpProxy",
585                                                                             "|url": "baseURL + '/Roo/Charass.php'",
586                                                                             "|xns": "Roo.data"
587                                                                         },
588                                                                         {
589                                                                             "|xns": "Roo.data",
590                                                                             "xtype": "JsonReader",
591                                                                             "totalProperty": "total",
592                                                                             "root": "data",
593                                                                             "*prop": "reader",
594                                                                             "id": "id",
595                                                                             "|fields": "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_name',\n        'type': 'string'\n    },\n    {\n        'name': 'event_when',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'action',\n        'type': 'string'\n    },\n    {\n        'name': 'ipaddr',\n        'type': 'string'\n    },\n    {\n        'name': 'on_id',\n        'type': 'int'\n    },\n    {\n        'name': 'on_table',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id',\n        'type': 'int'\n    },\n    {\n        'name': 'remarks',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_office_id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_name',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_phone',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_fax',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_email',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_company_id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_role',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_active',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_remarks',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_passwd',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_owner_id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_lang',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_no_reset_sent',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_action_type',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_project_id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_deleted_by',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_deleted_dt',\n        'type': 'date'\n    }\n]"
596                                                                         }
597                                                                     ]
598                                                                 }
599                                                             ]
600                                                         }
601                                                     ]
602                                                 }
603                                             ]
604                                         },
605                                         {
606                                             "*prop": "colModel[]",
607                                             "dataIndex": "item_number",
608                                             "header": "Number",
609                                             "width": 100,
610                                             "xtype": "ColumnModel",
611                                             "|renderer": "function(v) { return String.format('{0}', v); }",
612                                             "|xns": "Roo.grid"
613                                         },
614                                         {
615                                             "*prop": "colModel[]",
616                                             "dataIndex": "item_descrip1",
617                                             "header": "Description",
618                                             "width": 200,
619                                             "xtype": "ColumnModel",
620                                             "|renderer": "function(v) { return String.format('{0}', v); }",
621                                             "|xns": "Roo.grid"
622                                         },
623                                         {
624                                             "*prop": "colModel[]",
625                                             "dataIndex": "itemsrc_active",
626                                             "header": "Purchased",
627                                             "width": 75,
628                                             "xtype": "ColumnModel",
629                                             "|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 }",
630                                             "|xns": "Roo.grid"
631                                         },
632                                         {
633                                             "*prop": "colModel[]",
634                                             "dataIndex": "item_sold",
635                                             "header": "is Sold?",
636                                             "width": 75,
637                                             "xtype": "ColumnModel",
638                                             "|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 }",
639                                             "|xns": "Roo.grid"
640                                         },
641                                         {
642                                             "*prop": "colModel[]",
643                                             "dataIndex": "item_active",
644                                             "header": "is Active?",
645                                             "width": 75,
646                                             "xtype": "ColumnModel",
647                                             "|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 }",
648                                             "|xns": "Roo.grid"
649                                         },
650                                         {
651                                             "*prop": "colModel[]",
652                                             "dataIndex": "last_purchase_price",
653                                             "header": "Last purchase price",
654                                             "width": 120,
655                                             "xtype": "ColumnModel",
656                                             "|renderer": "function(v,x,r) {\n\n     return String.format('{0}{1}', r.data.last_purchase_price_curr_name, Roo.util.Format.number(v,2)) ; \n     \n }",
657                                             "|xns": "Roo.grid"
658                                         },
659                                         {
660                                             "*prop": "colModel[]",
661                                             "dataIndex": "item_type",
662                                             "header": "Item type",
663                                             "width": 100,
664                                             "xtype": "ColumnModel",
665                                             "|renderer": "function(v) { return String.format('{0}', v); }",
666                                             "|xns": "Roo.grid"
667                                         },
668                                         {
669                                             "*prop": "colModel[]",
670                                             "dataIndex": "item_prodcat_id_prodcat_code",
671                                             "header": "Item prodcat",
672                                             "width": 100,
673                                             "xtype": "ColumnModel",
674                                             "|renderer": "function(v) { return String.format('{0}', v); }",
675                                             "|xns": "Roo.grid"
676                                         },
677                                         {
678                                             "*prop": "colModel[]",
679                                             "align": "right",
680                                             "dataIndex": "item_actcost",
681                                             "header": "Cost",
682                                             "width": 75,
683                                             "xtype": "ColumnModel",
684                                             "|renderer": "function(v,x,r) {\n\n     return String.format('{0}{1}', r.data.item_curr_name, Roo.util.Format.number(v,2)) ; \n     \n }",
685                                             "|xns": "Roo.grid"
686                                         },
687                                         {
688                                             "*prop": "colModel[]",
689                                             "align": "right",
690                                             "dataIndex": "item_base_cost",
691                                             "header": "Cost (base)",
692                                             "width": 75,
693                                             "xtype": "ColumnModel",
694                                             "|renderer": "function(v,x,r) {\n\n     return String.format('{0}{1}', r.data.item_base_curr, Roo.util.Format.number(v,2)) ; \n     \n }",
695                                             "|xns": "Roo.grid"
696                                         }
697                                     ]
698                                 }
699                             ]
700                         }
701                     ]
702                 }
703             ]
704         }
705     ],
706     "permname": "",
707     "modOrder": "001"
708 }