{ "name" : "Pman.Tab.XtuplePeriods", "parent" : "Pman.Tab.XtupleAccountsTab", "title" : "", "path" : "/home/edward/gitlive/web.xtuple/Pman/Xtuple/Pman.Tab.XtuplePeriods.bjs", "permname" : "", "modOrder" : "300", "items" : [ { "fitToFrame" : true, "background" : true, "region" : "center", "title" : "Periods", "xtype" : "NestedLayoutPanel", "fitContainer" : true, "$ xns" : "Roo", "items" : [ { "xtype" : "BorderLayout", "$ xns" : "Roo", "* prop" : "layout", "items" : [ { "title" : "Periods", "xtype" : "LayoutRegion", "tabPosition" : "top", "$ xns" : "Roo", "* prop" : "center", "titlebar" : false }, { "title" : "Year Periods", "xtype" : "LayoutRegion", "tabPosition" : "top", "width" : 400, "$ xns" : "Roo", "split" : true, "* prop" : "west", "titlebar" : false }, { "listeners" : { "|activate" : "function() {\n _this.wpanel = this;\n if (_this.wgrid) {\n _this.wgrid.ds.load({});\n }\n}" }, "fitToframe" : true, "background" : true, "region" : "west", "title" : "Year Periods", "xtype" : "GridPanel", "fitContainer" : true, "$ xns" : "Roo", "tableName" : "yearperiod", "items" : [ { "listeners" : { "cellclick" : "function (_self, rowIndex, columnIndex, e)\n{\n\n var di = this.colModel.getDataIndex(columnIndex);\n\n if (di != 'yearperiod_closed') {\n return;\n }\n\n var rec = this.ds.getAt(rowIndex);\n\n\n var open = function(){\n new Pman.Request({\n url : baseURL + '/Roo/Yearperiod.php',\n timeout: 600000,\n mask : 'Processing',\n method : 'POST',\n params : {\n yearperiod_id : rec.data.yearperiod_id,\n _open : 1\n \n }, \n success : function() {\n _this.wgrid.ds.load({});\n }\n }); \n };\n \n var close = function(){\n new Pman.Request({\n url : baseURL + '/Roo/Yearperiod.php',\n timeout: 600000,\n mask : 'Processing',\n method : 'POST',\n params : {\n yearperiod_id : rec.data.yearperiod_id,\n _close : 1\n \n }, \n success : function() {\n _this.wgrid.ds.load({});\n }\n }); \n };\n \n if(rec.data.yearperiod_id * 1 < 1){\n Roo.MessageBox.alert('Error', 'Please select a period?');\n return;\n }\n\n //Roo.log(rec.data);\n if(rec.data.yearperiod_closed *1){\n Roo.MessageBox.confirm(\"Confirm\", \"Are you sure want to open this year period?\" , function(r) {\n if (r !='yes') {\n return;\n }\n open();\n \n });\n return;\n }\n \n \n\n \n Roo.MessageBox.confirm(\"Confirm\", \"Are you sure want to close this year period?\" , function(r) {\n if (r !='yes') {\n return;\n }\n close();\n \n })\n \n \n \n \n}", "|render" : "function() \n{\n _this.wgrid = this; \n //_this.dialog = Pman.Dialog.FILL_IN\n if (_this.wpanel.active) {\n this.ds.load({});\n }\n}", "rowclick" : "function (_self, rowIndex, e)\n{\n _this.grid.ds.load({});\n}" }, "autoExpandColumn" : "yearperiod_start", "xtype" : "Grid", "loadMask" : true, "$ xns" : "Roo.grid", "* prop" : "grid", "items" : [ { "xtype" : "RowSelectionModel", "singleSelect" : true, "$ xns" : "Roo.grid", "* prop" : "sm" }, { "xtype" : "Store", "remoteSort" : true, "$ sortInfo" : "{ field : 'yearperiod_start', direction: 'ASC' }", "$ xns" : "Roo.data", "* prop" : "dataSource", "items" : [ { "$ url" : "baseURL + '/Roo/Yearperiod.php'", "xtype" : "HttpProxy", "method" : "GET", "$ xns" : "Roo.data", "* prop" : "proxy" }, { "id" : "id", "root" : "data", "xtype" : "JsonReader", "$ fields" : "[\n {\n 'name': 'yearperiod_id',\n 'type': 'int'\n },\n {\n 'name': 'yearperiod_name',\n 'type': 'string'\n }\n]", "$ xns" : "Roo.data", "* prop" : "reader", "totalProperty" : "total" } ] }, { "xtype" : "ColumnModel", "header" : "Name", "width" : 100, "$ renderer" : "function(v,x,r) \n{ \n v = r.data.yearperiod_start.getFullYear() + '-' + r.data.yearperiod_end.getFullYear();\n \n return String.format('{0}', v ? v : ''); \n}", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "yearperiod_name" }, { "xtype" : "ColumnModel", "sortable" : true, "header" : "Start", "width" : 100, "$ renderer" : "function(v) { return String.format('{0}', v ? v.format('Y-m-d') : ''); }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "yearperiod_start" }, { "xtype" : "ColumnModel", "sortable" : true, "header" : "End", "width" : 100, "$ renderer" : "function(v) { return String.format('{0}', v ? v.format('Y-m-d') : ''); }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "yearperiod_end" }, { "xtype" : "ColumnModel", "sortable" : true, "header" : "Closed", "width" : 75, "$ renderer" : "function(v) { \n var state = v ? '-checked' : '';\n\n return '';\n \n }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "yearperiod_closed" } ] } ] }, { "listeners" : { "|activate" : "function() {\n _this.panel = this;\n}" }, "fitToframe" : true, "background" : true, "region" : "center", "title" : "Periods", "xtype" : "GridPanel", "fitContainer" : true, "$ xns" : "Roo", "tableName" : "period", "items" : [ { "listeners" : { "beforeedit" : "function (e)\n{\n if(e.field != 'period_name'){\n return false;\n }\n}", "|render" : "function() \n{\n _this.grid = this; \n}", "cellclick" : "function (_self, rowIndex, columnIndex, e)\n{\n\n var di = this.colModel.getDataIndex(columnIndex);\n\n if (di != 'period_closed' && di != 'period_freeze') {\n return;\n }\n\n var rec = _this.grid.ds.getAt(rowIndex);\n \n if(rec.data.period_id * 1 < 1){\n Roo.MessageBox.alert('Error', 'Error occur on getting the period id');\n return;\n }\n \n var action = rec.data[di] ? 'thaw' : 'freeze';\n \n if(di == 'period_closed'){\n action = rec.data[di] ? 'open' : 'close';\n }\n \n new Pman.Request({\n url : baseURL + '/Roo/Period.php',\n timeout: 600000,\n mask : 'Processing',\n method : 'POST',\n params : {\n period_id : rec.data.period_id,\n _action : action\n \n }, \n success : function() {\n _this.grid.ds.load({});\n }\n }); \n \n}", "afteredit" : "function (e)\n{\n if(e.field != 'period_name' || e.originalValue == e.value){\n return;\n }\n \n if(e.record.data.period_id * 1 < 1){\n Roo.MessageBox.alert('Error', 'Error occur on getting the period id');\n return;\n }\n \n new Pman.Request({\n url : baseURL + '/Roo/Period.php',\n method : 'POST',\n params : {\n period_id : e.record.data.period_id,\n period_name : e.record.data.period_name\n \n }, \n success : function() {\n _this.grid.ds.load({});\n }\n });\n}" }, "autoExpandColumn" : "period_name", "xtype" : "EditorGrid", "loadMask" : true, "clicksToEdit" : 2, "$ xns" : "Roo.grid", "* prop" : "grid", "items" : [ { "xtype" : "Toolbar", "$ xns" : "Roo", "* prop" : "toolbar", "items" : [ { "listeners" : { "render" : "function (_self)\n{\n _this.status = _self;\n}", "select" : "function (combo, record, index)\n{\n _this.grid.ds.load({});\n}" }, "listWidth" : 200, "triggerAction" : "all", "fieldLabel" : "Status", "displayField" : "fname", "hiddenName" : "status", "value" : "A", "valueField" : "ftype", "xtype" : "ComboBox", "allowBlank" : false, "editable" : false, "width" : 150, "$ xns" : "Roo.form", "mode" : "local", "name" : "status", "items" : [ { "xtype" : "SimpleStore", "$ data" : "[ \n [ 'O', \"Open\"],\n [ 'C' , \"Closed\"],\n [ 'A', \"All\"] \n]\n", "$ fields" : "[ 'ftype', 'fname']", "$ xns" : "Roo.data", "* prop" : "store" } ] }, { "xtype" : "Fill", "$ xns" : "Roo.Toolbar" }, { "listeners" : { "|click" : "function()\n{\n var addPeriod = function(){\n new Pman.Request({\n url : baseURL + '/Roo/Period.php',\n timeout: 600000,\n mask : 'Processing',\n method : 'POST',\n params : {\n _addExtraYear : 1\n }, \n success : function() {\n _this.wgrid.ds.load({});\n }\n });\n }\n \n Roo.MessageBox.confirm(\"Confirm\", \"Are you sure want to add extra year\" , function(r) {\n if (r !='yes') {\n return;\n }\n addPeriod();\n })\n \n}\n" }, "text" : "Add Extra Year", "xtype" : "Button", "cls" : "x-btn-text-icon", "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'", "$ xns" : "Roo.Toolbar" }, { "xtype" : "Separator", "$ xns" : "Roo.Toolbar" }, { "listeners" : { "|click" : "function()\n{\n var list = []; \n \n \n \n _this.grid.ds.each(function (r) {\n if (r.data.period_closed) {\n return;\n }\n \n if(r.data.transactions > 0 ){\n return false;\n }\n list.push(r.data);\n\n });\n \n if (!list.length) {\n Roo.MessageBox.alert(\"Notice\", \"Nothing to close\");\n return;\n }\n \n var tl = list.length;\n \n var closeNext = function(){\n \n if (!list.length) {\n Roo.MessageBox.hide();\n _this.grid.ds.load({});\n return;\n }\n \n var item = list.shift();\n \n Roo.MessageBox.updateProgress(\n (tl-list.length) / tl,\n \"Closing \" + item.period_name\n \n );\n \n new Pman.Request({\n url : baseURL + '/Roo/Period.php',\n timeout: 900000,\n //mask : 'Processing',\n method : 'POST',\n params : {\n period_id : item.period_id,\n _action: 'close' ,\n _second_action : 'freeze'\n }, \n success : function() {\n closeNext();\n// _this.grid.ds.load({});\n }\n });\n };\n \n \n \n \n Roo.MessageBox.confirm(\"Confirm\", \"Are you sure want to close the period where there are no transactions?\" , function(r) {\n if (r !='yes') {\n return;\n }\n Roo.MessageBox.progress( \"Closing periods\", \"Closing periods\");\n closeNext();\n \n })\n \n \n \n \n \n}\n" }, "text" : "Close all empty months", "xtype" : "Button", "cls" : "x-btn-text-icon", "$ icon" : "Roo.rootURL + 'images/default/tree/leaf.gif'", "$ xns" : "Roo.Toolbar" } ] }, { "listeners" : { "beforeload" : "function (_self, options)\n{\n options.params = options.params || {};\n \n var s = _this.wgrid.getSelectionModel().getSelected();\n \n if(!s || !s.data.yearperiod_id * 1 > 0){\n Roo.MessageBox.alert('Error','Please select a year period');\n this.removeAll();\n return false;\n }\n \n options.params._status = _this.status.getValue();\n options.params.period_yearperiod_id = s.data.yearperiod_id;\n options.params._with_transactions = 1;\n \n\n}" }, "xtype" : "Store", "remoteSort" : true, "$ sortInfo" : "{ field : 'period_start', direction: 'ASC' }", "$ xns" : "Roo.data", "* prop" : "dataSource", "items" : [ { "$ url" : "baseURL + '/Roo/Period.php'", "xtype" : "HttpProxy", "method" : "GET", "$ xns" : "Roo.data", "* prop" : "proxy" }, { "id" : "id", "root" : "data", "xtype" : "JsonReader", "$ fields" : "[\n {\n 'name': 'period_id',\n 'type': 'int'\n },\n {\n 'name': 'period_name',\n 'type': 'string'\n }\n]", "$ xns" : "Roo.data", "* prop" : "reader", "totalProperty" : "total" } ] }, { "xtype" : "ColumnModel", "header" : "Name", "width" : 100, "$ renderer" : "function(v) \n{ \n return String.format('{0}', v ? v : ''); \n}", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "period_name", "items" : [ { "xtype" : "GridEditor", "$ xns" : "Roo.grid", "* prop" : "editor", "items" : [ { "xtype" : "TextField", "allowBlank" : false, "$ xns" : "Roo.form", "* prop" : "field" } ] } ] }, { "xtype" : "ColumnModel", "header" : "Start", "width" : 100, "$ renderer" : "function(v) { return String.format('{0}', v ? v.format('Y-m-d') : ''); }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "period_start" }, { "xtype" : "ColumnModel", "header" : "End", "width" : 100, "$ renderer" : "function(v) { return String.format('{0}', v ? v.format('Y-m-d') : ''); }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "period_end" }, { "xtype" : "ColumnModel", "header" : "Closed", "width" : 75, "$ renderer" : "function(v) { \n var state = v ? '-checked' : '';\n\n return '';\n \n }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "period_closed" }, { "xtype" : "ColumnModel", "header" : "Frozen", "width" : 75, "$ renderer" : "function(v) { \n var state = v ? '-checked' : '';\n\n return '';\n \n }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "period_freeze" }, { "align" : "right", "xtype" : "ColumnModel", "header" : "Transactions", "width" : 100, "$ renderer" : "function(v) \n{ \n return String.format('{0}', v ? v : ''); \n}", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "transactions" } ] } ] } ] } ] } ] }