{ "id": "roo-file-78", "name": "Pman.Tab.XtupleSalesPlanning", "parent": "Pman.Tab.XtupleSales", "title": "Pman.Tab.XtupleSalesPlanning", "path": "/home/edward/gitlive/web.xtuple/Pman/Xtuple/Pman.Tab.XtupleSalesPlanning.bjs", "items": [ { "listeners": { "activate": "function (_self)\n{\n // Roo.log(Pman.hasPerm('Xtuple.SalesPlanner', 'S'));\n // Roo.log(Pman.Login.authUser);\n}" }, "background": false, "fitContainer": true, "fitToFrame": true, "title": "Sales Planning", "xtype": "NestedLayoutPanel", "|xns": "Roo", "items": [ { "|xns": "Roo", "xtype": "BorderLayout", "*prop": "layout", "items": [ { "|xns": "Roo", "xtype": "LayoutRegion", "*prop": "center" }, { "*prop": "south", "height": 400, "split": true, "xtype": "LayoutRegion", "|xns": "Roo" }, { "listeners": { "activate": "function (_self)\n{\n _self.layout.getRegion('center').showPanel(0);\n}" }, "background": false, "fitContainer": true, "fitToFrame": true, "region": "center", "xtype": "NestedLayoutPanel", "|xns": "Roo", "items": [ { "|xns": "Roo", "xtype": "BorderLayout", "*prop": "layout", "items": [ { "|xns": "Roo", "xtype": "LayoutRegion", "*prop": "center" }, { "*prop": "west", "split": true, "tabPosition": "top", "width": 300, "xtype": "LayoutRegion", "|xns": "Roo" }, { "listeners": { "|activate": "function() {\n _this.panel = this;\n \n // if (_this.grid) {\n // _this.grid.footer.onClick('first');\n // }\n}" }, "background": false, "fitContainer": true, "fitToframe": true, "region": "center", "tableName": "item", "title": "Item", "xtype": "GridPanel", "|xns": "Roo", "items": [ { "listeners": { "|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}" }, "*prop": "grid", "autoExpandColumn": "item_descrip1", "loadMask": true, "xtype": "Grid", "|xns": "Roo.grid", "items": [ { "listeners": { "afterselectionchange": "function (_self)\n{\n if (_this.sgrid) {\n _this.sgrid.footer.onClick('first');\n }\n}" }, "*prop": "sm", "singleSelect": true, "xtype": "RowSelectionModel", "|xns": "Roo.grid" }, { "listeners": { "beforeload": "function (_self, o)\n{\n o.params = o.params || {};\n \n var s = _this.wgrid.getSelectionModel().getSelected();\n if(!s.data.cust_id){\n _this.grid.ds.removeAll();\n return false;\n }\n _this.sgrid.ds.removeAll();\n \n o.params._with_year_total = 1;\n \n o.params._charass_brand_value = _this.brandSel.getValue();\n o.params._charass_group_value = _this.groupSel.getValue();\n \n o.params._with_itemsrc_active = 1;\n o.params._in_cust_id = s.data.cust_id;\n \n var date = new Date();\n var year = date.getFullYear(); // four digits\n var month = date.getMonth(); // 0-11\n \n var cm = _this.grid.getColumnModel();\n function cid(str) {\r\n return cm.getIndexByDataIndex(str);\r\n }\r \n \n cm.setColumnHeader(cid('total_before_last_year'),'Total ' + (year - 2));\n cm.setColumnHeader(cid('total_last_year'),'Total ' + (year - 1));\n cm.setColumnHeader(cid('forecast_this_year'),'Forecast ' + year);\n cm.setColumnHeader(cid('total_this_year'),'Total ' + year);\n \n if(month > 5){\n cm.setColumnHeader(cid('forecast_next_year'),'Total ' + (year + 1));\n cm.setHidden(cid('forecast_next_year'),false);\n }\n // it make the grid slow, change it later!\n if(s.data.cust_name == 'All Companies'){\n cm.setHidden(cid('forecast_this_year'),true);\n cm.setHidden(cid('company_estimates'),false);\n }else{\n cm.setHidden(cid('forecast_this_year'),false);\n cm.setHidden(cid('company_estimates'),true);\n }\n \n\n}", "load": "function (_self, records, options)\n{\n var sm = _this.grid.getSelectionModel();\n Roo.each(records, function(record){\n if(record.data.item_id == _this.grid.lastSelectedId){\n sm.selectRow(_this.grid.ds.indexOf(record));\n if (_this.sgrid) {\n _this.sgrid.footer.onClick('first');\n }\n }\n })\n}" }, "*prop": "dataSource", "remoteSort": true, "xtype": "Store", "|sortInfo": "{ field : 'item_number', direction: 'ASC' }", "|xns": "Roo.data", "items": [ { "*prop": "proxy", "method": "GET", "xtype": "HttpProxy", "|url": "baseURL + '/Roo/Item.php'", "|xns": "Roo.data" }, { "*prop": "reader", "id": "id", "root": "data", "totalProperty": "total", "xtype": "JsonReader", "|fields": "[\n {\n 'name': 'item_number',\n 'type': 'string'\n },\n {\n 'name': 'item_descrip1',\n 'type': 'string'\n },\n {\n 'name': 'total_before_last_year',\n 'type': 'int'\n },\n {\n 'name': 'total_last_year',\n 'type': 'int'\n },\n {\n 'name': 'forecast_this_year',\n 'type': 'int'\n },\n {\n 'name': 'total_this_year',\n 'type': 'int'\n },\n {\n 'name': 'total_next_year',\n 'type': 'int'\n },\n {\n 'name': 'forecast_next_year',\n 'type': 'int'\n },\n {\n 'name': 'last_forecast_entered',\n 'type': 'string'\n }\n]", "|xns": "Roo.data" } ] }, { "*prop": "footer", "displayInfo": true, "displayMsg": "Displaying Item{0} - {1} of {2}", "emptyMsg": "No Item found", "pageSize": 25, "xtype": "PagingToolbar", "|xns": "Roo" }, { "|xns": "Roo", "xtype": "Toolbar", "*prop": "toolbar", "items": [ { "listeners": { "render": "function (_self)\n{\n _this.brandSel = _self;\n \n}", "select": "function (combo, record, index)\n{\n _this.wgrid.ds.load({});}" }, "allowBlank": true, "alwaysQuery": true, "displayField": "charass_value", "editable": true, "emptyText": "Select Brand", "forceSelection": true, "listWidth": 300, "loadingText": "Searching...", "minChars": 2, "pageSize": 20, "qtip": "Select Brand", "queryParam": "query[charass_value]", "selectOnFocus": true, "tpl": "
{charass_value}
", "triggerAction": "all", "width": 200, "xtype": "ComboBox", "|xns": "Roo.form", "items": [ { "listeners": { "|beforeload": "function (_self, o)\n{\n o.params = o.params || {};\n // staff can see all logs, other companies can only see their own.\n // look for all of the charass 's with the same type= eg. brand.\n \n o.params.charass_char_id_char_name = 'BRAND';\n o.params.charass_target_type ='I';\n o.params._distinct = 'charass_value';\n o.params._columns = 'charass_value';\n\n}" }, "*prop": "store", "remoteSort": true, "xtype": "Store", "|sortInfo": "{ field : 'charass_value' , direction : 'ASC' }", "|xns": "Roo.data", "items": [ { "*prop": "proxy", "method": "GET", "xtype": "HttpProxy", "|url": "baseURL + '/Roo/Charass.php'", "|xns": "Roo.data" }, { "*prop": "reader", "id": "id", "root": "data", "totalProperty": "total", "xtype": "JsonReader", "|fields": "[\n {\n 'name': 'id',\n 'type': 'int'\n },\n {\n 'name': 'person_name',\n 'type': 'string'\n },\n {\n 'name': 'event_when',\n 'type': 'date',\n 'dateFormat': 'Y-m-d'\n },\n {\n 'name': 'action',\n 'type': 'string'\n },\n {\n 'name': 'ipaddr',\n 'type': 'string'\n },\n {\n 'name': 'on_id',\n 'type': 'int'\n },\n {\n 'name': 'on_table',\n 'type': 'string'\n },\n {\n 'name': 'person_id',\n 'type': 'int'\n },\n {\n 'name': 'remarks',\n 'type': 'string'\n },\n {\n 'name': 'person_id_id',\n 'type': 'int'\n },\n {\n 'name': 'person_id_office_id',\n 'type': 'int'\n },\n {\n 'name': 'person_id_name',\n 'type': 'string'\n },\n {\n 'name': 'person_id_phone',\n 'type': 'string'\n },\n {\n 'name': 'person_id_fax',\n 'type': 'string'\n },\n {\n 'name': 'person_id_email',\n 'type': 'string'\n },\n {\n 'name': 'person_id_company_id',\n 'type': 'int'\n },\n {\n 'name': 'person_id_role',\n 'type': 'string'\n },\n {\n 'name': 'person_id_active',\n 'type': 'int'\n },\n {\n 'name': 'person_id_remarks',\n 'type': 'string'\n },\n {\n 'name': 'person_id_passwd',\n 'type': 'string'\n },\n {\n 'name': 'person_id_owner_id',\n 'type': 'int'\n },\n {\n 'name': 'person_id_lang',\n 'type': 'string'\n },\n {\n 'name': 'person_id_no_reset_sent',\n 'type': 'int'\n },\n {\n 'name': 'person_id_action_type',\n 'type': 'string'\n },\n {\n 'name': 'person_id_project_id',\n 'type': 'int'\n },\n {\n 'name': 'person_id_deleted_by',\n 'type': 'int'\n },\n {\n 'name': 'person_id_deleted_dt',\n 'type': 'date'\n }\n]", "|xns": "Roo.data" } ] } ] }, { "listeners": { "render": "function (_self)\n{\n _this.groupSel = _self;\n}", "select": "function (combo, record, index)\n{\n _this.wgrid.ds.load({});\n}" }, "allowBlank": true, "alwaysQuery": true, "displayField": "charass_value", "editable": true, "emptyText": "Select Product Group", "forceSelection": true, "listWidth": 300, "loadingText": "Searching...", "minChars": 2, "pageSize": 20, "qtip": "Select Product Group", "queryParam": "query[charass_value]", "selectOnFocus": true, "tpl": "
{charass_value}
", "triggerAction": "all", "width": 200, "xtype": "ComboBox", "|xns": "Roo.form", "items": [ { "listeners": { "|beforeload": "function (_self, o)\n{\n o.params = o.params || {};\n // staff can see all logs, other companies can only see their own.\n // look for all of the charass 's with the same type= eg. brand.\n \n o.params.charass_char_id_char_name = 'PRODUCTGROUP';\n o.params.charass_target_type ='I';\n o.params._distinct = 'charass_value';\n o.params._columns = 'charass_value';\n\n}" }, "*prop": "store", "remoteSort": true, "xtype": "Store", "|sortInfo": "{ field : 'charass_value' , direction : 'ASC' }", "|xns": "Roo.data", "items": [ { "*prop": "proxy", "method": "GET", "xtype": "HttpProxy", "|url": "baseURL + '/Roo/Charass.php'", "|xns": "Roo.data" }, { "*prop": "reader", "id": "id", "root": "data", "totalProperty": "total", "xtype": "JsonReader", "|fields": "[\n {\n 'name': 'id',\n 'type': 'int'\n },\n {\n 'name': 'person_name',\n 'type': 'string'\n },\n {\n 'name': 'event_when',\n 'type': 'date',\n 'dateFormat': 'Y-m-d'\n },\n {\n 'name': 'action',\n 'type': 'string'\n },\n {\n 'name': 'ipaddr',\n 'type': 'string'\n },\n {\n 'name': 'on_id',\n 'type': 'int'\n },\n {\n 'name': 'on_table',\n 'type': 'string'\n },\n {\n 'name': 'person_id',\n 'type': 'int'\n },\n {\n 'name': 'remarks',\n 'type': 'string'\n },\n {\n 'name': 'person_id_id',\n 'type': 'int'\n },\n {\n 'name': 'person_id_office_id',\n 'type': 'int'\n },\n {\n 'name': 'person_id_name',\n 'type': 'string'\n },\n {\n 'name': 'person_id_phone',\n 'type': 'string'\n },\n {\n 'name': 'person_id_fax',\n 'type': 'string'\n },\n {\n 'name': 'person_id_email',\n 'type': 'string'\n },\n {\n 'name': 'person_id_company_id',\n 'type': 'int'\n },\n {\n 'name': 'person_id_role',\n 'type': 'string'\n },\n {\n 'name': 'person_id_active',\n 'type': 'int'\n },\n {\n 'name': 'person_id_remarks',\n 'type': 'string'\n },\n {\n 'name': 'person_id_passwd',\n 'type': 'string'\n },\n {\n 'name': 'person_id_owner_id',\n 'type': 'int'\n },\n {\n 'name': 'person_id_lang',\n 'type': 'string'\n },\n {\n 'name': 'person_id_no_reset_sent',\n 'type': 'int'\n },\n {\n 'name': 'person_id_action_type',\n 'type': 'string'\n },\n {\n 'name': 'person_id_project_id',\n 'type': 'int'\n },\n {\n 'name': 'person_id_deleted_by',\n 'type': 'int'\n },\n {\n 'name': 'person_id_deleted_dt',\n 'type': 'date'\n }\n]", "|xns": "Roo.data" } ] } ] }, { "|xns": "Roo.Toolbar", "xtype": "Fill" }, { "listeners": { "click": "function ()\n{\n var brand = _this.brandSel.getValue();\n var group = _this.groupSel.getValue();\n \n if(!brand && !group){\n Roo.MessageBox.alert('Error','Please select the brand or group');\n return;\n }\n \n Roo.MessageBox.alert(\"Notice\",\"Your report should be downloading now\");\n \n new Pman.download({\n url : baseURL + '/Roo/Salesforecast',\n method : 'GET',\n timeout: 900000,\n params : {\n '_download' : 1,\n 'brand' : brand,\n 'group' : group\n }\n }); \n \n}" }, "cls": "x-btn-text-icon", "text": "Download Report", "xtype": "Button", "|icon": "rootURL + '/Pman/templates/images/spreadsheet.gif'", "|xns": "Roo.Toolbar" } ] }, { "*prop": "colModel[]", "dataIndex": "itemsrc_active", "header": "is Active?", "width": 50, "xtype": "ColumnModel", "|renderer": "function(v) { \n var state = v * 1 > 0 ? '-checked' : '';\n\n return '';\n \n }", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "dataIndex": "item_number", "header": "Item code", "width": 200, "xtype": "ColumnModel", "|renderer": "function(v) { return String.format('{0}', v); }", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "dataIndex": "item_descrip1", "header": "Item name", "width": 200, "xtype": "ColumnModel", "|renderer": "function(v) { return String.format('{0}', v); }", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "dataIndex": "total_before_last_year", "header": "Total", "width": 150, "xtype": "ColumnModel", "|renderer": "function(v) { return String.format('{0}', v); }", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "dataIndex": "total_last_year", "header": "Total", "width": 150, "xtype": "ColumnModel", "|renderer": "function(v) { return String.format('{0}', v); }", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "dataIndex": "forecast_this_year", "header": "Forecast", "width": 150, "xtype": "ColumnModel", "|renderer": "function(v,x,r) { \n \n if (v*1 == 0) {\n \n return '' + v + '';\n }\n \n return String.format('{0}', v);\n \n \n}", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "dataIndex": "total_this_year", "header": "Total", "width": 150, "xtype": "ColumnModel", "|renderer": "function(v) { return String.format('{0}', v); }", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "dataIndex": "forecast_next_year", "header": "Forecast", "hidden": true, "width": 150, "xtype": "ColumnModel", "|renderer": "function(v,x,r) { \n \n if (v*1 == 0) {\n \n return '' + v + '';\n }\n \n return String.format('{0}', v);\n \n \n}", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "dataIndex": "last_forecast_entered", "header": "Last forcast entered", "width": 150, "xtype": "ColumnModel", "|renderer": "function(v,x,r) {\n if(!v){\n return;\n }\n var last_forecast = new Date(v);\n \n var date = new Date();\n var y = date.getFullYear();\n var m = date.getMonth() + 3;\n var d = date.getDate();\n if(m >= 11){\n y = y + 1;\n m = m - 11;\n }\n var c = new Date(y,m,d);\n if (last_forecast < c) {\n return '' + last_forecast.format('M Y') + '';\n }\n \n return String.format('{0}', last_forecast.format('M Y'));\n \n \n}", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "dataIndex": "company_estimates", "header": "Estimates", "hidden": true, "width": 150, "xtype": "ColumnModel", "|renderer": "function(v,x,r) {\n return String.format('{0}', v);\n \n \n}", "|xns": "Roo.grid" } ] } ] }, { "listeners": { "|activate": "function() {\n _this.wpanel = this;\n if (_this.wgrid) {\n _this.wgrid.ds.load({});\n }\n}" }, "background": true, "fitContainer": true, "fitToframe": true, "region": "west", "tableName": "custinfo", "title": "Customer", "xtype": "GridPanel", "|xns": "Roo", "items": [ { "listeners": { "|render": "function() \n{\n _this.wgrid = this; \n if (_this.wpanel.active) {\n _this.wgrid.ds.load({});\n }\n}", "rowclick": "function (_self, rowIndex, e)\n{\n var sm = _this.grid.getSelectionModel();\n if(sm.getSelections().length){\n _this.grid.lastSelectedId = sm.getSelections()[0].data.item_id;\n }\n _this.grid.footer.onClick('refresh');\n}" }, "*prop": "grid", "autoExpandColumn": "cust_name_with_pcs", "loadMask": true, "xtype": "Grid", "|xns": "Roo.grid", "items": [ { "listeners": { "beforeload": "function (_self, o){\n o.params = o.params || {};\n \n o.params._with_lastyear_total = 1;\n o.params._columns = 'cust_id,cust_name,lastyear_total';\n \n var brand = _this.brandSel.getValue();\n if(!brand.length){\n _this.wgrid.ds.removeAll();\n _this.grid.ds.removeAll();\n return false;\n }\n \n o.params._charass_brand_value = _this.brandSel.getValue();\n o.params._charass_group_value = _this.groupSel.getValue();\n \n o.params.limit = 9999;\n \n}\n", "load": "function (_self, records, options)\n{\n var sm = _this.wgrid.getSelectionModel();\n if (!sm.getSelections().length) {\n sm.selectFirstRow();\n }\n \n _this.grid.footer.onClick('first');\n}" }, "*prop": "dataSource", "remoteSort": true, "xtype": "Store", "|sortInfo": "{ field : 'lastyear_total', direction: 'DESC' }", "|xns": "Roo.data", "items": [ { "*prop": "proxy", "method": "GET", "xtype": "HttpProxy", "|url": "baseURL + '/Roo/Custinfo.php'", "|xns": "Roo.data" }, { "*prop": "reader", "id": "id", "root": "data", "totalProperty": "total", "xtype": "JsonReader", "|fields": "[\n {\n 'name': 'cust_id',\n 'type': 'int'\n },\n {\n 'name': 'cust_name_with_pcs',\n 'type': 'string'\n },\n {\n 'name': 'lastyear_total',\n 'type': 'int'\n }\n]", "|xns": "Roo.data" } ] }, { "*prop": "colModel[]", "dataIndex": "cust_name", "header": "Company Name", "width": 200, "xtype": "ColumnModel", "|renderer": "function(v) { return String.format('{0}', v); }", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "dataIndex": "lastyear_total", "header": "", "width": 75, "xtype": "ColumnModel", "|renderer": "function(v,x,r) \n{\n return String.format('{0}', v + ' pcs'); \n}", "|xns": "Roo.grid" } ] } ] } ] } ] }, { "listeners": { "|activate": "function() {\n _this.spanel = this;\n /* if (_this.sgrid) {\n _this.sgrid.footer.onClick('first');\n } */\n}" }, "background": false, "fitContainer": true, "fitToframe": true, "region": "south", "tableName": "Groups", "title": "Details", "xtype": "GridPanel", "|xns": "Roo", "items": [ { "listeners": { "|render": "function() \n{\n _this.sgrid = this; \n //_this.dialog = Pman.Dialog.FILL_IN\n /* if (_this.spanel.active) {\n this.footer.onClick('first');\n } */\n}", "afteredit": "function (e)\n{\n _this.grid.loadMask.el.unmask();\n _this.wgrid.loadMask.el.unmask();\n if(e.value == e.originalValue){\n return;\n }\n var field = e.field;\n var salesforecast_id = e.record.json[field + '_salesforecast_id'];\n var rec = _this.grid.getSelectionModel().getSelected();\n var s = _this.wgrid.getSelectionModel().getSelected();\n \n if(!rec || !s){\n Roo.Msg.alert(\"Error\",\"Please select a item\");\n return;\n }\n \n var params = {\n salesforecast_id : (salesforecast_id * 1 > 0) ? salesforecast_id : 0,\n salesforecast_cust_id : (s.data.cust_id < 0) ? 0 : s.data.cust_id,\n salesforecast_is_all_buyers : (s.data.view_type) == 'All' ? 1 : 0,\n _item_id : rec.data.item_id,\n month : e.column,\n year : e.record.data['year']\n }\n \n if(s.data.cust_id > 0){ // company level confirm and request editable!\n if(e.record.data['type'] == 'confirm'){\n params.salesforecast_qty = e.value;\n }\n if(e.record.data['type'] == 'request'){\n params.salesforecast_requests = e.value;\n }\n } else { // item level estimated and total forecast editable!\n if(e.record.data['type'] == 'estimated'){\n params.salesforecast_qty = e.value;\n }\n if(e.record.data['type'] == 'forecast'){\n params.salesforecast_sum = e.value;\n }\n }\n \n \n new Pman.Request({\n url : baseURL + '/Roo/Salesforecast.php',\n method :'POST',\n params : params,\n success : function() {\n \n _this.sgrid.footer.onClick('first');\n \n }\n });\n \n}", "beforeedit": "function (e)\n{ \n var rec = e.record;\n var y = new Date().getFullYear();\n var m = new Date().getMonth(); // 0-11\n var s = _this.grid.getSelectionModel().getSelected();\n var ss = _this.wgrid.getSelectionModel().getSelected();\n \n /*\r\n if(rec.data.type != 'forecast' || rec.data.year != y || !s.data.itemsrc_active || e.column < m + 3){\r\n return false;\r\n }\n */\n\n if(s.data.itemsrc_active * 1 < 1 || (rec.data.year == y && e.column < m + 3) || (rec.data.year != y && e.column + 12 < m + 3)){\n return false;\n }\n if(ss.data.cust_id > 0){ // companies level, confirm and request editable!\n if(rec.data.type != 'confirm' && rec.data.type != 'request'){\n return false;\n }\n }else{ // item level, estimated and total forecast editable!\n if(rec.data.type != 'estimated' && rec.data.type != 'forecast'){\n return false;\n }\n }\n \n _this.grid.loadMask.el.mask('Cancel edit forecast first!');\n _this.wgrid.loadMask.el.mask('Cancel edit forecast first!');\r\n}" }, "*prop": "grid", "autoExpandColumn": "year_text", "clicksToEdit": 1, "loadMask": true, "xtype": "EditorGrid", "|calcest": "function(colname) \n{\n\n var before = _this.sgrid.ds.getAt(0).data[colname];\n var last = _this.sgrid.ds.getAt(1).data[colname];\n var est = last * 2;\n if(before < last * 2){\n est = last * 2 - before;\n }\n return est;\n}\n", "|formatcol": "function(v,r,n) \n{\n var d = new Date();\n var y = d.getFullYear();\n var m = d.getMonth();\n var month = n.split(\"_\");\n // var est = _this.sgrid.calcest(n);\n /* if(r.data.type == 'forecast' && r.data.year == y && r.json.is_all_buyers == 0){\n if(month[1] < m + 3)\n { // fill in blank if the month less than next month\n return String.format('{0}',''); \n }\n if(est > v || v > est * 2 || v * 1 == 0)\n { //red if forcast is less than estimate or double estimate\n return '' + v + ' ( ' + est + ' )';\n }\n return String.format('{0}',v + ' ( ' + est + ' )'); \n }\n if(r.data.type == 'forecast' && r.data.year == y && r.json.is_all_buyers == 1){\n var t = '';\n if((typeof(v) != undefined && v > 0)){\n t += v + ' ';\n }\n if(typeof(r.json[n + '_sum']) != undefined && r.json[n + '_sum'] > 0){\n t += 'sum( ' + r.json[n + '_sum'] + ' )';\n }\n if(month[1] > m + 2 && month[1] < m + 7 && !t){\n return 'MUST FILL IN (' + est + ')';\n }\n return String.format('{0}',t); \n }\n */\n \n var s = _this.wgrid.getSelectionModel().getSelected();\n \n // forecast - item level \n \n \n if(r.data.type == 'confirm' && s.data.cust_id < 0 && v){\n return String.format('SUM ( {0} )',v); \n } \n \n if(r.data.type == 'percentage' && v){\n return String.format('{0}%', Roo.util.Format.number(v,2));\n } \n \n if(r.data.type == 'predicted' && v < 0){\n return String.format('{0}', 'BAD GUESS');\n }\n \n \n return String.format('{0}',v); \n\n}\n", "|xns": "Roo.grid", "items": [ { "listeners": { "beforeload": "function (_self, o)\n{\n o.params = o.params || {};\n \n var rec = _this.grid.getSelectionModel().getSelected();\n var s = _this.wgrid.getSelectionModel().getSelected();\n \n if(!_this.grid || !rec || !s){\n this.removeAll();\n return;\n }\n \n o.params._detailView = 1;\n o.params._item_id = rec.data.item_id;\n o.params._in_cust_id = (s.data.cust_id < 0) ? 0 : s.data.cust_id;\r\n o.params._is_all_buyers = (s.data.view_type) == 'All' ? 1 : 0;\n \r\n}" }, "*prop": "dataSource", "remoteSort": true, "xtype": "Store", "|sortInfo": "{ field : 'name', direction: 'ASC' }", "|xns": "Roo.data", "items": [ { "*prop": "proxy", "method": "GET", "xtype": "HttpProxy", "|url": "baseURL + '/Roo/Salesforecast.php'", "|xns": "Roo.data" }, { "*prop": "reader", "id": "id", "root": "data", "totalProperty": "total", "xtype": "JsonReader", "|fields": "[\n {\n 'name': 'total_1',\n 'type': 'int'\n },\n {\n 'name': 'total_2',\n 'type': 'int'\n },\n {\n 'name': 'total_3',\n 'type': 'int'\n },\n {\n 'name': 'total_4',\n 'type': 'int'\n },\n {\n 'name': 'total_5',\n 'type': 'int'\n },\n {\n 'name': 'total_6',\n 'type': 'int'\n },\n {\n 'name': 'total_7',\n 'type': 'int'\n },\n {\n 'name': 'total_8',\n 'type': 'int'\n },\n {\n 'name': 'total_9',\n 'type': 'int'\n },\n {\n 'name': 'total_10',\n 'type': 'int'\n },\n {\n 'name': 'total_11',\n 'type': 'int'\n },\n {\n 'name': 'total_12',\n 'type': 'int'\n },\n {\n 'name': 'type',\n 'type': 'string'\n },\n {\n 'name': 'year_text',\n 'type': 'string'\n },\n {\n 'name': 'year',\n 'type': 'int'\n }\n]", "|xns": "Roo.data" } ] }, { "|xns": "Roo", "xtype": "Toolbar", "*prop": "toolbar", "items": [ { "|xns": "Roo.Toolbar", "xtype": "Fill" }, { "listeners": { "click": "function (_self, e)\n{\n var d = new Date();\n var m = d.getMonth(); // getMonth -> 0-11\n var y = new Date().getFullYear();\n \n var salesforecasts = [];\n var est = 0;\n var salesforecast_id = 0;\n var qty = 0;\n var rec = _this.grid.getSelectionModel().getSelected();\r\n var s = _this.wgrid.getSelectionModel().getSelected();\n if(!rec || !s){\n Roo.Msg.alert(\"Error\",\"Please select a item\");\n return;\n }\n if(rec.data.itemsrc_active * 1 < 1 ){\n Roo.Msg.alert(\"Error\",\"The itemsrc is not active!\");\n return;\n }\n if(s.data.cust_id < 0){\n Roo.Msg.alert(\"Error\",\"Auto Fill Just happen on company level, please select a company!\");\n return;\n }\n\n for(var i = 3; i < 13 - m; i++){ // current month and the next month are not able to edit.\n \n var salesforecast = {};\n \n salesforecast_id = _this.sgrid.ds.getAt(3).json['total_' + (m + i) + '_salesforecast_id']; // check existing or not ???\n est = _this.sgrid.ds.getAt(2).json['total_' + (m + i)]; // estimated qty!\n qty = _this.sgrid.ds.getAt(3).json['total_' + (m + i)]; // existing qty!\n \n salesforecast['month'] = m + i; // period month\n salesforecast['year'] = y; // period year\n \n salesforecast['salesforecast_id'] = (salesforecast_id * 1 > 0) ? salesforecast_id : 0; // update or insert ???\n salesforecast['salesforecast_qty'] = (qty != 0) ? qty : est; // if we have entried in this period. do not use the estimated\n \n salesforecast['_item_id'] = rec.data.item_id;\n \n salesforecast['salesforecast_cust_id'] = s.data.cust_id;\n \n salesforecast['salesforecast_is_all_buyers'] = 0;\n \n salesforecasts.push((salesforecast)); \n }\n \n if(!salesforecasts.length){\n return;\n }\n new Pman.Request({\n url : baseURL + '/Roo/Salesforecast.php',\n method :'POST',\n params : {\n _group_data : Roo.encode(salesforecasts)\n \n },\n success : function() {\n \n _this.sgrid.footer.onClick('first');\n \n }\n });\n \n \n}" }, "text": "Auto Fill (This Year)", "xtype": "Button", "|xns": "Roo.Toolbar" } ] }, { "*prop": "footer", "xtype": "PagingToolbar", "pageSize": 25, "displayInfo": true, "displayMsg": "Displaying Groups{0} - {1} of {2}", "emptyMsg": "No Groups found", "|xns": "Roo" }, { "*prop": "colModel[]", "dataIndex": "year_text", "header": "Scenario / Month", "width": 200, "xtype": "ColumnModel", "|renderer": "function(v) { return String.format('{0}', v); }", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "dataIndex": "total_1", "header": "Jan", "width": 100, "xtype": "ColumnModel", "|renderer": "function(v,x,r) \n{\n return _this.sgrid.formatcol(v,r,this.name);\n}", "|xns": "Roo.grid", "items": [ { "|xns": "Roo.grid", "xtype": "GridEditor", "*prop": "editor", "items": [ { "*prop": "field", "allowDecimals": false, "xtype": "NumberField", "|xns": "Roo.form" } ] } ] }, { "*prop": "colModel[]", "dataIndex": "total_2", "header": "Feb", "width": 100, "xtype": "ColumnModel", "|renderer": "function(v,x,r) \n{\n return _this.sgrid.formatcol(v,r,this.name);\n}", "|xns": "Roo.grid", "items": [ { "|xns": "Roo.grid", "xtype": "GridEditor", "*prop": "editor", "items": [ { "*prop": "field", "allowDecimals": false, "xtype": "NumberField", "|xns": "Roo.form" } ] } ] }, { "*prop": "colModel[]", "dataIndex": "total_3", "header": "Mar", "width": 100, "xtype": "ColumnModel", "|renderer": "function(v,x,r) \n{\n return _this.sgrid.formatcol(v,r,this.name);\n}", "|xns": "Roo.grid", "items": [ { "|xns": "Roo.grid", "xtype": "GridEditor", "*prop": "editor", "items": [ { "*prop": "field", "allowDecimals": false, "xtype": "NumberField", "|xns": "Roo.form" } ] } ] }, { "*prop": "colModel[]", "dataIndex": "total_4", "header": "Apr", "width": 100, "xtype": "ColumnModel", "|renderer": "function(v,x,r) \n{\n return _this.sgrid.formatcol(v,r,this.name);\n}", "|xns": "Roo.grid", "items": [ { "|xns": "Roo.grid", "xtype": "GridEditor", "*prop": "editor", "items": [ { "*prop": "field", "allowDecimals": false, "xtype": "NumberField", "|xns": "Roo.form" } ] } ] }, { "*prop": "colModel[]", "dataIndex": "total_5", "header": "May", "width": 100, "xtype": "ColumnModel", "|renderer": "function(v,x,r) \n{\n return _this.sgrid.formatcol(v,r,this.name);\n}", "|xns": "Roo.grid", "items": [ { "|xns": "Roo.grid", "xtype": "GridEditor", "*prop": "editor", "items": [ { "*prop": "field", "allowDecimals": false, "xtype": "NumberField", "|xns": "Roo.form" } ] } ] }, { "*prop": "colModel[]", "dataIndex": "total_6", "header": "Jun", "width": 100, "xtype": "ColumnModel", "|renderer": "function(v,x,r) \n{\n return _this.sgrid.formatcol(v,r,this.name);\n}", "|xns": "Roo.grid", "items": [ { "|xns": "Roo.grid", "xtype": "GridEditor", "*prop": "editor", "items": [ { "*prop": "field", "allowDecimals": false, "xtype": "NumberField", "|xns": "Roo.form" } ] } ] }, { "*prop": "colModel[]", "dataIndex": "total_7", "header": "Jul", "width": 100, "xtype": "ColumnModel", "|renderer": "function(v,x,r) \n{\n return _this.sgrid.formatcol(v,r,this.name);\n}", "|xns": "Roo.grid", "items": [ { "|xns": "Roo.grid", "xtype": "GridEditor", "*prop": "editor", "items": [ { "*prop": "field", "allowDecimals": false, "xtype": "NumberField", "|xns": "Roo.form" } ] } ] }, { "*prop": "colModel[]", "dataIndex": "total_8", "header": "Aug", "width": 100, "xtype": "ColumnModel", "|renderer": "function(v,x,r) \n{\n return _this.sgrid.formatcol(v,r,this.name);\n}", "|xns": "Roo.grid", "items": [ { "|xns": "Roo.grid", "xtype": "GridEditor", "*prop": "editor", "items": [ { "*prop": "field", "allowDecimals": false, "xtype": "NumberField", "|xns": "Roo.form" } ] } ] }, { "*prop": "colModel[]", "dataIndex": "total_9", "header": "Sep", "width": 100, "xtype": "ColumnModel", "|renderer": "function(v,x,r) \n{\n return _this.sgrid.formatcol(v,r,this.name);\n}", "|xns": "Roo.grid", "items": [ { "|xns": "Roo.grid", "xtype": "GridEditor", "*prop": "editor", "items": [ { "*prop": "field", "allowDecimals": false, "xtype": "NumberField", "|xns": "Roo.form" } ] } ] }, { "*prop": "colModel[]", "dataIndex": "total_10", "header": "Oct", "width": 100, "xtype": "ColumnModel", "|renderer": "function(v,x,r) \n{\n return _this.sgrid.formatcol(v,r,this.name);\n}", "|xns": "Roo.grid", "items": [ { "|xns": "Roo.grid", "xtype": "GridEditor", "*prop": "editor", "items": [ { "*prop": "field", "allowDecimals": false, "xtype": "NumberField", "|xns": "Roo.form" } ] } ] }, { "*prop": "colModel[]", "dataIndex": "total_11", "header": "Nov", "width": 100, "xtype": "ColumnModel", "|renderer": "function(v,x,r) \n{\n return _this.sgrid.formatcol(v,r,this.name);\n}", "|xns": "Roo.grid", "items": [ { "|xns": "Roo.grid", "xtype": "GridEditor", "*prop": "editor", "items": [ { "*prop": "field", "allowDecimals": false, "xtype": "NumberField", "|xns": "Roo.form" } ] } ] }, { "*prop": "colModel[]", "dataIndex": "total_12", "header": "Dec", "width": 100, "xtype": "ColumnModel", "|renderer": "function(v,x,r) \n{\n return _this.sgrid.formatcol(v,r,this.name);\n}", "|xns": "Roo.grid", "items": [ { "|xns": "Roo.grid", "xtype": "GridEditor", "*prop": "editor", "items": [ { "*prop": "field", "allowDecimals": false, "xtype": "NumberField", "|xns": "Roo.form" } ] } ] }, { "*prop": "colModel[]", "dataIndex": "total_year", "header": "Total", "width": 100, "xtype": "ColumnModel", "|renderer": "function(v) { return String.format('{0}', v); }", "|xns": "Roo.grid" } ] } ] } ] } ] } ], "permname": "", "modOrder": "600" }