Pman.Tab.XtupleReconcile.bjs
[Pman.Xtuple] / Pman.Tab.XtupleReconcile.bjs
1 {
2     "id": "roo-file-62",
3     "name": "Pman.Tab.XtupleReconcile",
4     "parent": "Pman.Tab.XtupleAccountsTab",
5     "title": "Pman.Tab.XtupleReconcile",
6     "path": "/home/edward/gitlive/web.xtuple/Pman/Xtuple/Pman.Tab.XtupleReconcile.bjs",
7     "items": [
8         {
9             "background": true,
10             "title": "Bank Reconcile",
11             "xtype": "NestedLayoutPanel",
12             "|xns": "Roo",
13             "items": [
14                 {
15                     "|xns": "Roo",
16                     "xtype": "BorderLayout",
17                     "*prop": "layout",
18                     "items": [
19                         {
20                             "|xns": "Roo",
21                             "xtype": "LayoutRegion",
22                             "*prop": "center"
23                         },
24                         {
25                             "*prop": "west",
26                             "split": true,
27                             "width": 400,
28                             "xtype": "LayoutRegion",
29                             "|xns": "Roo"
30                         },
31                         {
32                             "listeners": {
33                                 "|activate": "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
34                             },
35                             "background": true,
36                             "fitContainer": true,
37                             "fitToframe": true,
38                             "region": "center",
39                             "tableName": "metasql",
40                             "title": "Bank Reconcile",
41                             "xtype": "GridPanel",
42                             "|xns": "Roo",
43                             "items": [
44                                 {
45                                     "listeners": {
46                                         "|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}",
47                                         "cellclick": "function (_self, rowIndex, columnIndex, e)\n{\n    var clear = function(ar) \n    {\n        var ar_in = ar;\n        if (ar === true) {\n            ar = [];\n            \n            _this.grid.ds.each(function(rec) {\n                if (rec.data.doc_type == 'BF') {\n                    return;\n                }\n                ar.push(rec);\n            });\n        }\n        var sortdate = false;\n        var data = [];\n        Roo.each(ar, function(rec) {\n            if (rec.data.cleared || rec.data.bankrec_posted) {\n                return;\n            }\n            if(!sortdate){\n                sortdate = rec.data.sortdate;\n            }\n            data.push({\n                 id : rec.data.id,\n                altid : rec.data.altid,\n                curr_rate : rec.data.doc_exchrate,\n                amount : rec.data.amount\n                \n            });\n        });\n       new Pman.Request({\n        url : baseURL + '/Roo/bankrecitem',\n            method : 'POST',\n            mask : 'Clearing',\n            params : {\n                bankaccnt_id : _this.bankacct.getValue(),\n                sortdate : sortdate,\n                set_clear : Roo.encode(data)\n            },\n            success : function() {\n                Roo.each(ar, function(rec) {\n                    rec.set('cleared', true);\n                });\n                if (ar_in === true) {\n                    _this.grid.ds.getAt(0).set('cleared', true);\n                }\n                _this.wgrid.footer.onClick('refresh');\n            }\n        });\n    }\n    \n    \n    var unclear = function(ar)\n    {\n        var ar_in = ar;\n        if (ar === true) {\n            ar = [];\n            \n            _this.grid.ds.each(function(rec) {\n                if (rec.data.doc_type == 'BF') {\n                    return;\n                }\n                ar.push(rec);\n            });\n        }\n        var sortdate = false;\n        var data = [];\n        Roo.each(ar, function(rec) {\n            if (!rec.data.cleared  || rec.data.bankrec_posted) {\n                return;\n            }\n            if(!sortdate){\n                sortdate = rec.data.sortdate;\n            }\n            data.push({\n                id : rec.data.id,\n                altid : rec.data.altid                \n            });\n        });\n\n        new Pman.Request({\n            url : baseURL + '/Roo/bankrecitem',\n            method : 'POST',\n            mask : 'Clearing',\n            params : {\n                bankaccnt_id : _this.bankacct.getValue(),\n                sortdate : sortdate,\n                remove_clear :Roo.encode(data)\n                \n            },\n            success : function() {\n                Roo.each(ar, function(rec) {\n                    rec.set('cleared', false);\n                });\n               if (ar_in === true) {\n                    _this.grid.ds.getAt(0).set('cleared', false);\n                }  \n                _this.wgrid.footer.onClick('refresh');\n            }\n        });\n     \n      \n    };\n    \n    \n    \n    var di = this.colModel.config[columnIndex].dataIndex;\n    if (di != 'cleared') {\n        return;\n    }\n    var  rec = this.ds.getAt(rowIndex);\n    if (rec.data.doc_type == 'BF') {\n    \n        if (rec.data.cleared) {\n            unclear(true);\n        \n        } else {\n            clear(true);\n        }\n    \n        return;\n    }\n    \n        \n        \n    if (rec.data.cleared) {\n    \n        unclear([rec]);\n        return;\n        \n    }\n    \n    clear([rec]);\n    \n    \n     \n         \n  \n}",
48                                         "beforeedit": "function (e)\n{\n    //    Roo.log(e);\n       var ch =  _this.grid.colModel.config[e.column].header;\n       var val = e.value *1;\n  // Roo.log(ch);\n  // Roo.log(val);\n\n       if (val > 0.0 && ch == 'Debit') {\n            e.cancel = true;\n            return;\n        }\n       if (val < 0.0 && ch == 'Credit') {\n            e.cancel = true;\n            return;\n        }\n        if (e.record.data.cleared || e.record.data.bankrec_posted) {\n            e.cancel = true;\n            return;\n        }\n        \n        // allow start editing..\n}",
49                                         "afteredit": "function (e)\n{\n\n    if (e.cancel) {\n        return;\n    }\n       var ch =  _this.grid.colModel.config[e.column].header;\n           var val = e.originalValue *1;\n      // Roo.log(ch);\n      // Roo.log(val);\n\n       if (val > 0.0 && ch == 'Debit') {\n            e.cancel = true;\n            return;\n        }\n       if (val < 0.0 && ch == 'Credit') {\n            e.cancel = true;\n            return;\n        }\n        if (e.record.data.cleared || e.record.data.bankrec_posted) {\n            e.cancel = true;\n            return;\n        }\n        if (val > 0.0 && e.value < 0.0) {\n        Roo.log(\"CANCEL\");  \n            e.record.set('amount', e.originalValue);\n            e.cancel = true;\n            return;\n        }\n        if (val < 0.0 && e.value > 0.0) {\n        Roo.log(\"CANCEL\");\n            e.record.set('amount', e.originalValue);\n            e.cancel = true;\n            return;\n        } \n        if (e.originalValue*1 == e.value*1) {\n            return;\n        }\n          \n        e.record.set('doc_exchrate', Math.abs(e.value  * 1)  / Math.abs(e.record.data.base_amount * 1));\n        Roo.log(e.record);\n        \n        _this.grid.ds.updateBalance();\n        // send it down the line...\n        new Pman.Request({\n            method : 'POST',\n            url : baseURL + '/Roo/bankrecitem',\n            mask : 'Saving',\n            params : {\n                bankaccnt_id : _this.bankacct.getValue(),\n                set_amount : Math.abs(e.value),\n                sortdate : e.record.data.sortdate,\n                source_id : e.record.data.id,\n                altid : e.record.data.altid\n            }\n        \n        });\n        \n         \n        \n        \n}"
50                                     },
51                                     "*prop": "grid",
52                                     "autoExpandColumn": "notes",
53                                     "clicksToEdit": 1,
54                                     "loadMask": true,
55                                     "xtype": "EditorGrid",
56                                     "|xns": "Roo.grid",
57                                     "items": [
58                                         {
59                                             "listeners": {
60                                                 "beforeloadadd": "function (_self, records, options, res)\n{\n //  _this.total = 0.0;\n\n  \n\n\n      _this.total = 1 * res.raw.amount;\n        _this.bf = 1 * res.raw.amount;\n    Roo.log(\"TOTAL:\" + _this.total);\n}\n",
61                                                 "load": "function (_self, records, options)\n{\n    \n    var bal = _this.bf;\n      var cleared = true;\n      var posted = true;\n    Roo.each(records, function(rec) {\n        if (!rec.data.cleared) {\n            cleared = false;\n\n        }\n        if (!rec.data.bankrec_posted) {\n            posted = false;\n        }\n        if (rec.data.doc_type != 'BF') {\n            bal += rec.data.amount *1;\n            rec.set('balance', bal);   \n        } else {\n            rec.set('balance', _this.bf);\n        }\n        \n        \n    });\n    \n    var rec = this.reader.newRow({\n        notes : 'Brought Forward',\n        balance : _this.bf,\n        doc_type : 'BF',\n        cleared : cleared,\n        bankrec_posted : posted\n    });\n    this.insert(0, [rec]);\n}",
62                                                 "beforeload": "function (_self, o)\n{\n    var s = _this.wgrid.getSelectionModel().getSelected();\n    \n    if (!s) {\n        return false;\n    }\n    o.params._group = 'bankrec';\n    o.params._name = 'all';\n    o.params['sortdate:text'] = s.data.sortdate;\n    o.params['bankaccntid:number'] =     _this.bankacct.getValue();\n\n    o.params['_cals'] = 'amount'\n}"
63                                             },
64                                             "*prop": "dataSource",
65                                             "remoteSort": true,
66                                             "xtype": "Store",
67                                             "|sortInfo": "{ field : 'metasql_group', direction: 'ASC' }",
68                                             "|updateBalance": "function() {\n     var bal = _this.bf;\n    this.each( function(rec) {\n        if (rec.data.doc_type != 'BF') {\n            bal += rec.data.amount *1;\n            rec.set('balance', bal);   \n        } else {\n            rec.set('balance', _this.bf);\n        }\n        \n        \n    });\n}\n",
69                                             "|xns": "Roo.data",
70                                             "items": [
71                                                 {
72                                                     "*prop": "proxy",
73                                                     "method": "GET",
74                                                     "xtype": "HttpProxy",
75                                                     "|url": "baseURL + '/Roo/metasql.php'",
76                                                     "|xns": "Roo.data"
77                                                 },
78                                                 {
79                                                     "*prop": "reader",
80                                                     "id": "idx",
81                                                     "root": "data",
82                                                     "totalProperty": "total",
83                                                     "xtype": "JsonReader",
84                                                     "|fields": "[\n    {\n        'name': 'metasql_id',\n        'type': 'int'\n    },\n    {\n        'name': 'metasql_group',\n        'type': 'string'\n    },\n    {\n        'name': 'metasql_name',\n        'type': 'string'\n    },\n    {\n        'name': 'metasql_notes',\n        'type': 'string'\n    },\n    {\n        'name': 'metasql_query',\n        'type': 'string'\n    },\n    {\n        'name': 'metasql_lastuser',\n        'type': 'string'\n    },\n    {\n        'name': 'metasql_lastupdate',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'metasql_grade',\n        'type': 'int'\n    }\n]",
85                                                     "|xns": "Roo.data"
86                                                 }
87                                             ]
88                                         },
89                                         {
90                                             "*prop": "footer",
91                                             "displayInfo": true,
92                                             "displayMsg": "Displaying records {0} - {1} of {2}",
93                                             "emptyMsg": "Nothing found",
94                                             "pageSize": 50,
95                                             "xtype": "PagingToolbar",
96                                             "|xns": "Roo"
97                                         },
98                                         {
99                                             "*prop": "toolbar",
100                                             "xtype": "Toolbar",
101                                             "|xns": "Roo",
102                                             "items": [
103                                                 {
104                                                     "listeners": {
105                                                         "render": "function (_self)\n{\n    _this.bankacct = _self;\n}",
106                                                         "select": "function (combo, record, index)\n{ \n    var curr = record.data.bankaccnt_curr_id_curr_abbr;\n    var col = _this.grid.colModel.config.length -1;\n    \n    _this.grid.colModel.setColumnHeader(col, 'Balance (' + curr +')');\n    \n    _this.grid.ds.removeAll();\n    \n    _this.wgrid.footer.onClick('first');\n}"
107                                                     },
108                                                     "allowBlank": false,
109                                                     "displayField": "bankaccnt_bankname",
110                                                     "editable": false,
111                                                     "emptyText": "Select bankaccnt",
112                                                     "fieldLabel": "bankaccnt",
113                                                     "forceSelection": true,
114                                                     "hiddenName": "bankaccnt_id",
115                                                     "listWidth": 400,
116                                                     "loadingText": "Searching...",
117                                                     "minChars": 2,
118                                                     "name": "bankaccnt_bankname",
119                                                     "pageSize": 50,
120                                                     "qtip": "Select bankaccnt",
121                                                     "queryParam": "",
122                                                     "selectOnFocus": true,
123                                                     "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{bankaccnt_bankname}</b> </div>",
124                                                     "triggerAction": "all",
125                                                     "typeAhead": true,
126                                                     "valueField": "bankaccnt_id",
127                                                     "width": 300,
128                                                     "xtype": "ComboBox",
129                                                     "|xns": "Roo.form",
130                                                     "items": [
131                                                         {
132                                                             "listeners": {
133                                                                 "|beforeload": "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n}\n"
134                                                             },
135                                                             "*prop": "store",
136                                                             "remoteSort": true,
137                                                             "xtype": "Store",
138                                                             "|sortInfo": "{ direction : 'ASC', field: 'bankaccnt_bankname' }",
139                                                             "|xns": "Roo.data",
140                                                             "items": [
141                                                                 {
142                                                                     "*prop": "proxy",
143                                                                     "xtype": "HttpProxy",
144                                                                     "method": "GET",
145                                                                     "|xns": "Roo.data",
146                                                                     "|url": "baseURL + '/Roo/bankaccnt.php'"
147                                                                 },
148                                                                 {
149                                                                     "*prop": "reader",
150                                                                     "xtype": "JsonReader",
151                                                                     "|xns": "Roo.data",
152                                                                     "id": "id",
153                                                                     "root": "data",
154                                                                     "totalProperty": "total",
155                                                                     "|fields": "[{\"name\":\"id\",\"type\":\"int\"},{\"name\":\"bankaccnt_name\",\"type\":\"string\"}]"
156                                                                 }
157                                                             ]
158                                                         }
159                                                     ]
160                                                 },
161                                                 {
162                                                     "listeners": {
163                                                         "click": "function (_self, e)\n{\n    var o = {params : {}}; \n    if (!_this.bankacct.getValue()) {\n        return false;\n    }\n    o.params._group = 'bankrec';\n    o.params._name = 'all';\n    o.params['bankaccntid:number'] =     _this.bankacct.getValue();\n    o.params['_sum_prev'] = 'amount';\n     o.url = baseURL + '/Roo/Metasql';\n     o.method = 'GET';\n     \n     var cols = {\n        'cleared' : 'Cleared',\n        'sortdate' : 'Date',\n        'doc_type' : 'Doctype',\n        'doc_number' : 'Doc number',\n        'notes' : 'Notes',\n        'doc_curr' : 'Currency',\n        'base_amount' : 'Base Amount',\n        'doc_exchrate' : 'Exchange Rate',\n        'amount' : 'Amount (Bank Currency)'\n    };\n     var n =0;\n     for (var i in cols) {\n        \n     \n        o.params['csvCols['+n+']'] =  i\n        o.params['csvTitles['+n+']'] =  cols[i];\n        n++;\n    }\n\n     \n     new Pman.Download(o);\n    Roo.MessageBox.alert(\"Notice\", \"Should be downloading now\");\n}"
164                                                     },
165                                                     "text": "Download",
166                                                     "xtype": "Button",
167                                                     "|xns": "Roo.Toolbar"
168                                                 },
169                                                 {
170                                                     "|xns": "Roo.Toolbar",
171                                                     "xtype": "Fill"
172                                                 }
173                                             ]
174                                         },
175                                         {
176                                             "*prop": "colModel[]",
177                                             "dataIndex": "cleared",
178                                             "header": "Cleared",
179                                             "width": 50,
180                                             "xtype": "ColumnModel",
181                                             "|renderer": "function(v,x,r) { \n    if (r.data.bankrec_posted) {\n        return 'POSTED';\n    }\n\n    var state = v   ?  '-checked' : '';\n                                    \n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n }",
182                                             "|xns": "Roo.grid"
183                                         },
184                                         {
185                                             "*prop": "colModel[]",
186                                             "dataIndex": "sortdate",
187                                             "header": "Date",
188                                             "width": 75,
189                                             "xtype": "ColumnModel",
190                                             "|renderer": "function(v) {   \n\n    return v ? Date.parseDate(v,'Y-m-d').format('d/M/Y') : '';\n }",
191                                             "|xns": "Roo.grid"
192                                         },
193                                         {
194                                             "*prop": "colModel[]",
195                                             "dataIndex": "doc_type",
196                                             "header": "Doctype",
197                                             "width": 50,
198                                             "xtype": "ColumnModel",
199                                             "|renderer": "function(v) { return String.format('{0}', v); }",
200                                             "|xns": "Roo.grid"
201                                         },
202                                         {
203                                             "*prop": "colModel[]",
204                                             "dataIndex": "doc_number",
205                                             "header": "Doc Number",
206                                             "width": 120,
207                                             "xtype": "ColumnModel",
208                                             "|renderer": "function(v) { return String.format('{0}', v); }",
209                                             "|xns": "Roo.grid"
210                                         },
211                                         {
212                                             "*prop": "colModel[]",
213                                             "dataIndex": "notes",
214                                             "header": "Notes",
215                                             "width": 200,
216                                             "xtype": "ColumnModel",
217                                             "|renderer": "function(v) { return String.format('{0}', v); }",
218                                             "|xns": "Roo.grid"
219                                         },
220                                         {
221                                             "*prop": "colModel[]",
222                                             "dataIndex": "doc_curr",
223                                             "header": "Currency",
224                                             "width": 75,
225                                             "xtype": "ColumnModel",
226                                             "|renderer": "function(v) { return String.format('{0}', v); }",
227                                             "|xns": "Roo.grid"
228                                         },
229                                         {
230                                             "*prop": "colModel[]",
231                                             "align": "right",
232                                             "dataIndex": "doc_exchrate",
233                                             "header": "Exchange Rate",
234                                             "width": 75,
235                                             "xtype": "ColumnModel",
236                                             "|renderer": "function(v) { return String.format('{0}', v ? (v*1).toFixed(3) : ''); }",
237                                             "|xns": "Roo.grid"
238                                         },
239                                         {
240                                             "*prop": "colModel[]",
241                                             "align": "right",
242                                             "dataIndex": "base_amount",
243                                             "header": "Base Amount",
244                                             "width": 120,
245                                             "xtype": "ColumnModel",
246                                             "|renderer": "function(v) { return String.format('{0}', Roo.util.Format.number(v*1,2)); }",
247                                             "|xns": "Roo.grid"
248                                         },
249                                         {
250                                             "*prop": "colModel[]",
251                                             "align": "right",
252                                             "dataIndex": "amount",
253                                             "header": "Credit",
254                                             "width": 120,
255                                             "xtype": "ColumnModel",
256                                             "|renderer": "function(v,x,r) { \n    if (r.data.doc_type == 'BF') {\n        return '';\n    }\n    return String.format('{0}', v > 0 ? Roo.util.Format.number(v*1,2)   : ''); }",
257                                             "|xns": "Roo.grid",
258                                             "items": [
259                                                 {
260                                                     "|xns": "Roo.grid",
261                                                     "xtype": "GridEditor",
262                                                     "*prop": "editor",
263                                                     "items": [
264                                                         {
265                                                             "*prop": "field",
266                                                             "cls": "align-right",
267                                                             "decimalPrecision": 2,
268                                                             "xtype": "NumberField",
269                                                             "|xns": "Roo.form"
270                                                         }
271                                                     ]
272                                                 }
273                                             ]
274                                         },
275                                         {
276                                             "*prop": "colModel[]",
277                                             "align": "right",
278                                             "dataIndex": "amount",
279                                             "header": "Debit",
280                                             "width": 120,
281                                             "xtype": "ColumnModel",
282                                             "|renderer": "function(v,x,r) { \n    if (r.data.doc_type == 'BF') {\n        return '';\n    }\n    return String.format('{0}', v < 0 ? Roo.util.Format.number(v*1,2): ''); }",
283                                             "|xns": "Roo.grid",
284                                             "items": [
285                                                 {
286                                                     "|xns": "Roo.grid",
287                                                     "xtype": "GridEditor",
288                                                     "*prop": "editor",
289                                                     "items": [
290                                                         {
291                                                             "*prop": "field",
292                                                             "cls": "align-right",
293                                                             "decimalPrecision": 2,
294                                                             "xtype": "NumberField",
295                                                             "|xns": "Roo.form"
296                                                         }
297                                                     ]
298                                                 }
299                                             ]
300                                         },
301                                         {
302                                             "*prop": "colModel[]",
303                                             "align": "right",
304                                             "dataIndex": "balance",
305                                             "header": "Balance",
306                                             "width": 120,
307                                             "xtype": "ColumnModel",
308                                             "|renderer": "\nfunction(v,x,r) { \n    if (r.data.doc_type == 'BF') {\n        return String.format('{0}', Roo.util.Format.number(v*1,2)); \n    }\n\n\n    //_this.total += (v*1)\n     return String.format('{0}', Roo.util.Format.number(v*1,2)); \n}",
309                                             "|xns": "Roo.grid"
310                                         }
311                                     ]
312                                 }
313                             ]
314                         },
315                         {
316                             "listeners": {
317                                 "|activate": "function() {\n    _this.wpanel = this;\n    //if (_this.wgrid) {\n    //    _this.wgrid.footer.onClick('first');\n    //}\n}"
318                             },
319                             "background": true,
320                             "fitContainer": true,
321                             "fitToframe": true,
322                             "region": "west",
323                             "tableName": "Groups",
324                             "title": "Pick a Date",
325                             "xtype": "GridPanel",
326                             "|xns": "Roo",
327                             "items": [
328                                 {
329                                     "listeners": {
330                                         "|render": "function() \n{\n    _this.wgrid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    //if (_this.wpanel.active) {\n    //   this.footer.onClick('first');\n    //}\n}",
331                                         "cellclick": "function (_self, rowIndex, columnIndex, e)\n{\n    var di = this.colModel.getDataIndex(columnIndex);\n\n    if (di != 'is_reconciled') {\n        return;\n    }\n     \n    var rec = this.ds.getAt(rowIndex);\n    \n    var voidit = function(){\n        new Pman.Request({\n            url : baseURL + '/Roo/Bankrec.php',\n            method :'POST',\n            params : {\n                _void : 1,\n                bankaccnt_id : _this.bankacct.getValue(),\n                sotrdate : rec.data.sortdate\n                \n            },\n            success : function() {\n                _this.wgrid.footer.onClick('refresh');\n            }\n        });\n    }\n    \n    var postit = function(){\n        new Pman.Request({\n            url : baseURL + '/Roo/Bankrec.php',\n            method :'POST',\n            params : {\n                _post : 1,\n                bankaccnt_id : _this.bankacct.getValue(),\n                sotrdate : rec.data.sortdate\n                \n            },\n            success : function() {\n                _this.wgrid.footer.onClick('refresh');\n            }\n        });\n    \n    }\n    \n    if(rec.data.is_reconciled == 1){\n        voidit();\n        return;\n    }\n    \n    postit();\n    return;\n    \n    \n    \n}",
332                                         "rowclick": "function (_self, rowIndex, e)\n{\n    \n     _this.wgrid.lastSelectedRow = rowIndex;\n    \n}"
333                                     },
334                                     "*prop": "grid",
335                                     "autoExpandColumn": "sortdate",
336                                     "loadMask": true,
337                                     "xtype": "Grid",
338                                     "|xns": "Roo.grid",
339                                     "items": [
340                                         {
341                                             "|xns": "Roo",
342                                             "xtype": "Toolbar",
343                                             "*prop": "toolbar",
344                                             "items": [
345                                                 {
346                                                     "listeners": {
347                                                         "render": "function (_self)\n{\n    _this.monthSel = _self;\n}",
348                                                         "select": "function (combo, date)\n{\n    _this.grid.ds.removeAll();\n    _this.wgrid.footer.onClick('first');\n}"
349                                                     },
350                                                     "allowBlank": true,
351                                                     "format": "M Y",
352                                                     "useIso": true,
353                                                     "width": 150,
354                                                     "xtype": "MonthField",
355                                                     "|xns": "Roo.form"
356                                                 },
357                                                 {
358                                                     "listeners": {
359                                                         "click": "function (_self, e)\n{\n    _this.monthSel.setValue('');\n    _this.grid.ds.removeAll();\r\n    _this.wgrid.footer.onClick('first');\r\n}"
360                                                     },
361                                                     "cls": "x-btn-icon",
362                                                     "xtype": "Button",
363                                                     "|icon": "rootURL + '/Pman/templates/images/edit-clear.gif'",
364                                                     "|xns": "Roo.Toolbar"
365                                                 },
366                                                 {
367                                                     "|xns": "Roo.Toolbar",
368                                                     "xtype": "Fill"
369                                                 },
370                                                 {
371                                                     "cls": "x-btn-text-icon",
372                                                     "text": "Fix Data",
373                                                     "xtype": "Button",
374                                                     "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'",
375                                                     "|xns": "Roo.Toolbar",
376                                                     "items": [
377                                                         {
378                                                             "*prop": "menu",
379                                                             "xtype": "Menu",
380                                                             "|xns": "Roo.menu",
381                                                             "items": [
382                                                                 {
383                                                                     "listeners": {
384                                                                         "click": "function (_self, e)\n{\n\n    Roo.MessageBox.confirm(\"Confirm\", \"Are you sure you want to fix all the historical data? It will recreate all the posted bankrec and delect all the unpost\",\n        function (res) {\n            if(res!='yes') {\n                return;\n            \n            }\n            new Pman.Request({\n                url : baseURL + '/Roo/Bankrec.php',\n                method :'POST',\n                params : {\n                    _fix : 1\n                },\n                success : function() {\n                    if(_this.wgrid){\n                        _this.wgrid.footer.onClick('refresh');\n                    }\n                    Roo.MessageBox.alert('Notice', 'FIXED');\n                }\n            });\n    });\n\n}"
385                                                                     },
386                                                                     "cls": "x-btn-text-icon",
387                                                                     "text": "Fix historical data",
388                                                                     "xtype": "Item",
389                                                                     "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'",
390                                                                     "|xns": "Roo.menu"
391                                                                 },
392                                                                 {
393                                                                     "listeners": {
394                                                                         "click": "function (_self, e)\n{\n\n    Roo.MessageBox.confirm(\"Confirm\", \"Are you sure you want?\",\n        function (res) {\n            if(res!='yes') {\n                return;\n            \n            }\n            new Pman.Request({\n                url : baseURL + '/Roo/Bankrec.php',\n                method :'POST',\n                params : {\n                    _closedPeriod : 1\n                },\n                success : function() {\n                    if(_this.wgrid){\n                        _this.wgrid.footer.onClick('refresh');\n                    }\n                    Roo.MessageBox.alert('Notice', 'DONE');\n                }\n            });\n    });\n\n}"
395                                                                     },
396                                                                     "cls": "x-btn-text-icon",
397                                                                     "text": "Fix Closed Periods",
398                                                                     "xtype": "Item",
399                                                                     "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'",
400                                                                     "|xns": "Roo.menu"
401                                                                 }
402                                                             ]
403                                                         }
404                                                     ]
405                                                 }
406                                             ]
407                                         },
408                                         {
409                                             "listeners": {
410                                                 "selectionchange": "function (_self)\n{\n    _this.grid.footer.onClick('first');\n}"
411                                             },
412                                             "*prop": "sm",
413                                             "singleSelect": true,
414                                             "xtype": "RowSelectionModel",
415                                             "|xns": "Roo.grid"
416                                         },
417                                         {
418                                             "listeners": {
419                                                 "beforeload": "function (_self, o)\n{\n\n    if (!_this.bankacct.getValue()) {\n        return false;\n    }\n    var dt = _this.monthSel.getValue();\n    \n    if(dt.length){\n        o.params['sortdate:text'] = typeof(dt) == 'string' ? dt : dt.format('Y-m-d');\n    }\n    o.params._group = 'bankrec';\n    o.params._name = 'bydate';\n    o.params['bankaccntid:number'] =  _this.bankacct.getValue();\n    \n\n    \n}",
420                                                 "load": "function (_self, records, options, res)\n{   \n    var sm = _this.wgrid.getSelectionModel();\n    \n    if(_this.wgrid.lastSelectedRow * 1 >0){\n        sm.selectRow(_this.wgrid.lastSelectedRow);\n        return;\n    }\n    \n    if (!sm.getSelections().length) {\n        sm.selectFirstRow();\n    }\n\n}"
421                                             },
422                                             "*prop": "dataSource",
423                                             "remoteSort": true,
424                                             "xtype": "Store",
425                                             "|sortInfo": "{ field : 'sotrdate', direction: 'ASC' }",
426                                             "|xns": "Roo.data",
427                                             "items": [
428                                                 {
429                                                     "*prop": "proxy",
430                                                     "method": "GET",
431                                                     "timeout": 900000,
432                                                     "xtype": "HttpProxy",
433                                                     "|url": "baseURL + '/Roo/metasql.php'",
434                                                     "|xns": "Roo.data"
435                                                 },
436                                                 {
437                                                     "*prop": "reader",
438                                                     "id": "id",
439                                                     "root": "data",
440                                                     "totalProperty": "total",
441                                                     "xtype": "JsonReader",
442                                                     "|fields": "[\n    {\n        'name': 'sortdate',\n        'type': 'string'\n    }\n]",
443                                                     "|xns": "Roo.data"
444                                                 }
445                                             ]
446                                         },
447                                         {
448                                             "*prop": "footer",
449                                             "displayInfo": false,
450                                             "displayMsg": "Displaying Date{0} - {1} of {2}",
451                                             "emptyMsg": "No Date found",
452                                             "pageSize": 25,
453                                             "xtype": "PagingToolbar",
454                                             "|xns": "Roo"
455                                         },
456                                         {
457                                             "*prop": "colModel[]",
458                                             "dataIndex": "sortdate",
459                                             "header": "Date",
460                                             "width": 100,
461                                             "xtype": "ColumnModel",
462                                             "|renderer": "function(v) {   \n\n    return v ? Date.parseDate(v,'Y-m-d').format('d/M/Y') : '';\n }",
463                                             "|xns": "Roo.grid"
464                                         },
465                                         {
466                                             "*prop": "colModel[]",
467                                             "align": "right",
468                                             "dataIndex": "balance",
469                                             "header": "Closing Balance",
470                                             "width": 120,
471                                             "xtype": "ColumnModel",
472                                             "|renderer": "function(v,x,r) { \n    \n    var color = 'red'; // has some not 'ticked'\n    \n    if(r.data.no_records - r.data.no_posted == 0){ // all posted on that date\n        color = 'black';\n    }\n    if(r.data.no_records - r.data.no_cleared == 0 && r.data.no_posted != r.data.no_cleared){ // has 'ticked' or posted\n        color = 'blue';\n    }\n    \n    return String.format('<span style=\"color:{0}\">{1}</span>', color, Roo.util.Format.number(v*1,2)); \n}",
473                                             "|xns": "Roo.grid"
474                                         },
475                                         {
476                                             "*prop": "colModel[]",
477                                             "align": "right",
478                                             "dataIndex": "reconciled",
479                                             "header": "Reconciled",
480                                             "width": 100,
481                                             "xtype": "ColumnModel",
482                                             "|renderer": "function(v,x,r) { \n    \n    if(!v){\n        return '';\n    }\n    \n    if((r.data.no_records * 1 != r.data.no_posted * 1) || r.data.balance * 1 != v * 1){ // not match\n        \n        return '<span style=\"color:red;font-weight:bold\">' + Roo.util.Format.number(v*1,2); \n    }\n    \n    return String.format('<span style=\"color:black\">{0}</span>', Roo.util.Format.number(v*1,2)); \n        \n }",
483                                             "|xns": "Roo.grid"
484                                         },
485                                         {
486                                             "*prop": "colModel[]",
487                                             "align": "right",
488                                             "dataIndex": "is_reconciled",
489                                             "header": "Post?",
490                                             "width": 50,
491                                             "xtype": "ColumnModel",
492                                             "|renderer": "function(v,x,r) { \n    var state = v  ?  '-checked' : '';\n\n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n }\n \n",
493                                             "|xns": "Roo.grid"
494                                         }
495                                     ]
496                                 }
497                             ]
498                         }
499                     ]
500                 }
501             ]
502         }
503     ],
504     "permname": "",
505     "modOrder": "105"
506 }