3 "name": "Pman.Tab.XtupleSalesPlanning",
4 "parent": "Pman.Tab.XtupleSales",
5 "title": "Pman.Tab.XtupleSalesPlanning",
6 "path": "/home/edward/gitlive/web.xtuple/Pman/Xtuple/Pman.Tab.XtupleSalesPlanning.bjs",
10 "activate": "function (_self)\n{\n // Roo.log(Pman.hasPerm('Xtuple.SalesPlanner', 'S'));\n // Roo.log(Pman.Login.authUser);\n}"
15 "title": "Sales Planning",
16 "xtype": "NestedLayoutPanel",
21 "xtype": "BorderLayout",
26 "xtype": "LayoutRegion",
33 "xtype": "LayoutRegion",
38 "activate": "function (_self)\n{\n _self.layout.getRegion('center').showPanel(0);\n}"
44 "xtype": "NestedLayoutPanel",
49 "xtype": "BorderLayout",
54 "xtype": "LayoutRegion",
62 "xtype": "LayoutRegion",
67 "|activate": "function() {\n _this.panel = this;\n \n // if (_this.grid) {\n // _this.grid.footer.onClick('first');\n // }\n}"
80 "|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}"
83 "autoExpandColumn": "item_descrip1",
90 "afterselectionchange": "function (_self)\n{\n if (_this.sgrid) {\n _this.sgrid.footer.onClick('first');\n }\n}"
94 "xtype": "RowSelectionModel",
99 "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}",
100 "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}"
102 "*prop": "dataSource",
105 "|sortInfo": "{ field : 'item_number', direction: 'ASC' }",
111 "xtype": "HttpProxy",
112 "|url": "baseURL + '/Roo/Item.php'",
119 "totalProperty": "total",
120 "xtype": "JsonReader",
121 "|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]",
129 "displayMsg": "Displaying Item{0} - {1} of {2}",
130 "emptyMsg": "No Item found",
132 "xtype": "PagingToolbar",
142 "render": "function (_self)\n{\n _this.brandSel = _self;\n \n}",
143 "select": "function (combo, record, index)\n{\n _this.wgrid.ds.load({});}"
147 "displayField": "charass_value",
149 "emptyText": "Select Brand",
150 "forceSelection": true,
152 "loadingText": "Searching...",
155 "qtip": "Select Brand",
156 "queryParam": "query[charass_value]",
157 "selectOnFocus": true,
158 "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{charass_value}</b> </div>",
159 "triggerAction": "all",
166 "|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}"
171 "|sortInfo": "{ field : 'charass_value' , direction : 'ASC' }",
177 "xtype": "HttpProxy",
178 "|url": "baseURL + '/Roo/Charass.php'",
185 "totalProperty": "total",
186 "xtype": "JsonReader",
187 "|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]",
196 "render": "function (_self)\n{\n _this.groupSel = _self;\n}",
197 "select": "function (combo, record, index)\n{\n _this.wgrid.ds.load({});\n}"
201 "displayField": "charass_value",
203 "emptyText": "Select Product Group",
204 "forceSelection": true,
206 "loadingText": "Searching...",
209 "qtip": "Select Product Group",
210 "queryParam": "query[charass_value]",
211 "selectOnFocus": true,
212 "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{charass_value}</b> </div>",
213 "triggerAction": "all",
220 "|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}"
225 "|sortInfo": "{ field : 'charass_value' , direction : 'ASC' }",
231 "xtype": "HttpProxy",
232 "|url": "baseURL + '/Roo/Charass.php'",
239 "totalProperty": "total",
240 "xtype": "JsonReader",
241 "|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]",
249 "|xns": "Roo.Toolbar",
254 "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}"
256 "cls": "x-btn-text-icon",
257 "text": "Download Report",
259 "|icon": "rootURL + '/Pman/templates/images/spreadsheet.gif'",
260 "|xns": "Roo.Toolbar"
265 "*prop": "colModel[]",
266 "dataIndex": "itemsrc_active",
267 "header": "is Active?",
269 "xtype": "ColumnModel",
270 "|renderer": "function(v) { \n var state = v * 1 > 0 ? '-checked' : '';\n\n return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n \n }",
274 "*prop": "colModel[]",
275 "dataIndex": "item_number",
276 "header": "Item code",
278 "xtype": "ColumnModel",
279 "|renderer": "function(v) { return String.format('{0}', v); }",
283 "*prop": "colModel[]",
284 "dataIndex": "item_descrip1",
285 "header": "Item name",
287 "xtype": "ColumnModel",
288 "|renderer": "function(v) { return String.format('{0}', v); }",
292 "*prop": "colModel[]",
293 "dataIndex": "total_before_last_year",
296 "xtype": "ColumnModel",
297 "|renderer": "function(v) { return String.format('{0}', v); }",
301 "*prop": "colModel[]",
302 "dataIndex": "total_last_year",
305 "xtype": "ColumnModel",
306 "|renderer": "function(v) { return String.format('{0}', v); }",
310 "*prop": "colModel[]",
311 "dataIndex": "forecast_this_year",
312 "header": "Forecast",
314 "xtype": "ColumnModel",
315 "|renderer": "function(v,x,r) { \n \n if (v*1 == 0) {\n \n return '<span style=\"color:red\">' + v + '</span>';\n }\n \n return String.format('{0}', v);\n \n \n}",
319 "*prop": "colModel[]",
320 "dataIndex": "total_this_year",
323 "xtype": "ColumnModel",
324 "|renderer": "function(v) { return String.format('{0}', v); }",
328 "*prop": "colModel[]",
329 "dataIndex": "forecast_next_year",
330 "header": "Forecast",
333 "xtype": "ColumnModel",
334 "|renderer": "function(v,x,r) { \n \n if (v*1 == 0) {\n \n return '<span style=\"color:red\">' + v + '</span>';\n }\n \n return String.format('{0}', v);\n \n \n}",
338 "*prop": "colModel[]",
339 "dataIndex": "last_forecast_entered",
340 "header": "Last forcast entered",
342 "xtype": "ColumnModel",
343 "|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 '<span style=\"color:red\">' + last_forecast.format('M Y') + '</span>';\n }\n \n return String.format('{0}', last_forecast.format('M Y'));\n \n \n}",
347 "*prop": "colModel[]",
348 "dataIndex": "company_estimates",
349 "header": "Estimates",
352 "xtype": "ColumnModel",
353 "|renderer": "function(v,x,r) {\n return String.format('{0}', v);\n \n \n}",
362 "|activate": "function() {\n _this.wpanel = this;\n if (_this.wgrid) {\n _this.wgrid.ds.load({});\n }\n}"
365 "fitContainer": true,
368 "tableName": "custinfo",
370 "xtype": "GridPanel",
375 "|render": "function() \n{\n _this.wgrid = this; \n if (_this.wpanel.active) {\n _this.wgrid.ds.load({});\n }\n}",
376 "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}"
379 "autoExpandColumn": "cust_name_with_pcs",
386 "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",
387 "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}"
389 "*prop": "dataSource",
392 "|sortInfo": "{ field : 'lastyear_total', direction: 'DESC' }",
398 "xtype": "HttpProxy",
399 "|url": "baseURL + '/Roo/Custinfo.php'",
406 "totalProperty": "total",
407 "xtype": "JsonReader",
408 "|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]",
414 "*prop": "colModel[]",
415 "dataIndex": "cust_name",
416 "header": "Company Name",
418 "xtype": "ColumnModel",
419 "|renderer": "function(v) { return String.format('{0}', v); }",
423 "*prop": "colModel[]",
424 "dataIndex": "lastyear_total",
427 "xtype": "ColumnModel",
428 "|renderer": "function(v,x,r) \n{\n return String.format('{0}', v + ' pcs'); \n}",
441 "|activate": "function() {\n _this.spanel = this;\n /* if (_this.sgrid) {\n _this.sgrid.footer.onClick('first');\n } */\n}"
444 "fitContainer": true,
447 "tableName": "Groups",
449 "xtype": "GridPanel",
454 "|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}",
455 "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}",
456 "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}"
459 "autoExpandColumn": "year_text",
462 "xtype": "EditorGrid",
463 "|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",
464 "|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 '<span style=\"color:red\">' + v + ' ( ' + est + ' )</span>';\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 '<span style=\"color:red\">MUST FILL IN (' + est + ')</span>';\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('<span style=\"color:green\">{0}%</span>', Roo.util.Format.number(v,2));\n } \n \n if(r.data.type == 'predicted' && v < 0){\n return String.format('<span style=\"color:red\">{0}</span>', 'BAD GUESS');\n }\n \n \n return String.format('{0}',v); \n\n}\n",
469 "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}"
471 "*prop": "dataSource",
474 "|sortInfo": "{ field : 'name', direction: 'ASC' }",
480 "xtype": "HttpProxy",
481 "|url": "baseURL + '/Roo/Salesforecast.php'",
488 "totalProperty": "total",
489 "xtype": "JsonReader",
490 "|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]",
501 "|xns": "Roo.Toolbar",
506 "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}"
508 "text": "Auto Fill (This Year)",
510 "|xns": "Roo.Toolbar"
516 "xtype": "PagingToolbar",
519 "displayMsg": "Displaying Groups{0} - {1} of {2}",
520 "emptyMsg": "No Groups found",
524 "*prop": "colModel[]",
525 "dataIndex": "year_text",
526 "header": "Scenario / Month",
528 "xtype": "ColumnModel",
529 "|renderer": "function(v) { return String.format('{0}', v); }",
533 "*prop": "colModel[]",
534 "dataIndex": "total_1",
537 "xtype": "ColumnModel",
538 "|renderer": "function(v,x,r) \n{\n return _this.sgrid.formatcol(v,r,this.name);\n}",
543 "xtype": "GridEditor",
548 "allowDecimals": false,
549 "xtype": "NumberField",
557 "*prop": "colModel[]",
558 "dataIndex": "total_2",
561 "xtype": "ColumnModel",
562 "|renderer": "function(v,x,r) \n{\n return _this.sgrid.formatcol(v,r,this.name);\n}",
567 "xtype": "GridEditor",
572 "allowDecimals": false,
573 "xtype": "NumberField",
581 "*prop": "colModel[]",
582 "dataIndex": "total_3",
585 "xtype": "ColumnModel",
586 "|renderer": "function(v,x,r) \n{\n return _this.sgrid.formatcol(v,r,this.name);\n}",
591 "xtype": "GridEditor",
596 "allowDecimals": false,
597 "xtype": "NumberField",
605 "*prop": "colModel[]",
606 "dataIndex": "total_4",
609 "xtype": "ColumnModel",
610 "|renderer": "function(v,x,r) \n{\n return _this.sgrid.formatcol(v,r,this.name);\n}",
615 "xtype": "GridEditor",
620 "allowDecimals": false,
621 "xtype": "NumberField",
629 "*prop": "colModel[]",
630 "dataIndex": "total_5",
633 "xtype": "ColumnModel",
634 "|renderer": "function(v,x,r) \n{\n return _this.sgrid.formatcol(v,r,this.name);\n}",
639 "xtype": "GridEditor",
644 "allowDecimals": false,
645 "xtype": "NumberField",
653 "*prop": "colModel[]",
654 "dataIndex": "total_6",
657 "xtype": "ColumnModel",
658 "|renderer": "function(v,x,r) \n{\n return _this.sgrid.formatcol(v,r,this.name);\n}",
663 "xtype": "GridEditor",
668 "allowDecimals": false,
669 "xtype": "NumberField",
677 "*prop": "colModel[]",
678 "dataIndex": "total_7",
681 "xtype": "ColumnModel",
682 "|renderer": "function(v,x,r) \n{\n return _this.sgrid.formatcol(v,r,this.name);\n}",
687 "xtype": "GridEditor",
692 "allowDecimals": false,
693 "xtype": "NumberField",
701 "*prop": "colModel[]",
702 "dataIndex": "total_8",
705 "xtype": "ColumnModel",
706 "|renderer": "function(v,x,r) \n{\n return _this.sgrid.formatcol(v,r,this.name);\n}",
711 "xtype": "GridEditor",
716 "allowDecimals": false,
717 "xtype": "NumberField",
725 "*prop": "colModel[]",
726 "dataIndex": "total_9",
729 "xtype": "ColumnModel",
730 "|renderer": "function(v,x,r) \n{\n return _this.sgrid.formatcol(v,r,this.name);\n}",
735 "xtype": "GridEditor",
740 "allowDecimals": false,
741 "xtype": "NumberField",
749 "*prop": "colModel[]",
750 "dataIndex": "total_10",
753 "xtype": "ColumnModel",
754 "|renderer": "function(v,x,r) \n{\n return _this.sgrid.formatcol(v,r,this.name);\n}",
759 "xtype": "GridEditor",
764 "allowDecimals": false,
765 "xtype": "NumberField",
773 "*prop": "colModel[]",
774 "dataIndex": "total_11",
777 "xtype": "ColumnModel",
778 "|renderer": "function(v,x,r) \n{\n return _this.sgrid.formatcol(v,r,this.name);\n}",
783 "xtype": "GridEditor",
788 "allowDecimals": false,
789 "xtype": "NumberField",
797 "*prop": "colModel[]",
798 "dataIndex": "total_12",
801 "xtype": "ColumnModel",
802 "|renderer": "function(v,x,r) \n{\n return _this.sgrid.formatcol(v,r,this.name);\n}",
807 "xtype": "GridEditor",
812 "allowDecimals": false,
813 "xtype": "NumberField",
821 "*prop": "colModel[]",
822 "dataIndex": "total_year",
825 "xtype": "ColumnModel",
826 "|renderer": "function(v) { return String.format('{0}', v); }",