Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Tab.XtupleSalesPlanning.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Tab.XtupleSalesPlanning = new Roo.XComponent({
6     part     :  ["Xtuple","SalesPlanning"],
7     order    : '600-Pman.Tab.XtupleSalesPlanning',
8     region   : 'center',
9     parent   : 'Pman.Tab.XtupleSales',
10     name     : "Pman.Tab.XtupleSalesPlanning",
11     disabled : false, 
12     permname : '', 
13     _tree : function()
14     {
15         var _this = this;
16         var MODULE = this;
17         return {
18             xtype: 'NestedLayoutPanel',
19             xns: Roo,
20             listeners : {
21                 activate : function (_self)
22                 {
23                    // Roo.log(Pman.hasPerm('Xtuple.SalesPlanner', 'S'));
24                    // Roo.log(Pman.Login.authUser);
25                 }
26             },
27             background : false,
28             fitContainer : true,
29             fitToFrame : true,
30             title : "Sales Planning",
31             layout : {
32                 xtype: 'BorderLayout',
33                 xns: Roo,
34                 items : [
35                     {
36                         xtype: 'NestedLayoutPanel',
37                         xns: Roo,
38                         listeners : {
39                             activate : function (_self)
40                             {
41                                 _self.layout.getRegion('center').showPanel(0);
42                             }
43                         },
44                         background : false,
45                         fitContainer : true,
46                         fitToFrame : true,
47                         region : 'center',
48                         layout : {
49                             xtype: 'BorderLayout',
50                             xns: Roo,
51                             items : [
52                                 {
53                                     xtype: 'GridPanel',
54                                     xns: Roo,
55                                     listeners : {
56                                         activate : function() {
57                                             _this.panel = this;
58                                             
59                                           //  if (_this.grid) {
60                                           //      _this.grid.footer.onClick('first');
61                                           //  }
62                                         }
63                                     },
64                                     background : false,
65                                     fitContainer : true,
66                                     fitToframe : true,
67                                     region : 'center',
68                                     tableName : 'item',
69                                     title : "Item",
70                                     grid : {
71                                         xtype: 'Grid',
72                                         xns: Roo.grid,
73                                         listeners : {
74                                             render : function() 
75                                             {
76                                                 _this.grid = this; 
77                                                 //_this.dialog = Pman.Dialog.FILL_IN
78                                               //  if (_this.panel.active) {
79                                                //    this.footer.onClick('first');
80                                               //  }
81                                             }
82                                         },
83                                         autoExpandColumn : 'item_descrip1',
84                                         loadMask : true,
85                                         sm : {
86                                             xtype: 'RowSelectionModel',
87                                             xns: Roo.grid,
88                                             listeners : {
89                                                 afterselectionchange : function (_self)
90                                                 {
91                                                     if (_this.sgrid) {
92                                                         _this.sgrid.footer.onClick('first');
93                                                     }
94                                                 }
95                                             },
96                                             singleSelect : true
97                                         },
98                                         dataSource : {
99                                             xtype: 'Store',
100                                             xns: Roo.data,
101                                             listeners : {
102                                                 beforeload : function (_self, o)
103                                                 {
104                                                     o.params = o.params || {};
105                                                     
106                                                     var s = _this.wgrid.getSelectionModel().getSelected();
107                                                     if(!s.data.cust_id){
108                                                         _this.grid.ds.removeAll();
109                                                         return false;
110                                                     }
111                                                     _this.sgrid.ds.removeAll();
112                                                     
113                                                     o.params._with_year_total = 1;
114                                                     
115                                                     o.params._charass_brand_value = _this.brandSel.getValue();
116                                                     o.params._charass_group_value = _this.groupSel.getValue();
117                                                     
118                                                     o.params._with_itemsrc_active = 1;
119                                                     o.params._in_cust_id = s.data.cust_id;
120                                                     
121                                                     var date = new Date();
122                                                     var year = date.getFullYear(); // four digits
123                                                     var month = date.getMonth(); // 0-11
124                                                     
125                                                     var cm = _this.grid.getColumnModel();
126                                                     function cid(str) {\r
127                                                         return cm.getIndexByDataIndex(str);\r
128                                                     }\r    
129                                                     
130                                                     cm.setColumnHeader(cid('total_before_last_year'),'Total ' + (year - 2));
131                                                     cm.setColumnHeader(cid('total_last_year'),'Total ' + (year - 1));
132                                                     cm.setColumnHeader(cid('forecast_this_year'),'Forecast ' + year);
133                                                     cm.setColumnHeader(cid('total_this_year'),'Total ' + year);
134                                                     
135                                                     if(month > 5){
136                                                         cm.setColumnHeader(cid('forecast_next_year'),'Total ' + (year + 1));
137                                                         cm.setHidden(cid('forecast_next_year'),false);
138                                                     }
139                                                     // it make the grid slow, change it later!
140                                                     if(s.data.cust_name == 'All Companies'){
141                                                         cm.setHidden(cid('forecast_this_year'),true);
142                                                         cm.setHidden(cid('company_estimates'),false);
143                                                     }else{
144                                                         cm.setHidden(cid('forecast_this_year'),false);
145                                                         cm.setHidden(cid('company_estimates'),true);
146                                                     }
147                                                     
148                                                 
149                                                 },
150                                                 load : function (_self, records, options)
151                                                 {
152                                                     var sm = _this.grid.getSelectionModel();
153                                                     Roo.each(records, function(record){
154                                                         if(record.data.item_id == _this.grid.lastSelectedId){
155                                                             sm.selectRow(_this.grid.ds.indexOf(record));
156                                                             if (_this.sgrid) {
157                                                                 _this.sgrid.footer.onClick('first');
158                                                             }
159                                                         }
160                                                     })
161                                                 }
162                                             },
163                                             remoteSort : true,
164                                             sortInfo : { field : 'item_number', direction: 'ASC' },
165                                             proxy : {
166                                                 xtype: 'HttpProxy',
167                                                 xns: Roo.data,
168                                                 method : 'GET',
169                                                 url : baseURL + '/Roo/Item.php'
170                                             },
171                                             reader : {
172                                                 xtype: 'JsonReader',
173                                                 xns: Roo.data,
174                                                 id : 'id',
175                                                 root : 'data',
176                                                 totalProperty : 'total',
177                                                 fields : [
178                                                     {
179                                                         'name': 'item_number',
180                                                         'type': 'string'
181                                                     },
182                                                     {
183                                                         'name': 'item_descrip1',
184                                                         'type': 'string'
185                                                     },
186                                                     {
187                                                         'name': 'total_before_last_year',
188                                                         'type': 'int'
189                                                     },
190                                                     {
191                                                         'name': 'total_last_year',
192                                                         'type': 'int'
193                                                     },
194                                                     {
195                                                         'name': 'forecast_this_year',
196                                                         'type': 'int'
197                                                     },
198                                                     {
199                                                         'name': 'total_this_year',
200                                                         'type': 'int'
201                                                     },
202                                                     {
203                                                         'name': 'total_next_year',
204                                                         'type': 'int'
205                                                     },
206                                                     {
207                                                         'name': 'forecast_next_year',
208                                                         'type': 'int'
209                                                     },
210                                                     {
211                                                         'name': 'last_forecast_entered',
212                                                         'type': 'string'
213                                                     }
214                                                 ]
215                                             }
216                                         },
217                                         footer : {
218                                             xtype: 'PagingToolbar',
219                                             xns: Roo,
220                                             displayInfo : true,
221                                             displayMsg : "Displaying Item{0} - {1} of {2}",
222                                             emptyMsg : "No Item found",
223                                             pageSize : 25
224                                         },
225                                         toolbar : {
226                                             xtype: 'Toolbar',
227                                             xns: Roo,
228                                             items : [
229                                                 {
230                                                     xtype: 'ComboBox',
231                                                     xns: Roo.form,
232                                                     listeners : {
233                                                         render : function (_self)
234                                                         {
235                                                           _this.brandSel = _self;
236                                                           
237                                                         },
238                                                         select : function (combo, record, index)
239                                                         {
240                                                             _this.wgrid.ds.load({});}
241                                                     },
242                                                     allowBlank : true,
243                                                     alwaysQuery : true,
244                                                     displayField : 'charass_value',
245                                                     editable : true,
246                                                     emptyText : "Select Brand",
247                                                     forceSelection : true,
248                                                     listWidth : 300,
249                                                     loadingText : "Searching...",
250                                                     minChars : 2,
251                                                     pageSize : 20,
252                                                     qtip : "Select Brand",
253                                                     queryParam : 'query[charass_value]',
254                                                     selectOnFocus : true,
255                                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{charass_value}</b> </div>',
256                                                     triggerAction : 'all',
257                                                     width : 200,
258                                                     store : {
259                                                         xtype: 'Store',
260                                                         xns: Roo.data,
261                                                         listeners : {
262                                                             beforeload : function (_self, o)
263                                                             {
264                                                                 o.params = o.params || {};
265                                                                 // staff can see all logs, other companies can only see their own.
266                                                                 // look for all of the charass 's with the same type= eg. brand.
267                                                                 
268                                                                 o.params.charass_char_id_char_name = 'BRAND';
269                                                                 o.params.charass_target_type ='I';
270                                                                 o.params._distinct = 'charass_value';
271                                                                 o.params._columns = 'charass_value';
272                                                             
273                                                             }
274                                                         },
275                                                         remoteSort : true,
276                                                         sortInfo : { field : 'charass_value' , direction : 'ASC' },
277                                                         proxy : {
278                                                             xtype: 'HttpProxy',
279                                                             xns: Roo.data,
280                                                             method : 'GET',
281                                                             url : baseURL + '/Roo/Charass.php'
282                                                         },
283                                                         reader : {
284                                                             xtype: 'JsonReader',
285                                                             xns: Roo.data,
286                                                             id : 'id',
287                                                             root : 'data',
288                                                             totalProperty : 'total',
289                                                             fields : [
290                                                                 {
291                                                                     'name': 'id',
292                                                                     'type': 'int'
293                                                                 },
294                                                                 {
295                                                                     'name': 'person_name',
296                                                                     'type': 'string'
297                                                                 },
298                                                                 {
299                                                                     'name': 'event_when',
300                                                                     'type': 'date',
301                                                                     'dateFormat': 'Y-m-d'
302                                                                 },
303                                                                 {
304                                                                     'name': 'action',
305                                                                     'type': 'string'
306                                                                 },
307                                                                 {
308                                                                     'name': 'ipaddr',
309                                                                     'type': 'string'
310                                                                 },
311                                                                 {
312                                                                     'name': 'on_id',
313                                                                     'type': 'int'
314                                                                 },
315                                                                 {
316                                                                     'name': 'on_table',
317                                                                     'type': 'string'
318                                                                 },
319                                                                 {
320                                                                     'name': 'person_id',
321                                                                     'type': 'int'
322                                                                 },
323                                                                 {
324                                                                     'name': 'remarks',
325                                                                     'type': 'string'
326                                                                 },
327                                                                 {
328                                                                     'name': 'person_id_id',
329                                                                     'type': 'int'
330                                                                 },
331                                                                 {
332                                                                     'name': 'person_id_office_id',
333                                                                     'type': 'int'
334                                                                 },
335                                                                 {
336                                                                     'name': 'person_id_name',
337                                                                     'type': 'string'
338                                                                 },
339                                                                 {
340                                                                     'name': 'person_id_phone',
341                                                                     'type': 'string'
342                                                                 },
343                                                                 {
344                                                                     'name': 'person_id_fax',
345                                                                     'type': 'string'
346                                                                 },
347                                                                 {
348                                                                     'name': 'person_id_email',
349                                                                     'type': 'string'
350                                                                 },
351                                                                 {
352                                                                     'name': 'person_id_company_id',
353                                                                     'type': 'int'
354                                                                 },
355                                                                 {
356                                                                     'name': 'person_id_role',
357                                                                     'type': 'string'
358                                                                 },
359                                                                 {
360                                                                     'name': 'person_id_active',
361                                                                     'type': 'int'
362                                                                 },
363                                                                 {
364                                                                     'name': 'person_id_remarks',
365                                                                     'type': 'string'
366                                                                 },
367                                                                 {
368                                                                     'name': 'person_id_passwd',
369                                                                     'type': 'string'
370                                                                 },
371                                                                 {
372                                                                     'name': 'person_id_owner_id',
373                                                                     'type': 'int'
374                                                                 },
375                                                                 {
376                                                                     'name': 'person_id_lang',
377                                                                     'type': 'string'
378                                                                 },
379                                                                 {
380                                                                     'name': 'person_id_no_reset_sent',
381                                                                     'type': 'int'
382                                                                 },
383                                                                 {
384                                                                     'name': 'person_id_action_type',
385                                                                     'type': 'string'
386                                                                 },
387                                                                 {
388                                                                     'name': 'person_id_project_id',
389                                                                     'type': 'int'
390                                                                 },
391                                                                 {
392                                                                     'name': 'person_id_deleted_by',
393                                                                     'type': 'int'
394                                                                 },
395                                                                 {
396                                                                     'name': 'person_id_deleted_dt',
397                                                                     'type': 'date'
398                                                                 }
399                                                             ]
400                                                         }
401                                                     }
402                                                 },
403                                                 {
404                                                     xtype: 'ComboBox',
405                                                     xns: Roo.form,
406                                                     listeners : {
407                                                         render : function (_self)
408                                                         {
409                                                           _this.groupSel = _self;
410                                                         },
411                                                         select : function (combo, record, index)
412                                                         {
413                                                             _this.wgrid.ds.load({});
414                                                         }
415                                                     },
416                                                     allowBlank : true,
417                                                     alwaysQuery : true,
418                                                     displayField : 'charass_value',
419                                                     editable : true,
420                                                     emptyText : "Select Product Group",
421                                                     forceSelection : true,
422                                                     listWidth : 300,
423                                                     loadingText : "Searching...",
424                                                     minChars : 2,
425                                                     pageSize : 20,
426                                                     qtip : "Select Product Group",
427                                                     queryParam : 'query[charass_value]',
428                                                     selectOnFocus : true,
429                                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{charass_value}</b> </div>',
430                                                     triggerAction : 'all',
431                                                     width : 200,
432                                                     store : {
433                                                         xtype: 'Store',
434                                                         xns: Roo.data,
435                                                         listeners : {
436                                                             beforeload : function (_self, o)
437                                                             {
438                                                                 o.params = o.params || {};
439                                                                 // staff can see all logs, other companies can only see their own.
440                                                                 // look for all of the charass 's with the same type= eg. brand.
441                                                                 
442                                                                 o.params.charass_char_id_char_name = 'PRODUCTGROUP';
443                                                                 o.params.charass_target_type ='I';
444                                                                 o.params._distinct = 'charass_value';
445                                                                     o.params._columns = 'charass_value';
446                                                             
447                                                             }
448                                                         },
449                                                         remoteSort : true,
450                                                         sortInfo : { field : 'charass_value' , direction : 'ASC' },
451                                                         proxy : {
452                                                             xtype: 'HttpProxy',
453                                                             xns: Roo.data,
454                                                             method : 'GET',
455                                                             url : baseURL + '/Roo/Charass.php'
456                                                         },
457                                                         reader : {
458                                                             xtype: 'JsonReader',
459                                                             xns: Roo.data,
460                                                             id : 'id',
461                                                             root : 'data',
462                                                             totalProperty : 'total',
463                                                             fields : [
464                                                                 {
465                                                                     'name': 'id',
466                                                                     'type': 'int'
467                                                                 },
468                                                                 {
469                                                                     'name': 'person_name',
470                                                                     'type': 'string'
471                                                                 },
472                                                                 {
473                                                                     'name': 'event_when',
474                                                                     'type': 'date',
475                                                                     'dateFormat': 'Y-m-d'
476                                                                 },
477                                                                 {
478                                                                     'name': 'action',
479                                                                     'type': 'string'
480                                                                 },
481                                                                 {
482                                                                     'name': 'ipaddr',
483                                                                     'type': 'string'
484                                                                 },
485                                                                 {
486                                                                     'name': 'on_id',
487                                                                     'type': 'int'
488                                                                 },
489                                                                 {
490                                                                     'name': 'on_table',
491                                                                     'type': 'string'
492                                                                 },
493                                                                 {
494                                                                     'name': 'person_id',
495                                                                     'type': 'int'
496                                                                 },
497                                                                 {
498                                                                     'name': 'remarks',
499                                                                     'type': 'string'
500                                                                 },
501                                                                 {
502                                                                     'name': 'person_id_id',
503                                                                     'type': 'int'
504                                                                 },
505                                                                 {
506                                                                     'name': 'person_id_office_id',
507                                                                     'type': 'int'
508                                                                 },
509                                                                 {
510                                                                     'name': 'person_id_name',
511                                                                     'type': 'string'
512                                                                 },
513                                                                 {
514                                                                     'name': 'person_id_phone',
515                                                                     'type': 'string'
516                                                                 },
517                                                                 {
518                                                                     'name': 'person_id_fax',
519                                                                     'type': 'string'
520                                                                 },
521                                                                 {
522                                                                     'name': 'person_id_email',
523                                                                     'type': 'string'
524                                                                 },
525                                                                 {
526                                                                     'name': 'person_id_company_id',
527                                                                     'type': 'int'
528                                                                 },
529                                                                 {
530                                                                     'name': 'person_id_role',
531                                                                     'type': 'string'
532                                                                 },
533                                                                 {
534                                                                     'name': 'person_id_active',
535                                                                     'type': 'int'
536                                                                 },
537                                                                 {
538                                                                     'name': 'person_id_remarks',
539                                                                     'type': 'string'
540                                                                 },
541                                                                 {
542                                                                     'name': 'person_id_passwd',
543                                                                     'type': 'string'
544                                                                 },
545                                                                 {
546                                                                     'name': 'person_id_owner_id',
547                                                                     'type': 'int'
548                                                                 },
549                                                                 {
550                                                                     'name': 'person_id_lang',
551                                                                     'type': 'string'
552                                                                 },
553                                                                 {
554                                                                     'name': 'person_id_no_reset_sent',
555                                                                     'type': 'int'
556                                                                 },
557                                                                 {
558                                                                     'name': 'person_id_action_type',
559                                                                     'type': 'string'
560                                                                 },
561                                                                 {
562                                                                     'name': 'person_id_project_id',
563                                                                     'type': 'int'
564                                                                 },
565                                                                 {
566                                                                     'name': 'person_id_deleted_by',
567                                                                     'type': 'int'
568                                                                 },
569                                                                 {
570                                                                     'name': 'person_id_deleted_dt',
571                                                                     'type': 'date'
572                                                                 }
573                                                             ]
574                                                         }
575                                                     }
576                                                 },
577                                                 {
578                                                     xtype: 'Fill',
579                                                     xns: Roo.Toolbar
580                                                 },
581                                                 {
582                                                     xtype: 'Button',
583                                                     xns: Roo.Toolbar,
584                                                     listeners : {
585                                                         click : function ()
586                                                         {
587                                                             var brand = _this.brandSel.getValue();
588                                                             var group = _this.groupSel.getValue();
589                                                             
590                                                             if(!brand && !group){
591                                                                 Roo.MessageBox.alert('Error','Please select the brand or group');
592                                                                 return;
593                                                             }
594                                                             
595                                                             Roo.MessageBox.alert("Notice","Your report should be downloading now");
596                                                             
597                                                             new Pman.download({
598                                                                 url : baseURL + '/Roo/Salesforecast',
599                                                                 method : 'GET',
600                                                                 timeout: 900000,
601                                                                 params : {
602                                                                     '_download' : 1,
603                                                                     'brand' : brand,
604                                                                     'group' : group
605                                                                 }
606                                                             });  
607                                                            
608                                                         }
609                                                     },
610                                                     cls : 'x-btn-text-icon',
611                                                     text : "Download Report",
612                                                     icon : rootURL + '/Pman/templates/images/spreadsheet.gif'
613                                                 }
614                                             ]
615                                         },
616                                         colModel : [
617                                             {
618                                                 xtype: 'ColumnModel',
619                                                 xns: Roo.grid,
620                                                 dataIndex : 'itemsrc_active',
621                                                 header : 'is Active?',
622                                                 width : 50,
623                                                 renderer : function(v) {  
624                                                     var state = v * 1 > 0 ?  '-checked' : '';
625                                                 
626                                                     return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
627                                                                 
628                                                  }
629                                             },
630                                             {
631                                                 xtype: 'ColumnModel',
632                                                 xns: Roo.grid,
633                                                 dataIndex : 'item_number',
634                                                 header : 'Item code',
635                                                 width : 200,
636                                                 renderer : function(v) { return String.format('{0}', v); }
637                                             },
638                                             {
639                                                 xtype: 'ColumnModel',
640                                                 xns: Roo.grid,
641                                                 dataIndex : 'item_descrip1',
642                                                 header : 'Item name',
643                                                 width : 200,
644                                                 renderer : function(v) { return String.format('{0}', v); }
645                                             },
646                                             {
647                                                 xtype: 'ColumnModel',
648                                                 xns: Roo.grid,
649                                                 dataIndex : 'total_before_last_year',
650                                                 header : 'Total',
651                                                 width : 150,
652                                                 renderer : function(v) { return String.format('{0}', v); }
653                                             },
654                                             {
655                                                 xtype: 'ColumnModel',
656                                                 xns: Roo.grid,
657                                                 dataIndex : 'total_last_year',
658                                                 header : 'Total',
659                                                 width : 150,
660                                                 renderer : function(v) { return String.format('{0}', v); }
661                                             },
662                                             {
663                                                 xtype: 'ColumnModel',
664                                                 xns: Roo.grid,
665                                                 dataIndex : 'forecast_this_year',
666                                                 header : 'Forecast',
667                                                 width : 150,
668                                                 renderer : function(v,x,r) { 
669                                                     
670                                                     if (v*1 == 0) {
671                                                     
672                                                         return '<span style="color:red">' + v + '</span>';
673                                                     }
674                                                     
675                                                     return String.format('{0}', v);
676                                                     
677                                                     
678                                                 }
679                                             },
680                                             {
681                                                 xtype: 'ColumnModel',
682                                                 xns: Roo.grid,
683                                                 dataIndex : 'total_this_year',
684                                                 header : 'Total',
685                                                 width : 150,
686                                                 renderer : function(v) { return String.format('{0}', v); }
687                                             },
688                                             {
689                                                 xtype: 'ColumnModel',
690                                                 xns: Roo.grid,
691                                                 dataIndex : 'forecast_next_year',
692                                                 header : 'Forecast',
693                                                 hidden : true,
694                                                 width : 150,
695                                                 renderer : function(v,x,r) { 
696                                                     
697                                                     if (v*1 == 0) {
698                                                     
699                                                         return '<span style="color:red">' + v + '</span>';
700                                                     }
701                                                     
702                                                     return String.format('{0}', v);
703                                                     
704                                                     
705                                                 }
706                                             },
707                                             {
708                                                 xtype: 'ColumnModel',
709                                                 xns: Roo.grid,
710                                                 dataIndex : 'last_forecast_entered',
711                                                 header : 'Last forcast entered',
712                                                 width : 150,
713                                                 renderer : function(v,x,r) {
714                                                     if(!v){
715                                                         return;
716                                                     }
717                                                     var last_forecast = new Date(v);
718                                                     
719                                                     var date = new Date();
720                                                     var y = date.getFullYear();
721                                                     var m = date.getMonth() + 3;
722                                                     var d = date.getDate();
723                                                     if(m >= 11){
724                                                         y = y + 1;
725                                                         m = m - 11;
726                                                     }
727                                                     var c = new Date(y,m,d);
728                                                     if (last_forecast < c) {
729                                                         return '<span style="color:red">' + last_forecast.format('M Y') + '</span>';
730                                                     }
731                                                     
732                                                     return String.format('{0}', last_forecast.format('M Y'));
733                                                     
734                                                     
735                                                 }
736                                             },
737                                             {
738                                                 xtype: 'ColumnModel',
739                                                 xns: Roo.grid,
740                                                 dataIndex : 'company_estimates',
741                                                 header : 'Estimates',
742                                                 hidden : true,
743                                                 width : 150,
744                                                 renderer : function(v,x,r) {
745                                                     return String.format('{0}', v);
746                                                     
747                                                     
748                                                 }
749                                             }
750                                         ]
751                                     }
752                                 },
753                                 {
754                                     xtype: 'GridPanel',
755                                     xns: Roo,
756                                     listeners : {
757                                         activate : function() {
758                                             _this.wpanel = this;
759                                             if (_this.wgrid) {
760                                                 _this.wgrid.ds.load({});
761                                             }
762                                         }
763                                     },
764                                     background : true,
765                                     fitContainer : true,
766                                     fitToframe : true,
767                                     region : 'west',
768                                     tableName : 'custinfo',
769                                     title : "Customer",
770                                     grid : {
771                                         xtype: 'Grid',
772                                         xns: Roo.grid,
773                                         listeners : {
774                                             render : function() 
775                                             {
776                                                 _this.wgrid = this; 
777                                                 if (_this.wpanel.active) {
778                                                     _this.wgrid.ds.load({});
779                                                 }
780                                             },
781                                             rowclick : function (_self, rowIndex, e)
782                                             {
783                                                 var sm = _this.grid.getSelectionModel();
784                                                if(sm.getSelections().length){
785                                                      _this.grid.lastSelectedId = sm.getSelections()[0].data.item_id;
786                                                  }
787                                                 _this.grid.footer.onClick('refresh');
788                                             }
789                                         },
790                                         autoExpandColumn : 'cust_name_with_pcs',
791                                         loadMask : true,
792                                         dataSource : {
793                                             xtype: 'Store',
794                                             xns: Roo.data,
795                                             listeners : {
796                                                 beforeload : function (_self, o){
797                                                     o.params = o.params || {};
798                                                     
799                                                     o.params._with_lastyear_total = 1;
800                                                     o.params._columns = 'cust_id,cust_name,lastyear_total';
801                                                     
802                                                     var brand = _this.brandSel.getValue();
803                                                     if(!brand.length){
804                                                         _this.wgrid.ds.removeAll();
805                                                         _this.grid.ds.removeAll();
806                                                         return false;
807                                                     }
808                                                     
809                                                     o.params._charass_brand_value = _this.brandSel.getValue();
810                                                     o.params._charass_group_value = _this.groupSel.getValue();
811                                                     
812                                                     o.params.limit = 9999;
813                                                     
814                                                 },
815                                                 load : function (_self, records, options)
816                                                 {
817                                                     var sm = _this.wgrid.getSelectionModel();
818                                                     if (!sm.getSelections().length) {
819                                                         sm.selectFirstRow();
820                                                     }
821                                                     
822                                                     _this.grid.footer.onClick('first');
823                                                 }
824                                             },
825                                             remoteSort : true,
826                                             sortInfo : { field : 'lastyear_total', direction: 'DESC' },
827                                             proxy : {
828                                                 xtype: 'HttpProxy',
829                                                 xns: Roo.data,
830                                                 method : 'GET',
831                                                 url : baseURL + '/Roo/Custinfo.php'
832                                             },
833                                             reader : {
834                                                 xtype: 'JsonReader',
835                                                 xns: Roo.data,
836                                                 id : 'id',
837                                                 root : 'data',
838                                                 totalProperty : 'total',
839                                                 fields : [
840                                                     {
841                                                         'name': 'cust_id',
842                                                         'type': 'int'
843                                                     },
844                                                     {
845                                                         'name': 'cust_name_with_pcs',
846                                                         'type': 'string'
847                                                     },
848                                                     {
849                                                         'name': 'lastyear_total',
850                                                         'type': 'int'
851                                                     }
852                                                 ]
853                                             }
854                                         },
855                                         colModel : [
856                                             {
857                                                 xtype: 'ColumnModel',
858                                                 xns: Roo.grid,
859                                                 dataIndex : 'cust_name',
860                                                 header : 'Company Name',
861                                                 width : 200,
862                                                 renderer : function(v) { return String.format('{0}', v); }
863                                             },
864                                             {
865                                                 xtype: 'ColumnModel',
866                                                 xns: Roo.grid,
867                                                 dataIndex : 'lastyear_total',
868                                                 header : '',
869                                                 width : 75,
870                                                 renderer : function(v,x,r) 
871                                                 {
872                                                     return String.format('{0}', v + ' pcs'); 
873                                                 }
874                                             }
875                                         ]
876                                     }
877                                 }
878                             ],
879                             center : {
880                                 xtype: 'LayoutRegion',
881                                 xns: Roo
882                             },
883                             west : {
884                                 xtype: 'LayoutRegion',
885                                 xns: Roo,
886                                 split : true,
887                                 tabPosition : 'top',
888                                 width : 300
889                             }
890                         }
891                     },
892                     {
893                         xtype: 'GridPanel',
894                         xns: Roo,
895                         listeners : {
896                             activate : function() {
897                                 _this.spanel = this;
898                               /*  if (_this.sgrid) {
899                                     _this.sgrid.footer.onClick('first');
900                                 } */
901                             }
902                         },
903                         background : false,
904                         fitContainer : true,
905                         fitToframe : true,
906                         region : 'south',
907                         tableName : 'Groups',
908                         title : "Details",
909                         grid : {
910                             xtype: 'EditorGrid',
911                             xns: Roo.grid,
912                             listeners : {
913                                 render : function() 
914                                 {
915                                     _this.sgrid = this; 
916                                     //_this.dialog = Pman.Dialog.FILL_IN
917                                    /* if (_this.spanel.active) {
918                                        this.footer.onClick('first');
919                                     } */
920                                 },
921                                 afteredit : function (e)
922                                 {
923                                     _this.grid.loadMask.el.unmask();
924                                     _this.wgrid.loadMask.el.unmask();
925                                     if(e.value == e.originalValue){
926                                         return;
927                                     }
928                                     var field = e.field;
929                                     var salesforecast_id = e.record.json[field + '_salesforecast_id'];
930                                     var rec = _this.grid.getSelectionModel().getSelected();
931                                     var s = _this.wgrid.getSelectionModel().getSelected();
932                                     
933                                     if(!rec || !s){
934                                         Roo.Msg.alert("Error","Please select a item");
935                                         return;
936                                     }
937                                     
938                                     var params = {
939                                             salesforecast_id : (salesforecast_id * 1 > 0) ? salesforecast_id : 0,
940                                             salesforecast_cust_id : (s.data.cust_id < 0) ? 0 : s.data.cust_id,
941                                             salesforecast_is_all_buyers : (s.data.view_type) == 'All' ? 1 : 0,
942                                             _item_id : rec.data.item_id,
943                                             month : e.column,
944                                             year : e.record.data['year']
945                                         }
946                                     
947                                     if(s.data.cust_id > 0){ // company level confirm and request editable!
948                                         if(e.record.data['type'] == 'confirm'){
949                                             params.salesforecast_qty = e.value;
950                                         }
951                                         if(e.record.data['type'] == 'request'){
952                                             params.salesforecast_requests = e.value;
953                                         }
954                                     } else { // item level estimated and total forecast editable!
955                                         if(e.record.data['type'] == 'estimated'){
956                                             params.salesforecast_qty = e.value;
957                                         }
958                                         if(e.record.data['type'] == 'forecast'){
959                                             params.salesforecast_sum = e.value;
960                                         }
961                                     }
962                                     
963                                     
964                                     new Pman.Request({
965                                         url : baseURL + '/Roo/Salesforecast.php',
966                                         method :'POST',
967                                         params : params,
968                                         success : function() {
969                                            
970                                             _this.sgrid.footer.onClick('first');
971                                             
972                                         }
973                                     });
974                                     
975                                 },
976                                 beforeedit : function (e)
977                                 {   
978                                     var rec = e.record;
979                                     var y = new Date().getFullYear();
980                                     var m = new Date().getMonth(); // 0-11
981                                     var s = _this.grid.getSelectionModel().getSelected();
982                                     var ss = _this.wgrid.getSelectionModel().getSelected();
983                                    
984                                    /*\r
985                                     if(rec.data.type != 'forecast' || rec.data.year != y || !s.data.itemsrc_active || e.column < m + 3){\r
986                                         return false;\r
987                                     }
988                                     */
989                                 
990                                     if(s.data.itemsrc_active * 1 < 1 || (rec.data.year == y && e.column < m + 3) || (rec.data.year != y && e.column + 12 < m + 3)){
991                                         return false;
992                                     }
993                                     if(ss.data.cust_id > 0){ // companies level, confirm and request editable!
994                                         if(rec.data.type != 'confirm' && rec.data.type != 'request'){
995                                             return false;
996                                         }
997                                     }else{ // item level, estimated and total forecast  editable!
998                                         if(rec.data.type != 'estimated' && rec.data.type != 'forecast'){
999                                             return false;
1000                                         }
1001                                     }
1002                                     
1003                                     _this.grid.loadMask.el.mask('Cancel edit forecast first!');
1004                                     _this.wgrid.loadMask.el.mask('Cancel edit forecast first!');\r
1005                                 }
1006                             },
1007                             autoExpandColumn : 'year_text',
1008                             clicksToEdit : 1,
1009                             loadMask : true,
1010                             calcest : function(colname) 
1011                             {
1012                             
1013                                 var before = _this.sgrid.ds.getAt(0).data[colname];
1014                                 var last = _this.sgrid.ds.getAt(1).data[colname];
1015                                 var est = last * 2;
1016                                 if(before < last * 2){
1017                                    est = last * 2 - before;
1018                                 }
1019                                 return est;
1020                             },
1021                             formatcol : function(v,r,n) 
1022                             {
1023                                var d = new Date();
1024                                var y = d.getFullYear();
1025                                var m = d.getMonth();
1026                                var month = n.split("_");
1027                              //  var est =  _this.sgrid.calcest(n);
1028                              /*  if(r.data.type == 'forecast' && r.data.year == y && r.json.is_all_buyers == 0){
1029                                     if(month[1] < m + 3)
1030                                     { // fill in blank if the month less than next month
1031                                         return String.format('{0}',''); 
1032                                     }
1033                                     if(est > v || v > est * 2 || v * 1 == 0)
1034                                     { //red if forcast is less than estimate or double estimate
1035                                         return '<span style="color:red">' + v + ' ( ' + est + ' )</span>';
1036                                     }
1037                                     return String.format('{0}',v + ' ( ' + est + ' )'); 
1038                                 }
1039                                 if(r.data.type == 'forecast' && r.data.year == y && r.json.is_all_buyers == 1){
1040                                     var t = '';
1041                                     if((typeof(v) != undefined && v > 0)){
1042                                         t += v + ' ';
1043                                     }
1044                                     if(typeof(r.json[n + '_sum']) != undefined && r.json[n + '_sum'] > 0){
1045                                         t += 'sum( ' + r.json[n + '_sum'] + ' )';
1046                                     }
1047                                     if(month[1] > m + 2 && month[1] < m + 7 && !t){
1048                                         return '<span style="color:red">MUST FILL IN (' + est + ')</span>';
1049                                     }
1050                                     return String.format('{0}',t); 
1051                                 }
1052                                 */
1053                                 
1054                                 var s = _this.wgrid.getSelectionModel().getSelected();
1055                                 
1056                                 // forecast - item level 
1057                                 
1058                                 
1059                                 if(r.data.type == 'confirm' && s.data.cust_id < 0 && v){
1060                                     return String.format('SUM ( {0} )',v); 
1061                                 } 
1062                                 
1063                                 if(r.data.type == 'percentage' && v){
1064                                     return  String.format('<span style="color:green">{0}%</span>', Roo.util.Format.number(v,2));
1065                                 } 
1066                                 
1067                                 if(r.data.type == 'predicted' && v < 0){
1068                                     return  String.format('<span style="color:red">{0}</span>', 'BAD GUESS');
1069                                 }
1070                                 
1071                                 
1072                                 return String.format('{0}',v); 
1073                             
1074                             },
1075                             dataSource : {
1076                                 xtype: 'Store',
1077                                 xns: Roo.data,
1078                                 listeners : {
1079                                     beforeload : function (_self, o)
1080                                     {
1081                                         o.params = o.params || {};
1082                                         
1083                                         var rec = _this.grid.getSelectionModel().getSelected();
1084                                         var s = _this.wgrid.getSelectionModel().getSelected();
1085                                         
1086                                         if(!_this.grid || !rec || !s){
1087                                             this.removeAll();
1088                                             return;
1089                                         }
1090                                         
1091                                         o.params._detailView = 1;
1092                                         o.params._item_id = rec.data.item_id;
1093                                         o.params._in_cust_id = (s.data.cust_id < 0) ? 0 : s.data.cust_id;\r
1094                                         o.params._is_all_buyers = (s.data.view_type) == 'All' ? 1 : 0;
1095                                         \r
1096                                     }
1097                                 },
1098                                 remoteSort : true,
1099                                 sortInfo : { field : 'name', direction: 'ASC' },
1100                                 proxy : {
1101                                     xtype: 'HttpProxy',
1102                                     xns: Roo.data,
1103                                     method : 'GET',
1104                                     url : baseURL + '/Roo/Salesforecast.php'
1105                                 },
1106                                 reader : {
1107                                     xtype: 'JsonReader',
1108                                     xns: Roo.data,
1109                                     id : 'id',
1110                                     root : 'data',
1111                                     totalProperty : 'total',
1112                                     fields : [
1113                                         {
1114                                             'name': 'total_1',
1115                                             'type': 'int'
1116                                         },
1117                                         {
1118                                             'name': 'total_2',
1119                                             'type': 'int'
1120                                         },
1121                                         {
1122                                             'name': 'total_3',
1123                                             'type': 'int'
1124                                         },
1125                                         {
1126                                             'name': 'total_4',
1127                                             'type': 'int'
1128                                         },
1129                                         {
1130                                             'name': 'total_5',
1131                                             'type': 'int'
1132                                         },
1133                                         {
1134                                             'name': 'total_6',
1135                                             'type': 'int'
1136                                         },
1137                                         {
1138                                             'name': 'total_7',
1139                                             'type': 'int'
1140                                         },
1141                                         {
1142                                             'name': 'total_8',
1143                                             'type': 'int'
1144                                         },
1145                                         {
1146                                             'name': 'total_9',
1147                                             'type': 'int'
1148                                         },
1149                                         {
1150                                             'name': 'total_10',
1151                                             'type': 'int'
1152                                         },
1153                                         {
1154                                             'name': 'total_11',
1155                                             'type': 'int'
1156                                         },
1157                                         {
1158                                             'name': 'total_12',
1159                                             'type': 'int'
1160                                         },
1161                                         {
1162                                             'name': 'type',
1163                                             'type': 'string'
1164                                         },
1165                                         {
1166                                             'name': 'year_text',
1167                                             'type': 'string'
1168                                         },
1169                                         {
1170                                             'name': 'year',
1171                                             'type': 'int'
1172                                         }
1173                                     ]
1174                                 }
1175                             },
1176                             toolbar : {
1177                                 xtype: 'Toolbar',
1178                                 xns: Roo,
1179                                 items : [
1180                                     {
1181                                         xtype: 'Fill',
1182                                         xns: Roo.Toolbar
1183                                     },
1184                                     {
1185                                         xtype: 'Button',
1186                                         xns: Roo.Toolbar,
1187                                         listeners : {
1188                                             click : function (_self, e)
1189                                             {
1190                                                 var d = new Date();
1191                                                 var m = d.getMonth(); // getMonth -> 0-11
1192                                                 var y = new Date().getFullYear();
1193                                                 
1194                                                 var salesforecasts = [];
1195                                                 var est = 0;
1196                                                 var salesforecast_id = 0;
1197                                                 var qty = 0;
1198                                                 var rec = _this.grid.getSelectionModel().getSelected();\r
1199                                                 var s = _this.wgrid.getSelectionModel().getSelected();
1200                                                 if(!rec || !s){
1201                                                     Roo.Msg.alert("Error","Please select a item");
1202                                                     return;
1203                                                 }
1204                                                 if(rec.data.itemsrc_active * 1 < 1 ){
1205                                                     Roo.Msg.alert("Error","The itemsrc is not active!");
1206                                                     return;
1207                                                 }
1208                                                 if(s.data.cust_id < 0){
1209                                                     Roo.Msg.alert("Error","Auto Fill Just happen on company level, please select a company!");
1210                                                     return;
1211                                                 }
1212                                             
1213                                                 for(var i = 3; i < 13 - m; i++){ //  current month and the next month are not able to edit.
1214                                                 
1215                                                     var salesforecast = {};
1216                                                     
1217                                                     salesforecast_id = _this.sgrid.ds.getAt(3).json['total_' + (m + i) + '_salesforecast_id']; // check existing or not ???
1218                                                     est = _this.sgrid.ds.getAt(2).json['total_' + (m + i)]; // estimated qty!
1219                                                     qty = _this.sgrid.ds.getAt(3).json['total_' + (m + i)]; // existing qty!
1220                                                     
1221                                                     salesforecast['month'] = m + i; // period month
1222                                                     salesforecast['year'] = y; // period year
1223                                                     
1224                                                     salesforecast['salesforecast_id'] = (salesforecast_id * 1 > 0) ? salesforecast_id : 0; // update or insert ???
1225                                                     salesforecast['salesforecast_qty'] = (qty != 0) ? qty : est; // if we have entried in this period. do not use the estimated
1226                                                     
1227                                                     salesforecast['_item_id'] = rec.data.item_id;
1228                                                     
1229                                                     salesforecast['salesforecast_cust_id'] = s.data.cust_id;
1230                                                     
1231                                                     salesforecast['salesforecast_is_all_buyers'] = 0;
1232                                                     
1233                                                     salesforecasts.push((salesforecast)); 
1234                                                 }
1235                                                 
1236                                                 if(!salesforecasts.length){
1237                                                     return;
1238                                                 }
1239                                                 new Pman.Request({
1240                                                     url : baseURL + '/Roo/Salesforecast.php',
1241                                                     method :'POST',
1242                                                     params : {
1243                                                         _group_data : Roo.encode(salesforecasts)
1244                                                         
1245                                                     },
1246                                                     success : function() {
1247                                                        
1248                                                         _this.sgrid.footer.onClick('first');
1249                                                         
1250                                                     }
1251                                                 });
1252                                                 
1253                                              
1254                                             }
1255                                         },
1256                                         text : "Auto Fill  (This Year)"
1257                                     }
1258                                 ]
1259                             },
1260                             footer : {
1261                                 xtype: 'PagingToolbar',
1262                                 xns: Roo,
1263                                 pageSize : 25,
1264                                 displayInfo : true,
1265                                 displayMsg : "Displaying Groups{0} - {1} of {2}",
1266                                 emptyMsg : "No Groups found"
1267                             },
1268                             colModel : [
1269                                 {
1270                                     xtype: 'ColumnModel',
1271                                     xns: Roo.grid,
1272                                     dataIndex : 'year_text',
1273                                     header : 'Scenario / Month',
1274                                     width : 200,
1275                                     renderer : function(v) { return String.format('{0}', v); }
1276                                 },
1277                                 {
1278                                     xtype: 'ColumnModel',
1279                                     xns: Roo.grid,
1280                                     dataIndex : 'total_1',
1281                                     header : 'Jan',
1282                                     width : 100,
1283                                     renderer : function(v,x,r) 
1284                                     {
1285                                        return _this.sgrid.formatcol(v,r,this.name);
1286                                     },
1287                                     editor : {
1288                                         xtype: 'GridEditor',
1289                                         xns: Roo.grid,
1290                                         field : {
1291                                             xtype: 'NumberField',
1292                                             xns: Roo.form,
1293                                             allowDecimals : false
1294                                         }
1295                                     }
1296                                 },
1297                                 {
1298                                     xtype: 'ColumnModel',
1299                                     xns: Roo.grid,
1300                                     dataIndex : 'total_2',
1301                                     header : 'Feb',
1302                                     width : 100,
1303                                     renderer : function(v,x,r) 
1304                                     {
1305                                        return _this.sgrid.formatcol(v,r,this.name);
1306                                     },
1307                                     editor : {
1308                                         xtype: 'GridEditor',
1309                                         xns: Roo.grid,
1310                                         field : {
1311                                             xtype: 'NumberField',
1312                                             xns: Roo.form,
1313                                             allowDecimals : false
1314                                         }
1315                                     }
1316                                 },
1317                                 {
1318                                     xtype: 'ColumnModel',
1319                                     xns: Roo.grid,
1320                                     dataIndex : 'total_3',
1321                                     header : 'Mar',
1322                                     width : 100,
1323                                     renderer : function(v,x,r) 
1324                                     {
1325                                        return _this.sgrid.formatcol(v,r,this.name);
1326                                     },
1327                                     editor : {
1328                                         xtype: 'GridEditor',
1329                                         xns: Roo.grid,
1330                                         field : {
1331                                             xtype: 'NumberField',
1332                                             xns: Roo.form,
1333                                             allowDecimals : false
1334                                         }
1335                                     }
1336                                 },
1337                                 {
1338                                     xtype: 'ColumnModel',
1339                                     xns: Roo.grid,
1340                                     dataIndex : 'total_4',
1341                                     header : 'Apr',
1342                                     width : 100,
1343                                     renderer : function(v,x,r) 
1344                                     {
1345                                        return _this.sgrid.formatcol(v,r,this.name);
1346                                     },
1347                                     editor : {
1348                                         xtype: 'GridEditor',
1349                                         xns: Roo.grid,
1350                                         field : {
1351                                             xtype: 'NumberField',
1352                                             xns: Roo.form,
1353                                             allowDecimals : false
1354                                         }
1355                                     }
1356                                 },
1357                                 {
1358                                     xtype: 'ColumnModel',
1359                                     xns: Roo.grid,
1360                                     dataIndex : 'total_5',
1361                                     header : 'May',
1362                                     width : 100,
1363                                     renderer : function(v,x,r) 
1364                                     {
1365                                        return _this.sgrid.formatcol(v,r,this.name);
1366                                     },
1367                                     editor : {
1368                                         xtype: 'GridEditor',
1369                                         xns: Roo.grid,
1370                                         field : {
1371                                             xtype: 'NumberField',
1372                                             xns: Roo.form,
1373                                             allowDecimals : false
1374                                         }
1375                                     }
1376                                 },
1377                                 {
1378                                     xtype: 'ColumnModel',
1379                                     xns: Roo.grid,
1380                                     dataIndex : 'total_6',
1381                                     header : 'Jun',
1382                                     width : 100,
1383                                     renderer : function(v,x,r) 
1384                                     {
1385                                        return _this.sgrid.formatcol(v,r,this.name);
1386                                     },
1387                                     editor : {
1388                                         xtype: 'GridEditor',
1389                                         xns: Roo.grid,
1390                                         field : {
1391                                             xtype: 'NumberField',
1392                                             xns: Roo.form,
1393                                             allowDecimals : false
1394                                         }
1395                                     }
1396                                 },
1397                                 {
1398                                     xtype: 'ColumnModel',
1399                                     xns: Roo.grid,
1400                                     dataIndex : 'total_7',
1401                                     header : 'Jul',
1402                                     width : 100,
1403                                     renderer : function(v,x,r) 
1404                                     {
1405                                        return _this.sgrid.formatcol(v,r,this.name);
1406                                     },
1407                                     editor : {
1408                                         xtype: 'GridEditor',
1409                                         xns: Roo.grid,
1410                                         field : {
1411                                             xtype: 'NumberField',
1412                                             xns: Roo.form,
1413                                             allowDecimals : false
1414                                         }
1415                                     }
1416                                 },
1417                                 {
1418                                     xtype: 'ColumnModel',
1419                                     xns: Roo.grid,
1420                                     dataIndex : 'total_8',
1421                                     header : 'Aug',
1422                                     width : 100,
1423                                     renderer : function(v,x,r) 
1424                                     {
1425                                        return _this.sgrid.formatcol(v,r,this.name);
1426                                     },
1427                                     editor : {
1428                                         xtype: 'GridEditor',
1429                                         xns: Roo.grid,
1430                                         field : {
1431                                             xtype: 'NumberField',
1432                                             xns: Roo.form,
1433                                             allowDecimals : false
1434                                         }
1435                                     }
1436                                 },
1437                                 {
1438                                     xtype: 'ColumnModel',
1439                                     xns: Roo.grid,
1440                                     dataIndex : 'total_9',
1441                                     header : 'Sep',
1442                                     width : 100,
1443                                     renderer : function(v,x,r) 
1444                                     {
1445                                        return _this.sgrid.formatcol(v,r,this.name);
1446                                     },
1447                                     editor : {
1448                                         xtype: 'GridEditor',
1449                                         xns: Roo.grid,
1450                                         field : {
1451                                             xtype: 'NumberField',
1452                                             xns: Roo.form,
1453                                             allowDecimals : false
1454                                         }
1455                                     }
1456                                 },
1457                                 {
1458                                     xtype: 'ColumnModel',
1459                                     xns: Roo.grid,
1460                                     dataIndex : 'total_10',
1461                                     header : 'Oct',
1462                                     width : 100,
1463                                     renderer : function(v,x,r) 
1464                                     {
1465                                        return _this.sgrid.formatcol(v,r,this.name);
1466                                     },
1467                                     editor : {
1468                                         xtype: 'GridEditor',
1469                                         xns: Roo.grid,
1470                                         field : {
1471                                             xtype: 'NumberField',
1472                                             xns: Roo.form,
1473                                             allowDecimals : false
1474                                         }
1475                                     }
1476                                 },
1477                                 {
1478                                     xtype: 'ColumnModel',
1479                                     xns: Roo.grid,
1480                                     dataIndex : 'total_11',
1481                                     header : 'Nov',
1482                                     width : 100,
1483                                     renderer : function(v,x,r) 
1484                                     {
1485                                        return _this.sgrid.formatcol(v,r,this.name);
1486                                     },
1487                                     editor : {
1488                                         xtype: 'GridEditor',
1489                                         xns: Roo.grid,
1490                                         field : {
1491                                             xtype: 'NumberField',
1492                                             xns: Roo.form,
1493                                             allowDecimals : false
1494                                         }
1495                                     }
1496                                 },
1497                                 {
1498                                     xtype: 'ColumnModel',
1499                                     xns: Roo.grid,
1500                                     dataIndex : 'total_12',
1501                                     header : 'Dec',
1502                                     width : 100,
1503                                     renderer : function(v,x,r) 
1504                                     {
1505                                        return _this.sgrid.formatcol(v,r,this.name);
1506                                     },
1507                                     editor : {
1508                                         xtype: 'GridEditor',
1509                                         xns: Roo.grid,
1510                                         field : {
1511                                             xtype: 'NumberField',
1512                                             xns: Roo.form,
1513                                             allowDecimals : false
1514                                         }
1515                                     }
1516                                 },
1517                                 {
1518                                     xtype: 'ColumnModel',
1519                                     xns: Roo.grid,
1520                                     dataIndex : 'total_year',
1521                                     header : 'Total',
1522                                     width : 100,
1523                                     renderer : function(v) { return String.format('{0}', v); }
1524                                 }
1525                             ]
1526                         }
1527                     }
1528                 ],
1529                 center : {
1530                     xtype: 'LayoutRegion',
1531                     xns: Roo
1532                 },
1533                 south : {
1534                     xtype: 'LayoutRegion',
1535                     xns: Roo,
1536                     height : 400,
1537                     split : true
1538                 }
1539             }
1540         };
1541     }
1542 });