Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Tab.XtupleSalesInvoice.bjs
1 {
2     "id": "roo-file-393",
3     "name": "Pman.Tab.XtupleSalesInvoice",
4     "parent": "Pman.Tab.XtupleSales",
5     "title": "",
6     "path": "/home/alan/gitlive/web.xtuple/Pman/Xtuple/Pman.Tab.XtupleSalesInvoice.bjs",
7     "items": [
8         {
9             "listeners": {
10                 "|activate": "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
11             },
12             ".builderCfg": "{\"cols\":[{\"table\":\"invchead\",\"column\":\"invchead_ordernumber\",\"columnshort\":\"invchead_ordernumber\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Sales Order#\"},{\"table\":\"invchead\",\"column\":\"invchead_orderdate\",\"columnshort\":\"invchead_orderdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ordered\"},{\"table\":\"invchead\",\"column\":\"invchead_posted\",\"columnshort\":\"invchead_posted\",\"ctype\":\"bool\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Posted\"},{\"table\":\"invchead\",\"column\":\"invchead_printed\",\"columnshort\":\"invchead_printed\",\"ctype\":\"bool\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Printed?\"},{\"table\":\"invchead\",\"column\":\"invchead_invcdate\",\"columnshort\":\"invchead_invcdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Invoiced\"},{\"table\":\"invchead\",\"column\":\"invchead_billto_name\",\"columnshort\":\"invchead_billto_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"Bill To\"}],\"cols_ex\":[\"invchead_billto_name\"],\"table\":\"invchead\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}",
13             "background": true,
14             "fitContainer": true,
15             "fitToframe": true,
16             "region": "center",
17             "tableName": "invchead",
18             "title": "Invoices",
19             "xtype": "GridPanel",
20             "|xns": "Roo",
21             "items": [
22                 {
23                     "listeners": {
24                         "|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}",
25                         "|rowdblclick": "function (_self, rowIndex, e)\n{\n \n     \n     var d =  this.getDataSource().getAt(rowIndex).data;\n     \n     if (d.cohead_id) {\n     \n        Pman.Dialog.XtupleSalesOrder.show( {\n            cohead_id : d.cohead_id\n        \n        }, function() {\n            _this.grid.footer.onClick('refresh');\n            // updated..\n            Pman.Tab.XtupleSales.grid.footer.onClick('first');\n        });  \n        return;\n    }\n    \n    // other wise not a sales order related..\n    \n         \n     Pman.Dialog.XtupleInvc.show( {\n            _id : d.invchead_id\n        \n        }, function() {\n            _this.grid.footer.onClick('refresh');\n            // updated..\n            Pman.Tab.XtupleSales.grid.footer.onClick('first');\n        });  \n    \n}\n"
26                     },
27                     "*prop": "grid",
28                     "autoExpandColumn": "cust_name",
29                     "loadMask": true,
30                     "xtype": "Grid",
31                     "|xns": "Roo.grid",
32                     "items": [
33                         {
34                             "listeners": {
35                                 "beforeload": "function (_self, o)\n{\n    if (_this.ordernumber.getValue().length) {\n        o.params['query[invchead_ordernumber]'] = _this.ordernumber.getValue();\n    }\n    \n    if (_this.invcnumber.getValue().length) {\n        o.params['query[invchead_invcnumber]'] = _this.invcnumber.getValue();\n    }\n    \n    \n    if (_this.customer.getValue()) {\n        o.params.invchead_cust_id = _this.customer.getValue();\n    }\n    if (_this.fromDate.getValue()) {\n        o.params['search[fromDate]'] = _this.fromDate.getValue().format('Y-m-d');\n    }\n    if (_this.toDate.getValue()) {\n        o.params['search[toDate]'] = _this.toDate.getValue().format('Y-m-d');\n    }\n    o.params._show_status = _this.status.getValue();\n    \n    o.params._with_salesorder = 1;\n}"
36                             },
37                             "*prop": "dataSource",
38                             "remoteSort": true,
39                             "xtype": "Store",
40                             "|sortInfo": "{ field : 'invchead_invcdate', direction: 'DESC' }",
41                             "|xns": "Roo.data",
42                             "items": [
43                                 {
44                                     "*prop": "proxy",
45                                     "xtype": "HttpProxy",
46                                     "method": "GET",
47                                     "|url": "baseURL + '/Roo/invchead.php'",
48                                     "|xns": "Roo.data"
49                                 },
50                                 {
51                                     "|xns": "Roo.data",
52                                     "xtype": "JsonReader",
53                                     "totalProperty": "total",
54                                     "root": "data",
55                                     ".builderCfg": "{\"cols\":[{\"table\":\"invchead\",\"column\":\"invchead_ordernumber\",\"columnshort\":\"invchead_ordernumber\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Sales Order#\"},{\"table\":\"invchead\",\"column\":\"invchead_orderdate\",\"columnshort\":\"invchead_orderdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ordered\"},{\"table\":\"invchead\",\"column\":\"invchead_posted\",\"columnshort\":\"invchead_posted\",\"ctype\":\"bool\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Posted\"},{\"table\":\"invchead\",\"column\":\"invchead_printed\",\"columnshort\":\"invchead_printed\",\"ctype\":\"bool\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Printed?\"},{\"table\":\"invchead\",\"column\":\"invchead_invcdate\",\"columnshort\":\"invchead_invcdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Invoiced\"},{\"table\":\"invchead\",\"column\":\"invchead_billto_name\",\"columnshort\":\"invchead_billto_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"Bill To\"}],\"cols_ex\":[\"invchead_billto_name\"],\"table\":\"invchead\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}",
56                                     "*prop": "reader",
57                                     "id": "id",
58                                     "|fields": "[\n    {\n        'name': 'invchead_ordernumber',\n        'type': 'string'\n    },\n    {\n        'name': 'invchead_orderdate',\n        'type': 'date'\n    },\n    {\n        'name': 'invchead_posted',\n        'type': 'boolean'\n    },\n    {\n        'name': 'invchead_printed',\n        'type': 'boolean'\n    },\n    {\n        'name': 'invchead_invcdate',\n        'type': 'date'\n    },\n    {\n        'name': 'invchead_billto_name',\n        'type': 'string'\n    }\n]"
59                                 }
60                             ]
61                         },
62                         {
63                             "*prop": "footer",
64                             "xtype": "PagingToolbar",
65                             "pageSize": 25,
66                             "displayInfo": true,
67                             "displayMsg": "Displaying invchead{0} - {1} of {2}",
68                             "emptyMsg": "No invchead found",
69                             "|xns": "Roo",
70                             "items": [
71                                 {
72                                     "listeners": {
73                                         "click": "function (_self, e)\n{\n    new Pman.Download({\n        grid: _this.grid\n    });\n    Roo.MessageBox.alert(\"Notice\", \"Download should start soon\");\n}"
74                                     },
75                                     "text": "Download",
76                                     "xtype": "Button",
77                                     "|xns": "Roo.Toolbar"
78                                 }
79                             ]
80                         },
81                         {
82                             "*prop": "toolbar",
83                             "xtype": "Toolbar",
84                             "|xns": "Roo",
85                             "items": [
86                                 {
87                                     "listeners": {
88                                         "render": "function (_self)\n{\n    _this.invcnumber = _self;\n}",
89                                         "specialkey": "function (_self, e)\n{\n    _this.grid.footer.onClick('first');\n}"
90                                     },
91                                     "emptyText": "Invoice #",
92                                     "width": 70,
93                                     "xtype": "TextField",
94                                     "|xns": "Roo.form"
95                                 },
96                                 {
97                                     "listeners": {
98                                         "render": "function (_self)\n{\n    _this.ordernumber = _self;\n}",
99                                         "select": "function (combo, record, index)\n{\n    Roo.log('select');\n    _this.grid.footer.onClick('first');\n}"
100                                     },
101                                     "allowBlank": true,
102                                     "displayField": "invchead_ordernumber",
103                                     "editable": true,
104                                     "emptyText": "Order",
105                                     "fieldLabel": "ordernumber",
106                                     "forceSelection": true,
107                                     "hiddenName": "invchead_id",
108                                     "listWidth": 400,
109                                     "loadingText": "Searching...",
110                                     "minChars": 2,
111                                     "name": "invchead_ordernumber",
112                                     "pageSize": 20,
113                                     "qtip": "Select invchead",
114                                     "queryParam": "query[invchead_ordernumber]",
115                                     "selectOnFocus": true,
116                                     "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{invchead_ordernumber}</b> </div>",
117                                     "triggerAction": "all",
118                                     "valueField": "invchead_ordernumber",
119                                     "width": 150,
120                                     "xtype": "ComboBox",
121                                     "|xns": "Roo.form",
122                                     "items": [
123                                         {
124                                             "*prop": "store",
125                                             "|xns": "Roo.data",
126                                             "|sortInfo": "{ direction : 'ASC', field: 'invchead_ordernumber' }",
127                                             "xtype": "Store",
128                                             "remoteSort": true,
129                                             "listeners": {
130                                                 "|beforeload": "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n}\n"
131                                             },
132                                             "items": [
133                                                 {
134                                                     "*prop": "proxy",
135                                                     "xtype": "HttpProxy",
136                                                     "method": "GET",
137                                                     "|xns": "Roo.data",
138                                                     "|url": "baseURL + '/Roo/invchead.php'"
139                                                 },
140                                                 {
141                                                     "*prop": "reader",
142                                                     "xtype": "JsonReader",
143                                                     "|xns": "Roo.data",
144                                                     "id": "invchead_id",
145                                                     "root": "data",
146                                                     "totalProperty": "total",
147                                                     "|fields": "[{\"name\":\"invchead_id\",\"type\":\"int\"},\"invchead_ordernumber\"]"
148                                                 }
149                                             ]
150                                         }
151                                     ]
152                                 },
153                                 {
154                                     "listeners": {
155                                         "render": "function (_self)\n{\n    _this.customer = _self;\n}",
156                                         "select": "function (combo, record, index)\n{\n    _this.grid.footer.onClick('first');\n}"
157                                     },
158                                     "allowBlank": true,
159                                     "displayField": "cust_name",
160                                     "editable": true,
161                                     "emptyText": "Select Customer",
162                                     "fieldLabel": "cust_name",
163                                     "forceSelection": true,
164                                     "hiddenName": "cust_id",
165                                     "listWidth": 400,
166                                     "loadingText": "Searching...",
167                                     "minChars": 2,
168                                     "name": "cust_name",
169                                     "pageSize": 20,
170                                     "qtip": "Select custinfo",
171                                     "queryParam": "query[cust_name]",
172                                     "selectOnFocus": true,
173                                     "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{cust_name}</b> </div>",
174                                     "triggerAction": "all",
175                                     "valueField": "cust_id",
176                                     "width": 200,
177                                     "xtype": "ComboBox",
178                                     "|xns": "Roo.form",
179                                     "items": [
180                                         {
181                                             "*prop": "store",
182                                             "|xns": "Roo.data",
183                                             "|sortInfo": "{ direction : 'ASC', field: 'cust_name' }",
184                                             "xtype": "Store",
185                                             "remoteSort": true,
186                                             "listeners": {
187                                                 "|beforeload": "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n}\n"
188                                             },
189                                             "items": [
190                                                 {
191                                                     "*prop": "proxy",
192                                                     "xtype": "HttpProxy",
193                                                     "method": "GET",
194                                                     "|xns": "Roo.data",
195                                                     "|url": "baseURL + '/Roo/custinfo.php'"
196                                                 },
197                                                 {
198                                                     "*prop": "reader",
199                                                     "xtype": "JsonReader",
200                                                     "|xns": "Roo.data",
201                                                     "id": "cust_id",
202                                                     "root": "data",
203                                                     "totalProperty": "total",
204                                                     "|fields": "[{\"name\":\"cust_id\",\"type\":\"int\"},\"cust_name\"]"
205                                                 }
206                                             ]
207                                         }
208                                     ]
209                                 },
210                                 {
211                                     "listeners": {
212                                         "render": "function (_self)\n{\n  _this.status = _self;\n}",
213                                         "beforeselect": "function (combo, record, index)\n{\n (function() {   _this.grid.footer.onClick('first'); }).defer(100);\n}"
214                                     },
215                                     "allowBlank": false,
216                                     "displayField": "fname",
217                                     "editable": false,
218                                     "fieldLabel": "Status",
219                                     "hiddenName": "status",
220                                     "listWidth": 200,
221                                     "mode": "local",
222                                     "name": "status",
223                                     "triggerAction": "all",
224                                     "value": "A",
225                                     "valueField": "ftype",
226                                     "width": 100,
227                                     "xtype": "ComboBox",
228                                     "|xns": "Roo.form",
229                                     "items": [
230                                         {
231                                             "*prop": "store",
232                                             "xtype": "SimpleStore",
233                                             "|data": "[ \n    [ 'U', \"Unpaid\"],\n    [ 'NV' , \"Not Void Only\"],\n    [ 'V' , \"Void Only\"],    \n    [ 'A', \"All\"] \n]\n",
234                                             "|fields": "[  'ftype', 'fname']",
235                                             "|xns": "Roo.data"
236                                         }
237                                     ]
238                                 },
239                                 {
240                                     "text": "From:",
241                                     "xtype": "TextItem",
242                                     "|xns": "Roo.Toolbar"
243                                 },
244                                 {
245                                     "listeners": {
246                                         "select": "function (combo, date)\n{\n    _this.grid.footer.onClick('first');\n}",
247                                         "render": "function (_self)\n{\n    _this.fromDate = _self;\n}"
248                                     },
249                                     "format": "Y-m-d",
250                                     "xtype": "DateField",
251                                     "|xns": "Roo.form"
252                                 },
253                                 {
254                                     "text": " To:",
255                                     "xtype": "TextItem",
256                                     "|xns": "Roo.Toolbar"
257                                 },
258                                 {
259                                     "listeners": {
260                                         "select": "function (combo, date)\n{\n    _this.grid.footer.onClick('first');\n}",
261                                         "render": "function (_self)\n{\n    _this.toDate = _self;\n}"
262                                     },
263                                     "format": "Y-m-d",
264                                     "xtype": "DateField",
265                                     "|xns": "Roo.form"
266                                 },
267                                 {
268                                     "|xns": "Roo.Toolbar",
269                                     "xtype": "Fill"
270                                 },
271                                 {
272                                     "listeners": {
273                                         "|click": "function ()\n{\n\n    if (!Pman.hasPerm('Xtuple.InvoiceAll', 'S')) {\n        Roo.MessageBox.alert(\"Error\", \"You do not have permissions to do that, please contact the administrator to void invoices, or edit the sales order.\");\n        return;\n    \n    }\n    \n    \n     var sel  = _this.grid.getSelectionModel().getSelected();\n    if (!sel) {\n        Roo.MessageBox.alert(\"Error\", \"Select a invoice\");\n        return;\n    }\n    // check current status of shipment..\n    \n    Roo.MessageBox.confirm(\"Are you sure\", \"Are you sure you want to VOID that invoice?\",\n        function(r) {\n            if (r != 'yes') {\n                return;\n            }\n            new Pman.Request({\n                mask : 'Sending',\n                url : baseURL + '/Roo/invchead',\n                method : 'POST',\n                params : {\n                    invchead_id : sel.data.invchead_id,\n                    _void : 1\n                },\n                success : function() {\n                    _this.grid.footer.onClick('refresh');\n                }\n            })\n            \n        }\n    );\n            \n            \n   \n}"
274                                     },
275                                     "cls": "x-btn-text-icon",
276                                     "text": "Void Invoice",
277                                     "xtype": "Button",
278                                     "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
279                                     "|xns": "Roo.Toolbar"
280                                 }
281                             ]
282                         },
283                         {
284                             "*prop": "colModel[]",
285                             "align": "right",
286                             "dataIndex": "invchead_ordernumber",
287                             "header": "Sales Order#",
288                             "width": 100,
289                             "xtype": "ColumnModel",
290                             "|renderer": "function(v) { return String.format('{0}', v); }",
291                             "|xns": "Roo.grid"
292                         },
293                         {
294                             "*prop": "colModel[]",
295                             "align": "right",
296                             "dataIndex": "invchead_invcnumber",
297                             "header": "Invoice#",
298                             "width": 100,
299                             "xtype": "ColumnModel",
300                             "|renderer": "function(v,x,r) {\n    if (r.data.invchead_void) { \n        var vv = v.split('x-').shift();\n        return String.format('<s>{0}</s>', vv);    \n    }\n    return String.format('{0}', v);\n }",
301                             "|xns": "Roo.grid"
302                         },
303                         {
304                             "xtype": "ColumnModel",
305                             ".builderCfg": "{\"table\":\"invchead\",\"column\":\"invchead_orderdate\",\"columnshort\":\"invchead_orderdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ordered\"}",
306                             "header": "Ordered",
307                             "width": 75,
308                             "dataIndex": "invchead_orderdate",
309                             "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
310                             "|xns": "Roo.grid",
311                             "*prop": "colModel[]"
312                         },
313                         {
314                             "*prop": "colModel[]",
315                             "dataIndex": "invchead_posted",
316                             "header": "Posted",
317                             "width": 75,
318                             "xtype": "ColumnModel",
319                             "|renderer": "function(v,x,r) {     \n \n    if (r.data.invchead_void) { \n        return String.format('<s>VOID</s>', v);    \n    }\n    \n    return String.format('{0}', v); \n}",
320                             "|xns": "Roo.grid"
321                         },
322                         {
323                             "*prop": "colModel[]",
324                             "dataIndex": "invchead_void",
325                             "header": "Void",
326                             "hidden": true,
327                             "width": 75,
328                             "xtype": "ColumnModel",
329                             "|renderer": "function(v,x,r) {     \n \n    \n    return String.format('{0}', v); \n}",
330                             "|xns": "Roo.grid"
331                         },
332                         {
333                             "*prop": "colModel[]",
334                             "dataIndex": "invchead_salesrep_id_salesrep_name",
335                             "header": "Sales Rep",
336                             "width": 75,
337                             "xtype": "ColumnModel",
338                             "|renderer": "function(v) { return String.format('{0}', v); }",
339                             "|xns": "Roo.grid"
340                         },
341                         {
342                             "*prop": "colModel[]",
343                             "dataIndex": "cust_salesrep_id_salesrep_name",
344                             "header": "Customer Rep",
345                             "width": 75,
346                             "xtype": "ColumnModel",
347                             "|renderer": "function(v) { return String.format('{0}', v); }",
348                             "|xns": "Roo.grid"
349                         },
350                         {
351                             "*prop": "colModel[]",
352                             ".builderCfg": "{\"table\":\"invchead\",\"column\":\"invchead_printed\",\"columnshort\":\"invchead_printed\",\"ctype\":\"bool\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Printed?\"}",
353                             "dataIndex": "invchead_printed",
354                             "header": "Printed?",
355                             "hidden": true,
356                             "width": 75,
357                             "xtype": "ColumnModel",
358                             "|renderer": "function(v) { return String.format('{0}', v); }",
359                             "|xns": "Roo.grid"
360                         },
361                         {
362                             "xtype": "ColumnModel",
363                             ".builderCfg": "{\"table\":\"invchead\",\"column\":\"invchead_invcdate\",\"columnshort\":\"invchead_invcdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Invoiced\"}",
364                             "header": "Invoiced",
365                             "width": 75,
366                             "dataIndex": "invchead_invcdate",
367                             "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
368                             "|xns": "Roo.grid",
369                             "*prop": "colModel[]"
370                         },
371                         {
372                             "*prop": "colModel[]",
373                             "dataIndex": "cust_addr_id_addr_postalcode",
374                             "header": "Customer Postcode",
375                             "width": 75,
376                             "xtype": "ColumnModel",
377                             "|renderer": "function(v) { return String.format('{0}', v); }",
378                             "|xns": "Roo.grid"
379                         },
380                         {
381                             "*prop": "colModel[]",
382                             "dataIndex": "cust_addr_id_addr_state",
383                             "header": "Customer State",
384                             "width": 75,
385                             "xtype": "ColumnModel",
386                             "|renderer": "function(v) { return String.format('{0}', v); }",
387                             "|xns": "Roo.grid"
388                         },
389                         {
390                             "*prop": "colModel[]",
391                             "dataIndex": "cust_name",
392                             "header": "Customer",
393                             "width": 200,
394                             "xtype": "ColumnModel",
395                             "|renderer": "function(v) { return String.format('{0}', v); }",
396                             "|xns": "Roo.grid"
397                         },
398                         {
399                             "*prop": "colModel[]",
400                             "dataIndex": "invchead_curr_id_curr_symbol",
401                             "header": "Currency",
402                             "width": 75,
403                             "xtype": "ColumnModel",
404                             "|renderer": "function(v) { return String.format('{0}', v ? v : '??'); }",
405                             "|xns": "Roo.grid"
406                         },
407                         {
408                             "*prop": "colModel[]",
409                             "align": "right",
410                             "dataIndex": "invchead_total",
411                             "header": "Value",
412                             "width": 75,
413                             "xtype": "ColumnModel",
414                             "|renderer": "function(v) { return v ? Roo.util.Format.usMoney( v) : ''; }",
415                             "|xns": "Roo.grid"
416                         },
417                         {
418                             "*prop": "colModel[]",
419                             "align": "right",
420                             "dataIndex": "aropen_amount",
421                             "header": "w/Tax",
422                             "width": 75,
423                             "xtype": "ColumnModel",
424                             "|renderer": "function(v) { return v ? Roo.util.Format.usMoney( v) : ''; }",
425                             "|xns": "Roo.grid"
426                         }
427                     ]
428                 }
429             ]
430         }
431     ],
432     "permname": "",
433     "modOrder": "300"
434 }