- "xtype" : "BorderLayout",
- "$ xns" : "Roo",
- "* prop" : "layout",
- "items" : [
- {
- "xtype" : "LayoutRegion",
- "$ xns" : "Roo",
- "* prop" : "center"
- },
- {
- "xtype" : "LayoutRegion",
- "width" : 400,
- "$ xns" : "Roo",
- "split" : true,
- "* prop" : "west"
- },
- {
- "listeners" : {
- "|activate" : "function() {\n _this.panel = this;\n if (_this.grid) {\n _this.grid.footer.onClick('first');\n }\n}"
- },
- "fitToframe" : true,
- "background" : true,
- "region" : "center",
- "title" : "Bank Reconcile",
- "xtype" : "GridPanel",
- "fitContainer" : true,
- "$ xns" : "Roo",
- "tableName" : "metasql",
- "items" : [
- {
- "listeners" : {
- "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}",
- "|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}",
- "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}",
- "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}"
- },
- "autoExpandColumn" : "notes",
- "xtype" : "EditorGrid",
- "loadMask" : true,
- "clicksToEdit" : 1,
- "$ xns" : "Roo.grid",
- "* prop" : "grid",
- "items" : [
- {
- "listeners" : {
- "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",
- "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}",
- "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}"
- },
- "xtype" : "Store",
- "remoteSort" : true,
- "$ sortInfo" : "{ field : 'metasql_group', direction: 'ASC' }",
- "$ xns" : "Roo.data",
- "$ 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",
- "* prop" : "dataSource",
- "items" : [
- {
- "$ url" : "baseURL + '/Roo/metasql.php'",
- "xtype" : "HttpProxy",
- "method" : "GET",
- "$ xns" : "Roo.data",
- "* prop" : "proxy"
- },
- {
- "id" : "idx",
- "root" : "data",
- "xtype" : "JsonReader",
- "$ 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]",
- "$ xns" : "Roo.data",
- "* prop" : "reader",
- "totalProperty" : "total"
- }
- ]
- },
- {
- "pageSize" : 50,
- "xtype" : "PagingToolbar",
- "emptyMsg" : "Nothing found",
- "$ xns" : "Roo",
- "displayMsg" : "Displaying records {0} - {1} of {2}",
- "displayInfo" : true,
- "* prop" : "footer"
- },
- {
- "xtype" : "Toolbar",
- "$ xns" : "Roo",
- "* prop" : "toolbar",
- "items" : [
- {
- "listeners" : {
- "render" : "function (_self)\n{\n _this.bankacct = _self;\n}",
- "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}"
- },
- "listWidth" : 400,
- "triggerAction" : "all",
- "fieldLabel" : "bankaccnt",
- "forceSelection" : true,
- "selectOnFocus" : true,
- "pageSize" : 50,
- "displayField" : "bankaccnt_bankname",
- "emptyText" : "Select bankaccnt",
- "hiddenName" : "bankaccnt_id",
- "minChars" : 2,
- "valueField" : "bankaccnt_id",
- "xtype" : "ComboBox",
- "allowBlank" : false,
- "typeAhead" : true,
- "editable" : false,
- "width" : 300,
- "$ xns" : "Roo.form",
- "name" : "bankaccnt_bankname",
- "qtip" : "Select bankaccnt",
- "queryParam" : "",
- "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{bankaccnt_bankname}</b> </div>",
- "loadingText" : "Searching...",
- "items" : [
- {
- "listeners" : {
- "|beforeload" : "function (_self, o){\n o.params = o.params || {};\n // set more here\n}\n"
- },
- "xtype" : "Store",
- "remoteSort" : true,
- "$ sortInfo" : "{ direction : 'ASC', field: 'bankaccnt_bankname' }",
- "$ xns" : "Roo.data",
- "* prop" : "store",
- "items" : [
- {
- "$ url" : "baseURL + '/Roo/bankaccnt.php'",
- "method" : "GET",
- "xtype" : "HttpProxy",
- "$ xns" : "Roo.data",
- "* prop" : "proxy"
- },
- {
- "id" : "id",
- "root" : "data",
- "xtype" : "JsonReader",
- "$ xns" : "Roo.data",
- "$ fields" : "[{\"name\":\"id\",\"type\":\"int\"},{\"name\":\"bankaccnt_name\",\"type\":\"string\"}]",
- "* prop" : "reader",
- "totalProperty" : "total"
- }
- ]
- }
- ]
- },
- {
- "listeners" : {
- "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}"
- },
- "text" : "Download",
- "xtype" : "Button",
- "$ xns" : "Roo.Toolbar"
- },
- {
- "xtype" : "Fill",
- "$ xns" : "Roo.Toolbar"
- }
- ]
- },
- {
- "xtype" : "ColumnModel",
- "header" : "Cleared",
- "width" : 50,
- "$ 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 }",
- "$ xns" : "Roo.grid",
- "* prop" : "colModel[]",
- "dataIndex" : "cleared"
- },
- {
- "xtype" : "ColumnModel",
- "header" : "Date",
- "width" : 75,
- "$ renderer" : "function(v) { \n\n return v ? Date.parseDate(v,'Y-m-d').format('d/M/Y') : '';\n }",
- "$ xns" : "Roo.grid",
- "* prop" : "colModel[]",
- "dataIndex" : "sortdate"
- },
- {
- "xtype" : "ColumnModel",
- "header" : "Doctype",
- "width" : 50,
- "$ renderer" : "function(v) { return String.format('{0}', v); }",
- "$ xns" : "Roo.grid",
- "* prop" : "colModel[]",
- "dataIndex" : "doc_type"
- },
- {
- "xtype" : "ColumnModel",
- "header" : "Doc Number",
- "width" : 120,
- "$ renderer" : "function(v) { return String.format('{0}', v); }",
- "$ xns" : "Roo.grid",
- "* prop" : "colModel[]",
- "dataIndex" : "doc_number"
- },
- {
- "xtype" : "ColumnModel",
- "header" : "Notes",
- "width" : 200,
- "$ renderer" : "function(v) { return String.format('{0}', v); }",
- "$ xns" : "Roo.grid",
- "* prop" : "colModel[]",
- "dataIndex" : "notes"
- },
- {
- "xtype" : "ColumnModel",
- "header" : "Currency",
- "width" : 75,
- "$ renderer" : "function(v) { return String.format('{0}', v); }",
- "$ xns" : "Roo.grid",
- "* prop" : "colModel[]",
- "dataIndex" : "doc_curr"
- },
- {
- "align" : "right",
- "xtype" : "ColumnModel",
- "header" : "Exchange Rate",
- "width" : 75,
- "$ renderer" : "function(v) { return String.format('{0}', v ? (v*1).toFixed(3) : ''); }",
- "$ xns" : "Roo.grid",
- "* prop" : "colModel[]",
- "dataIndex" : "doc_exchrate"
- },
- {
- "align" : "right",
- "xtype" : "ColumnModel",
- "header" : "Base Amount",
- "width" : 120,
- "$ renderer" : "function(v) { return String.format('{0}', Roo.util.Format.number(v*1,2)); }",
- "$ xns" : "Roo.grid",
- "* prop" : "colModel[]",
- "dataIndex" : "base_amount"
- },
- {
- "align" : "right",
- "xtype" : "ColumnModel",
- "header" : "Credit",
- "width" : 120,
- "$ 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) : ''); }",
- "$ xns" : "Roo.grid",
- "* prop" : "colModel[]",
- "dataIndex" : "amount",
- "items" : [
- {
- "xtype" : "GridEditor",
- "$ xns" : "Roo.grid",
- "* prop" : "editor",
- "items" : [
- {
- "xtype" : "NumberField",
- "cls" : "align-right",
- "decimalPrecision" : 2,
- "$ xns" : "Roo.form",
- "* prop" : "field"
- }
- ]
- }
- ]
- },
- {
- "align" : "right",
- "xtype" : "ColumnModel",
- "header" : "Debit",
- "width" : 120,
- "$ 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): ''); }",
- "$ xns" : "Roo.grid",
- "* prop" : "colModel[]",
- "dataIndex" : "amount",
- "items" : [
- {
- "xtype" : "GridEditor",
- "$ xns" : "Roo.grid",
- "* prop" : "editor",
- "items" : [
- {
- "xtype" : "NumberField",
- "cls" : "align-right",
- "decimalPrecision" : 2,
- "$ xns" : "Roo.form",
- "* prop" : "field"
- }
- ]
- }
- ]
- },
- {
- "align" : "right",
- "xtype" : "ColumnModel",
- "header" : "Balance",
- "width" : 120,
- "$ 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}",
- "$ xns" : "Roo.grid",
- "* prop" : "colModel[]",
- "dataIndex" : "balance"
- }
- ]
- }
- ]
- },
- {
- "listeners" : {
- "|activate" : "function() {\n _this.wpanel = this;\n //if (_this.wgrid) {\n // _this.wgrid.footer.onClick('first');\n //}\n}"
- },
- "fitToframe" : true,
- "background" : true,
- "region" : "west",
- "title" : "Pick a Date",
- "xtype" : "GridPanel",
- "fitContainer" : true,
- "$ xns" : "Roo",
- "tableName" : "Groups",
- "items" : [
- {
- "listeners" : {
- "|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}",
- "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}",
- "rowclick" : "function (_self, rowIndex, e)\n{\n \n _this.wgrid.lastSelectedRow = rowIndex;\n \n}"
- },
- "autoExpandColumn" : "sortdate",
- "xtype" : "Grid",
- "loadMask" : true,
- "$ xns" : "Roo.grid",
- "* prop" : "grid",
- "items" : [
- {
- "xtype" : "Toolbar",
- "$ xns" : "Roo",
- "* prop" : "toolbar",
- "items" : [
- {
- "listeners" : {
- "render" : "function (_self)\n{\n _this.monthSel = _self;\n}",
- "select" : "function (combo, date)\n{\n _this.grid.ds.removeAll();\n _this.wgrid.footer.onClick('first');\n}"
- },
- "format" : "M Y",
- "useIso" : true,
- "xtype" : "MonthField",
- "allowBlank" : true,
- "width" : 150,
- "$ xns" : "Roo.form"
- },
- {
- "listeners" : {
- "click" : "function (_self, e)\n{\n _this.monthSel.setValue('');\n _this.grid.ds.removeAll();\r\n _this.wgrid.footer.onClick('first');\r\n}"
- },
- "xtype" : "Button",
- "cls" : "x-btn-icon",
- "$ icon" : "rootURL + '/Pman/templates/images/edit-clear.gif'",
- "$ xns" : "Roo.Toolbar"
- },
- {
- "xtype" : "Fill",
- "$ xns" : "Roo.Toolbar"
- },
- {
- "text" : "Fix Data",
- "xtype" : "Button",
- "cls" : "x-btn-text-icon",
- "$ icon" : "Roo.rootURL + 'images/default/tree/leaf.gif'",
- "$ xns" : "Roo.Toolbar",
- "items" : [
- {
- "xtype" : "Menu",
- "$ xns" : "Roo.menu",
- "* prop" : "menu",
- "items" : [
- {
- "listeners" : {
- "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}"
- },
- "text" : "Fix historical data",
- "xtype" : "Item",
- "cls" : "x-btn-text-icon",
- "$ icon" : "Roo.rootURL + 'images/default/tree/leaf.gif'",
- "$ xns" : "Roo.menu"
- },
- {
- "listeners" : {
- "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}"
- },
- "text" : "Fix Closed Periods",
- "xtype" : "Item",
- "cls" : "x-btn-text-icon",
- "$ icon" : "Roo.rootURL + 'images/default/tree/leaf.gif'",
- "$ xns" : "Roo.menu"
- }
- ]
- }
- ]
- }
- ]
- },
- {
- "listeners" : {
- "selectionchange" : "function (_self)\n{\n _this.grid.footer.onClick('first');\n}"
- },
- "xtype" : "RowSelectionModel",
- "singleSelect" : true,
- "$ xns" : "Roo.grid",
- "* prop" : "sm"
- },
- {
- "listeners" : {
- "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}",
- "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}"
- },
- "xtype" : "Store",
- "remoteSort" : true,
- "$ sortInfo" : "{ field : 'sotrdate', direction: 'ASC' }",
- "$ xns" : "Roo.data",
- "* prop" : "dataSource",
- "items" : [
- {
- "$ url" : "baseURL + '/Roo/metasql.php'",
- "method" : "GET",
- "xtype" : "HttpProxy",
- "timeout" : 900000,
- "$ xns" : "Roo.data",
- "* prop" : "proxy"
- },
- {
- "id" : "id",
- "root" : "data",
- "xtype" : "JsonReader",
- "$ fields" : "[\n {\n 'name': 'sortdate',\n 'type': 'string'\n }\n]",
- "$ xns" : "Roo.data",
- "* prop" : "reader",
- "totalProperty" : "total"
- }
- ]
- },
- {
- "pageSize" : 25,
- "xtype" : "PagingToolbar",
- "emptyMsg" : "No Date found",
- "$ xns" : "Roo",
- "displayMsg" : "Displaying Date{0} - {1} of {2}",
- "displayInfo" : false,
- "* prop" : "footer"
- },
- {
- "xtype" : "ColumnModel",
- "header" : "Date",
- "width" : 100,
- "$ renderer" : "function(v) { \n\n return v ? Date.parseDate(v,'Y-m-d').format('d/M/Y') : '';\n }",
- "$ xns" : "Roo.grid",
- "* prop" : "colModel[]",
- "dataIndex" : "sortdate"
- },
- {
- "align" : "right",
- "xtype" : "ColumnModel",
- "header" : "Closing Balance",
- "width" : 120,
- "$ 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}",
- "$ xns" : "Roo.grid",
- "* prop" : "colModel[]",
- "dataIndex" : "balance"
- },
- {
- "align" : "right",
- "xtype" : "ColumnModel",
- "header" : "Reconciled",
- "width" : 100,
- "$ 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 }",
- "$ xns" : "Roo.grid",
- "* prop" : "colModel[]",
- "dataIndex" : "reconciled"
- },
- {
- "align" : "right",
- "xtype" : "ColumnModel",
- "header" : "Post?",
- "width" : 50,
- "$ 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",
- "$ xns" : "Roo.grid",
- "* prop" : "colModel[]",
- "dataIndex" : "is_reconciled"
- }
- ]
- }
- ]
- }
- ]
+ "$ url" : "baseURL + '/Roo/bankaccnt.php'",
+ "xtype" : "HttpProxy",
+ "method" : "GET",
+ "$ xns" : "Roo.data",
+ "* prop" : "proxy"
+ },
+ {
+ "id" : "id",
+ "root" : "data",
+ "xtype" : "JsonReader",
+ "$ xns" : "Roo.data",
+ "$ fields" : "[{\"name\":\"id\",\"type\":\"int\"},{\"name\":\"bankaccnt_name\",\"type\":\"string\"}]",
+ "* prop" : "reader",
+ "totalProperty" : "total"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "listeners" : {
+ "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}"
+ },
+ "text" : "Download",
+ "xtype" : "Button",
+ "$ xns" : "Roo.Toolbar"
+ },
+ {
+ "xtype" : "Fill",
+ "$ xns" : "Roo.Toolbar"
+ }
+ ]
+ },
+ {
+ "xtype" : "ColumnModel",
+ "width" : 50,
+ "header" : "Cleared",
+ "$ 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 }",
+ "$ xns" : "Roo.grid",
+ "* prop" : "colModel[]",
+ "dataIndex" : "cleared"
+ },
+ {
+ "xtype" : "ColumnModel",
+ "width" : 75,
+ "header" : "Date",
+ "$ renderer" : "function(v) { \n\n return v ? Date.parseDate(v,'Y-m-d').format('d/M/Y') : '';\n }",
+ "$ xns" : "Roo.grid",
+ "* prop" : "colModel[]",
+ "dataIndex" : "sortdate"
+ },
+ {
+ "xtype" : "ColumnModel",
+ "width" : 50,
+ "header" : "Doctype",
+ "$ renderer" : "function(v) { return String.format('{0}', v); }",
+ "$ xns" : "Roo.grid",
+ "* prop" : "colModel[]",
+ "dataIndex" : "doc_type"
+ },
+ {
+ "xtype" : "ColumnModel",
+ "width" : 120,
+ "header" : "Doc Number",
+ "$ renderer" : "function(v) { return String.format('{0}', v); }",
+ "$ xns" : "Roo.grid",
+ "* prop" : "colModel[]",
+ "dataIndex" : "doc_number"
+ },
+ {
+ "xtype" : "ColumnModel",
+ "width" : 200,
+ "header" : "Notes",
+ "$ renderer" : "function(v) { return String.format('{0}', v); }",
+ "$ xns" : "Roo.grid",
+ "* prop" : "colModel[]",
+ "dataIndex" : "notes"
+ },
+ {
+ "xtype" : "ColumnModel",
+ "width" : 75,
+ "header" : "Currency",
+ "$ renderer" : "function(v) { return String.format('{0}', v); }",
+ "$ xns" : "Roo.grid",
+ "* prop" : "colModel[]",
+ "dataIndex" : "doc_curr"
+ },
+ {
+ "align" : "right",
+ "xtype" : "ColumnModel",
+ "header" : "Exchange Rate",
+ "width" : 75,
+ "$ renderer" : "function(v) { return String.format('{0}', v ? (v*1).toFixed(3) : ''); }",
+ "$ xns" : "Roo.grid",
+ "* prop" : "colModel[]",
+ "dataIndex" : "doc_exchrate"
+ },
+ {
+ "align" : "right",
+ "xtype" : "ColumnModel",
+ "header" : "Base Amount",
+ "width" : 120,
+ "$ renderer" : "function(v) { return String.format('{0}', Roo.util.Format.number(v*1,2)); }",
+ "$ xns" : "Roo.grid",
+ "* prop" : "colModel[]",
+ "dataIndex" : "base_amount"
+ },
+ {
+ "align" : "right",
+ "xtype" : "ColumnModel",
+ "header" : "Credit",
+ "width" : 120,
+ "$ 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) : ''); }",
+ "$ xns" : "Roo.grid",
+ "* prop" : "colModel[]",
+ "dataIndex" : "amount",
+ "items" : [
+ {
+ "xtype" : "GridEditor",
+ "$ xns" : "Roo.grid",
+ "* prop" : "editor",
+ "items" : [
+ {
+ "xtype" : "NumberField",
+ "cls" : "align-right",
+ "decimalPrecision" : 2,
+ "$ xns" : "Roo.form",
+ "* prop" : "field"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "align" : "right",
+ "xtype" : "ColumnModel",
+ "header" : "Debit",
+ "width" : 120,
+ "$ 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): ''); }",
+ "$ xns" : "Roo.grid",
+ "* prop" : "colModel[]",
+ "dataIndex" : "amount",
+ "items" : [
+ {
+ "xtype" : "GridEditor",
+ "$ xns" : "Roo.grid",
+ "* prop" : "editor",
+ "items" : [
+ {
+ "xtype" : "NumberField",
+ "cls" : "align-right",
+ "decimalPrecision" : 2,
+ "$ xns" : "Roo.form",
+ "* prop" : "field"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "align" : "right",
+ "xtype" : "ColumnModel",
+ "header" : "Balance",
+ "width" : 120,
+ "$ 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}",
+ "$ xns" : "Roo.grid",
+ "* prop" : "colModel[]",
+ "dataIndex" : "balance"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "listeners" : {
+ "|activate" : "function() {\n _this.wpanel = this;\n //if (_this.wgrid) {\n // _this.wgrid.footer.onClick('first');\n //}\n}"
+ },
+ "region" : "west",
+ "fitToframe" : true,
+ "background" : true,
+ "title" : "Pick a Date",
+ "xtype" : "GridPanel",
+ "fitContainer" : true,
+ "$ xns" : "Roo",
+ "tableName" : "Groups",
+ "items" : [
+ {
+ "listeners" : {
+ "|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}",
+ "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}",
+ "rowclick" : "function (_self, rowIndex, e)\n{\n \n _this.wgrid.lastSelectedRow = rowIndex;\n \n}"
+ },
+ "autoExpandColumn" : "sortdate",
+ "xtype" : "Grid",
+ "loadMask" : true,
+ "$ xns" : "Roo.grid",
+ "* prop" : "grid",
+ "items" : [
+ {
+ "xtype" : "Toolbar",
+ "$ xns" : "Roo",
+ "* prop" : "toolbar",
+ "items" : [
+ {
+ "listeners" : {
+ "render" : "function (_self)\n{\n _this.monthSel = _self;\n}",
+ "select" : "function (combo, date)\n{\n _this.grid.ds.removeAll();\n _this.wgrid.footer.onClick('first');\n}"
+ },
+ "format" : "M Y",
+ "xtype" : "MonthField",
+ "useIso" : true,
+ "allowBlank" : true,
+ "width" : 150,
+ "$ xns" : "Roo.form"
+ },
+ {
+ "listeners" : {
+ "click" : "function (_self, e)\n{\n _this.monthSel.setValue('');\n _this.grid.ds.removeAll();\r\n _this.wgrid.footer.onClick('first');\r\n}"
+ },
+ "xtype" : "Button",
+ "cls" : "x-btn-icon",
+ "$ icon" : "rootURL + '/Pman/templates/images/edit-clear.gif'",
+ "$ xns" : "Roo.Toolbar"
+ },
+ {
+ "xtype" : "Fill",
+ "$ xns" : "Roo.Toolbar"
+ },
+ {
+ "text" : "Fix Data",
+ "xtype" : "Button",
+ "cls" : "x-btn-text-icon",
+ "$ icon" : "Roo.rootURL + 'images/default/tree/leaf.gif'",
+ "$ xns" : "Roo.Toolbar",
+ "items" : [
+ {
+ "xtype" : "Menu",
+ "$ xns" : "Roo.menu",
+ "* prop" : "menu",
+ "items" : [
+ {
+ "listeners" : {
+ "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}"
+ },
+ "text" : "Fix historical data",
+ "xtype" : "Item",
+ "cls" : "x-btn-text-icon",
+ "$ icon" : "Roo.rootURL + 'images/default/tree/leaf.gif'",
+ "$ xns" : "Roo.menu"
+ },
+ {
+ "listeners" : {
+ "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}"
+ },
+ "text" : "Fix Closed Periods",
+ "xtype" : "Item",
+ "cls" : "x-btn-text-icon",
+ "$ icon" : "Roo.rootURL + 'images/default/tree/leaf.gif'",
+ "$ xns" : "Roo.menu"