Pman.Tab.XtuplePriceLists.bjs
[Pman.Xtuple] / Pman.Tab.XtuplePriceLists.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.XtuplePriceLists = new Roo.XComponent({
6     part     :  ["Xtuple","PriceLists"],
7     order    : '001-Pman.Tab.XtuplePriceLists',
8     region   : 'center',
9     parent   : 'Pman.Tab.XtupleManage',
10     name     : "Pman.Tab.XtuplePriceLists",
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             background : true,
21             fitContainer : true,
22             fitToFrame : true,
23             region : 'center',
24             title : "Price List",
25             layout : {
26                 xtype: 'BorderLayout',
27                 xns: Roo,
28                 items : [
29                     {
30                         xtype: 'GridPanel',
31                         xns: Roo,
32                         listeners : {
33                             activate : function() {
34                                 _this.panel = this;
35                                 if (_this.grid) {
36                                     _this.grid.footer.onClick('first');
37                                 }
38                             }
39                         },
40                         background : true,
41                         fitContainer : true,
42                         fitToframe : true,
43                         region : 'center',
44                         tableName : 'ipshead',
45                         title : "Price Lists",
46                         grid : {
47                             xtype: 'Grid',
48                             xns: Roo.grid,
49                             listeners : {
50                                 render : function() 
51                                 {
52                                     _this.grid = this; 
53                                     _this.dialog = Pman.Dialog.XtuplePriceList
54                                     if (_this.panel.active) {
55                                        this.footer.onClick('first');
56                                     }
57                                 },
58                                 rowdblclick : function (_self, rowIndex, e)
59                                 {
60                                     if (!_this.dialog) return;
61                                     _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
62                                         _this.grid.footer.onClick('first');
63                                     }); 
64                                     
65                                 }
66                             },
67                             autoExpandColumn : 'ipshead_descrip',
68                             loadMask : true,
69                             sm : {
70                                 xtype: 'RowSelectionModel',
71                                 xns: Roo.grid
72                             },
73                             dataSource : {
74                                 xtype: 'Store',
75                                 xns: Roo.data,
76                                 remoteSort : true,
77                                 sortInfo : { field : 'ipshead_name', direction: 'ASC' },
78                                 proxy : {
79                                     xtype: 'HttpProxy',
80                                     xns: Roo.data,
81                                     method : 'GET',
82                                     url : baseURL + '/Roo/ipshead.php'
83                                 },
84                                 reader : {
85                                     xtype: 'JsonReader',
86                                     xns: Roo.data,
87                                     totalProperty : 'total',
88                                     root : 'data',
89                                     id : 'id',
90                                     fields : [
91                                         {
92                                             'name': 'ipshead_id',
93                                             'type': 'int'
94                                         },
95                                         {
96                                             'name': 'ipshead_name',
97                                             'type': 'string'
98                                         },
99                                         {
100                                             'name': 'ipshead_descrip',
101                                             'type': 'string'
102                                         },
103                                         {
104                                             'name': 'ipshead_effective',
105                                             'type': 'date',
106                                             'dateFormat': 'Y-m-d'
107                                         },
108                                         {
109                                             'name': 'ipshead_expires',
110                                             'type': 'date',
111                                             'dateFormat': 'Y-m-d'
112                                         },
113                                         {
114                                             'name': 'ipshead_curr_id',
115                                             'type': 'int'
116                                         },
117                                         {
118                                             'name': 'ipshead_updated',
119                                             'type': 'date',
120                                             'dateFormat': 'Y-m-d'
121                                         },
122                                         {
123                                             'name': 'ipshead_curr_id_curr_id',
124                                             'type': 'int'
125                                         },
126                                         {
127                                             'name': 'ipshead_curr_id_curr_base',
128                                             'type': 'int'
129                                         },
130                                         {
131                                             'name': 'ipshead_curr_id_curr_name',
132                                             'type': 'string'
133                                         },
134                                         {
135                                             'name': 'ipshead_curr_id_curr_symbol',
136                                             'type': 'string'
137                                         },
138                                         {
139                                             'name': 'ipshead_curr_id_curr_abbr',
140                                             'type': 'string'
141                                         }
142                                     ]
143                                 }
144                             },
145                             footer : {
146                                 xtype: 'PagingToolbar',
147                                 xns: Roo,
148                                 displayInfo : true,
149                                 displayMsg : "Displaying ipshead{0} - {1} of {2}",
150                                 emptyMsg : "No ipshead found",
151                                 pageSize : 25
152                             },
153                             toolbar : {
154                                 xtype: 'Toolbar',
155                                 xns: Roo,
156                                 items : [
157                                     {
158                                         xtype: 'Button',
159                                         xns: Roo.Toolbar,
160                                         listeners : {
161                                             click : function (_self, e)
162                                             {
163                                                new Pman.Download({
164                                                     method: 'GET',
165                                                     url : baseURL + '/Roo/Ipsiteminfo',
166                                                     params : {
167                                                         _pricegrid : 1
168                                                     }
169                                                });
170                                             }
171                                         },
172                                         text : "Download Price Matrix"
173                                     },
174                                     {
175                                         xtype: 'Button',
176                                         xns: Roo.Toolbar,
177                                         listeners : {
178                                             click : function (_self, e)
179                                             {
180                                                Pman.Dialog.Image.show(
181                                                    {
182                                                         _url : baseURL+'/Xtuple/Pricing'
183                                                     
184                                                    },
185                                                    function (data) {
186                                                         var msg = [];
187                                                         if (data.deleted) {
188                                                             msg.push("Deleted " + data.deleted + " Price(s)");
189                                                         }
190                                                         if (data.updated) {
191                                                             msg.push("Updated " + data.updated + " Price(s)");
192                                                         }            
193                                                         if (data.inserted) {
194                                                             msg.push("Added " + data.inserted + " Price(s)");
195                                                         }
196                                                         if (!msg.length) {
197                                                             msg.push("No data changed");
198                                                         }
199                                                         Roo.MessageBox.alert("Notice", msg.join("\n"));
200                                             
201                                                    }
202                                                );
203                                             }
204                                         },
205                                         text : "Upload Price Matrix"
206                                     },
207                                     {
208                                         xtype: 'Fill',
209                                         xns: Roo.Toolbar
210                                     },
211                                     {
212                                         xtype: 'Button',
213                                         xns: Roo.Toolbar,
214                                         text : "Add",
215                                         cls : 'x-btn-text-icon',
216                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
217                                         listeners : {
218                                             click : function()
219                                             {
220                                                 if (!_this.dialog) return;
221                                                 _this.dialog.show( { id : 0 } , function() {
222                                                     _this.grid.footer.onClick('first');
223                                                }); 
224                                             }
225                                         }
226                                     },
227                                     {
228                                         xtype: 'Button',
229                                         xns: Roo.Toolbar,
230                                         text : "Delete",
231                                         cls : 'x-btn-text-icon',
232                                         icon : rootURL + '/Pman/templates/images/trash.gif',
233                                         listeners : {
234                                             click : function()
235                                             {
236                                                  Pman.genericDelete(_this, 'ipshead'); 
237                                             }
238                                         }
239                                     }
240                                 ]
241                             },
242                             colModel : [
243                                 {
244                                     xtype: 'ColumnModel',
245                                     xns: Roo.grid,
246                                     dataIndex : 'ipshead_curr_id_curr_name',
247                                     header : 'Ipshead curr',
248                                     sortable : true,
249                                     width : 75,
250                                     renderer : function(v) { return String.format('{0}', v); }
251                                 },
252                                 {
253                                     xtype: 'ColumnModel',
254                                     xns: Roo.grid,
255                                     dataIndex : 'ipshead_name',
256                                     header : 'Ipshead name',
257                                     sortable : true,
258                                     width : 200,
259                                     renderer : function(v) { return String.format('{0}', v); }
260                                 },
261                                 {
262                                     xtype: 'ColumnModel',
263                                     xns: Roo.grid,
264                                     header : 'Ipshead descrip',
265                                     width : 200,
266                                     dataIndex : 'ipshead_descrip',
267                                     renderer : function(v) { return String.format('{0}', v); }
268                                 },
269                                 {
270                                     xtype: 'ColumnModel',
271                                     xns: Roo.grid,
272                                     header : 'Ipshead effective',
273                                     width : 75,
274                                     dataIndex : 'ipshead_effective',
275                                     renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
276                                 },
277                                 {
278                                     xtype: 'ColumnModel',
279                                     xns: Roo.grid,
280                                     dataIndex : 'ipshead_expires',
281                                     header : 'Ipshead expires',
282                                     width : 75,
283                                     renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
284                                 },
285                                 {
286                                     xtype: 'ColumnModel',
287                                     xns: Roo.grid,
288                                     header : 'Ipshead updated',
289                                     width : 75,
290                                     dataIndex : 'ipshead_updated',
291                                     renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
292                                 }
293                             ]
294                         }
295                     },
296                     {
297                         xtype: 'GridPanel',
298                         xns: Roo,
299                         listeners : {
300                             activate : function() {
301                                 _this.ipanel = this;
302                                 if (_this.igrid) {
303                                    // _this.igrid.footer.onClick('first');
304                                 }
305                             }
306                         },
307                         background : true,
308                         fitContainer : true,
309                         fitToframe : true,
310                         region : 'center',
311                         tableName : 'item',
312                         title : "Products",
313                         grid : {
314                             xtype: 'EditorGrid',
315                             xns: Roo.grid,
316                             listeners : {
317                                 render : function() 
318                                 {
319                                     _this.igrid = this; 
320                                     //_this.dialog = Pman.Dialog.FILL_IN
321                                     if (_this.ipanel.active) {
322                                        //this.footer.onClick('first');
323                                     }
324                                 },
325                                 cellclick : function (_self, row, col, e)
326                                 {
327                                      var di = _this.grid.colModel.getDataIndex(col);
328                                      
329                                      var rec = _this.grid.ds.getAt(row);
330                                      
331                                      if(di == 'item_image_filename'){
332                                         if(!rec.data.item_image_id){
333                                             return;
334                                         }
335                                         var u = baseURL;
336                                         if(rec.data.item_image_from_hk){
337                                             u = u.split('/');
338                                             u.pop();
339                                             u = u.join('/') + '/hk.php';
340                                         }
341                                         Pman.download( {
342                                            url: u + '/Images/Download/' + rec.data.item_image_id  + '/' + rec.data.item_image_filename
343                                        });
344                                        return;
345                                      }
346                                      
347                                      if (di == 'item_active') {
348                                      
349                                         var nv = rec.data.item_active ? 0 : 1;
350                                         new Pman.Request({
351                                             mask : 'Saving',
352                                             url : baseURL + '/Roo/Item',
353                                             params : {
354                                                 item_id : rec.data.item_id,
355                                                 item_active : nv
356                                             },
357                                             success : function() {
358                                                 rec.set('item_active', nv);
359                                             }
360                                         });
361                                         return;
362                                         
363                                      
364                                      }
365                                      
366                                      if(di == 'itemsrc_active'){
367                                         if(!rec.data.itemsrc_active){
368                                             Roo.MessageBox.alert('Error','Please edit it on Xtuple tool');
369                                             return;
370                                         }
371                                         if(rec.data.itemsrc_active){
372                                             Roo.MessageBox.confirm("Confirm", "Are you sure this product is no longer purchased",
373                                                 function (res) {
374                                                     if(res!='yes') {
375                                                         return;
376                                                     }
377                                                     rec.commit();
378                                             });
379                                         }
380                                     }
381                                      
382                                      _this.locgrid.footer.onClick('first');
383                                      
384                                      
385                                      
386                                      
387                                 },
388                                 afteredit : function (e)
389                                 {
390                                     
391                                     
392                                     Roo.log(e);
393                                     new Pman.Request({
394                                         url : baseURL +'/Roo/Charass',
395                                         params : {
396                                              charass_char_id_char_name : e.field.replace(/^item_char_/,'').toUpperCase(),
397                                              charass_value : e.value,
398                                              charass_target_type : 'I',
399                                              charass_default : 1,
400                                              charass_target_id : e.record.data.item_id
401                                          },
402                                          method : 'POST'
403                                      });
404                                     
405                                     
406                                     e.record.commit();
407                                     
408                                     
409                                     
410                                 },
411                                 rowdblclick : function (_self, rowIndex, e)
412                                 {
413                                     if (!_this.dialog) return;
414                                     _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
415                                         _this.grid.footer.onClick('first');
416                                     }); 
417                                 }
418                             },
419                             autoExpandColumn : 'item_descrip1',
420                             clicksToEdit : 1,
421                             loadMask : true,
422                             dataSource : {
423                                 xtype: 'Store',
424                                 xns: Roo.data,
425                                 listeners : {
426                                     beforeload : function (_self, o)
427                                     {
428                                       o.params._with_prodcat = 1;
429                                       o.params._with_char = 1;
430                                       o.params._with_itemsrc_active = 1;
431                                       o.params._with_last_purchase_price = 1;
432                                       o.params._with_image = 1;
433                                       var s = _this.search.getValue();
434                                       if (s.length) {
435                                         o.params['query[number_or_name]'] = s;
436                                       }
437                                       if (!_this.active.pressed) {
438                                         o.params.item_active = 1;
439                                       }
440                                       if (_this.brandSel.getValue().length) {
441                                         o.params._with_brand = _this.brandSel.getValue()
442                                       }
443                                     },
444                                     update : function (_self, record, operation)
445                                     {
446                                         if(operation != 'commit'){
447                                             return;
448                                         }
449                                         
450                                         var nv  = record.data.itemsrc_active ? 0 : 1;
451                                         new Pman.Request({
452                                             mask : 'Saving',
453                                             url : baseURL + '/Roo/Itemsrc',
454                                             params : {
455                                                 _update_by_item : 1,
456                                                 item_id : record.data.item_id,
457                                                 itemsrc_active : nv
458                                             },
459                                             success : function(res) {
460                                                 record.set('itemsrc_active', nv);
461                                             }
462                                         });
463                                     }
464                                 },
465                                 remoteSort : true,
466                                 sortInfo : { field : 'item_number', direction: 'ASC' },
467                                 proxy : {
468                                     xtype: 'HttpProxy',
469                                     xns: Roo.data,
470                                     method : 'GET',
471                                     url : baseURL + '/Roo/item.php'
472                                 },
473                                 reader : {
474                                     xtype: 'JsonReader',
475                                     xns: Roo.data,
476                                     totalProperty : 'total',
477                                     root : 'data',
478                                     id : 'id',
479                                     fields : [
480                                         {
481                                             'name': 'item_id',
482                                             'type': 'int'
483                                         },
484                                         {
485                                             'name': 'item_number',
486                                             'type': 'string'
487                                         },
488                                         {
489                                             'name': 'item_descrip1',
490                                             'type': 'string'
491                                         },
492                                         {
493                                             'name': 'item_descrip2',
494                                             'type': 'string'
495                                         },
496                                         {
497                                             'name': 'item_classcode_id',
498                                             'type': 'int'
499                                         },
500                                         {
501                                             'name': 'item_picklist',
502                                             'type': 'int'
503                                         },
504                                         {
505                                             'name': 'item_comments',
506                                             'type': 'string'
507                                         },
508                                         {
509                                             'name': 'item_sold',
510                                             'type': 'int'
511                                         },
512                                         {
513                                             'name': 'item_fractional',
514                                             'type': 'int'
515                                         },
516                                         {
517                                             'name': 'item_active',
518                                             'type': 'int'
519                                         },
520                                         {
521                                             'name': 'item_type',
522                                             'type': 'string'
523                                         },
524                                         {
525                                             'name': 'item_prodweight',
526                                             'type': 'float'
527                                         },
528                                         {
529                                             'name': 'item_packweight',
530                                             'type': 'float'
531                                         },
532                                         {
533                                             'name': 'item_prodcat_id',
534                                             'type': 'int'
535                                         },
536                                         {
537                                             'name': 'item_exclusive',
538                                             'type': 'int'
539                                         },
540                                         {
541                                             'name': 'item_listprice',
542                                             'type': 'float'
543                                         },
544                                         {
545                                             'name': 'item_config',
546                                             'type': 'int'
547                                         },
548                                         {
549                                             'name': 'item_extdescrip',
550                                             'type': 'string'
551                                         },
552                                         {
553                                             'name': 'item_upccode',
554                                             'type': 'string'
555                                         },
556                                         {
557                                             'name': 'item_maxcost',
558                                             'type': 'float'
559                                         },
560                                         {
561                                             'name': 'item_inv_uom_id',
562                                             'type': 'int'
563                                         },
564                                         {
565                                             'name': 'item_price_uom_id',
566                                             'type': 'int'
567                                         },
568                                         {
569                                             'name': 'item_warrdays',
570                                             'type': 'int'
571                                         },
572                                         {
573                                             'name': 'item_freightclass_id',
574                                             'type': 'int'
575                                         },
576                                         {
577                                             'name': 'item_tax_recoverable',
578                                             'type': 'int'
579                                         },
580                                         {
581                                             'name': 'item_price_uom_id_uom_id',
582                                             'type': 'int'
583                                         },
584                                         {
585                                             'name': 'item_price_uom_id_uom_name',
586                                             'type': 'string'
587                                         },
588                                         {
589                                             'name': 'item_price_uom_id_uom_descrip',
590                                             'type': 'string'
591                                         },
592                                         {
593                                             'name': 'item_price_uom_id_uom_item_weight',
594                                             'type': 'int'
595                                         },
596                                         {
597                                             'name': 'item_inv_uom_id_uom_id',
598                                             'type': 'int'
599                                         },
600                                         {
601                                             'name': 'item_inv_uom_id_uom_name',
602                                             'type': 'string'
603                                         },
604                                         {
605                                             'name': 'item_inv_uom_id_uom_descrip',
606                                             'type': 'string'
607                                         },
608                                         {
609                                             'name': 'item_inv_uom_id_uom_item_weight',
610                                             'type': 'int'
611                                         },
612                                         {
613                                             'name': 'item_freightclass_id_freightclass_id',
614                                             'type': 'int'
615                                         },
616                                         {
617                                             'name': 'item_freightclass_id_freightclass_code',
618                                             'type': 'string'
619                                         },
620                                         {
621                                             'name': 'item_freightclass_id_freightclass_descrip',
622                                             'type': 'string'
623                                         },
624                                         {
625                                             'name': 'item_classcode_id_classcode_id',
626                                             'type': 'int'
627                                         },
628                                         {
629                                             'name': 'item_classcode_id_classcode_code',
630                                             'type': 'string'
631                                         },
632                                         {
633                                             'name': 'item_classcode_id_classcode_descrip',
634                                             'type': 'string'
635                                         },
636                                         {
637                                             'name': 'item_classcode_id_classcode_mfg',
638                                             'type': 'int'
639                                         },
640                                         {
641                                             'name': 'item_classcode_id_classcode_creator',
642                                             'type': 'string'
643                                         },
644                                         {
645                                             'name': 'item_classcode_id_classcode_created',
646                                             'type': 'date'
647                                         },
648                                         {
649                                             'name': 'item_classcode_id_classcode_modifier',
650                                             'type': 'string'
651                                         },
652                                         {
653                                             'name': 'item_classcode_id_classcode_modified',
654                                             'type': 'date'
655                                         },
656                                         {
657                                             'name': 'item_classcode_id_classcode_type',
658                                             'type': 'string'
659                                         }
660                                     ]
661                                 }
662                             },
663                             toolbar : {
664                                 xtype: 'Toolbar',
665                                 xns: Roo,
666                                 items : [
667                                     {
668                                         xtype: 'ComboBox',
669                                         xns: Roo.form,
670                                         listeners : {
671                                             render : function (_self)
672                                             {
673                                               _this.brandSel = _self;
674                                             },
675                                             select : function (combo, record, index)
676                                             {
677                                                 _this.grid.footer.onClick('first');
678                                             }
679                                         },
680                                         allowBlank : true,
681                                         alwaysQuery : true,
682                                         displayField : 'charass_value',
683                                         editable : true,
684                                         forceSelection : true,
685                                         listWidth : 300,
686                                         loadingText : "Searching...",
687                                         minChars : 2,
688                                         pageSize : 20,
689                                         qtip : "Select Brand",
690                                         queryParam : 'query[charass_value]',
691                                         selectOnFocus : true,
692                                         tpl : '<div class="x-grid-cell-text x-btn button"><b>{charass_value}</b> </div>',
693                                         triggerAction : 'all',
694                                         width : 150,
695                                         store : {
696                                             xtype: 'Store',
697                                             xns: Roo.data,
698                                             listeners : {
699                                                 beforeload : function (_self, o)
700                                                 {
701                                                     o.params = o.params || {};
702                                                     // staff can see all logs, other companies can only see their own.
703                                                     // look for all of the charass 's with the same type= eg. brand.
704                                                     
705                                                     o.params.charass_char_id_char_name = 'BRAND';
706                                                     o.params.charass_target_type ='I';
707                                                     o.params._distinct = 'charass_value';
708                                                         o.params._columns = 'charass_value';
709                                                 
710                                                 }
711                                             },
712                                             remoteSort : true,
713                                             sortInfo : { field : 'charass_value' , direction : 'ASC' },
714                                             proxy : {
715                                                 xtype: 'HttpProxy',
716                                                 xns: Roo.data,
717                                                 method : 'GET',
718                                                 url : baseURL + '/Roo/Charass.php'
719                                             },
720                                             reader : {
721                                                 xtype: 'JsonReader',
722                                                 xns: Roo.data,
723                                                 totalProperty : 'total',
724                                                 root : 'data',
725                                                 id : 'id',
726                                                 fields : [
727                                                     {
728                                                         'name': 'id',
729                                                         'type': 'int'
730                                                     },
731                                                     {
732                                                         'name': 'person_name',
733                                                         'type': 'string'
734                                                     },
735                                                     {
736                                                         'name': 'event_when',
737                                                         'type': 'date',
738                                                         'dateFormat': 'Y-m-d'
739                                                     },
740                                                     {
741                                                         'name': 'action',
742                                                         'type': 'string'
743                                                     },
744                                                     {
745                                                         'name': 'ipaddr',
746                                                         'type': 'string'
747                                                     },
748                                                     {
749                                                         'name': 'on_id',
750                                                         'type': 'int'
751                                                     },
752                                                     {
753                                                         'name': 'on_table',
754                                                         'type': 'string'
755                                                     },
756                                                     {
757                                                         'name': 'person_id',
758                                                         'type': 'int'
759                                                     },
760                                                     {
761                                                         'name': 'remarks',
762                                                         'type': 'string'
763                                                     },
764                                                     {
765                                                         'name': 'person_id_id',
766                                                         'type': 'int'
767                                                     },
768                                                     {
769                                                         'name': 'person_id_office_id',
770                                                         'type': 'int'
771                                                     },
772                                                     {
773                                                         'name': 'person_id_name',
774                                                         'type': 'string'
775                                                     },
776                                                     {
777                                                         'name': 'person_id_phone',
778                                                         'type': 'string'
779                                                     },
780                                                     {
781                                                         'name': 'person_id_fax',
782                                                         'type': 'string'
783                                                     },
784                                                     {
785                                                         'name': 'person_id_email',
786                                                         'type': 'string'
787                                                     },
788                                                     {
789                                                         'name': 'person_id_company_id',
790                                                         'type': 'int'
791                                                     },
792                                                     {
793                                                         'name': 'person_id_role',
794                                                         'type': 'string'
795                                                     },
796                                                     {
797                                                         'name': 'person_id_active',
798                                                         'type': 'int'
799                                                     },
800                                                     {
801                                                         'name': 'person_id_remarks',
802                                                         'type': 'string'
803                                                     },
804                                                     {
805                                                         'name': 'person_id_passwd',
806                                                         'type': 'string'
807                                                     },
808                                                     {
809                                                         'name': 'person_id_owner_id',
810                                                         'type': 'int'
811                                                     },
812                                                     {
813                                                         'name': 'person_id_lang',
814                                                         'type': 'string'
815                                                     },
816                                                     {
817                                                         'name': 'person_id_no_reset_sent',
818                                                         'type': 'int'
819                                                     },
820                                                     {
821                                                         'name': 'person_id_action_type',
822                                                         'type': 'string'
823                                                     },
824                                                     {
825                                                         'name': 'person_id_project_id',
826                                                         'type': 'int'
827                                                     },
828                                                     {
829                                                         'name': 'person_id_deleted_by',
830                                                         'type': 'int'
831                                                     },
832                                                     {
833                                                         'name': 'person_id_deleted_dt',
834                                                         'type': 'date'
835                                                     }
836                                                 ]
837                                             }
838                                         }
839                                     },
840                                     {
841                                         xtype: 'TextField',
842                                         xns: Roo.form,
843                                         listeners : {
844                                             render : function (_self)
845                                             {
846                                               _this.search = _self;
847                                             },
848                                             specialkey : function (_self, e)
849                                             {
850                                                 _this.grid.footer.onClick('first');
851                                             }
852                                         }
853                                     },
854                                     {
855                                         xtype: 'Button',
856                                         xns: Roo.Toolbar,
857                                         listeners : {
858                                             click : function (_self, e)
859                                             {
860                                             _this.grid.footer.onClick('first');
861                                             }
862                                         },
863                                         cls : 'x-btn-icon',
864                                         icon : rootURL + '/Pman/templates/images/search.gif'
865                                     },
866                                     {
867                                         xtype: 'Button',
868                                         xns: Roo.Toolbar,
869                                         listeners : {
870                                             click : function (_self, e)
871                                             {
872                                                 _this.search.setValue('');
873                                                 
874                                             
875                                                 
876                                                 _this.grid.footer.onClick('first');
877                                             }
878                                         },
879                                         cls : 'x-btn-icon',
880                                         icon : rootURL + '/Pman/templates/images/edit-clear.gif'
881                                     },
882                                     {
883                                         xtype: 'Separator',
884                                         xns: Roo.Toolbar
885                                     },
886                                     {
887                                         xtype: 'Button',
888                                         xns: Roo.Toolbar,
889                                         listeners : {
890                                             toggle : function (_self, pressed)
891                                             {
892                                             
893                                                 this.setText(pressed ? "Hide Inactive" : "Show Inactive");
894                                                 (function() { _this.grid.footer.onClick('first'); }).defer(100);
895                                             },
896                                             render : function (_self)
897                                             {
898                                                 _this.active = _self;
899                                             }
900                                         },
901                                         enableToggle : true,
902                                         text : "Show Inactive"
903                                     },
904                                     {
905                                         xtype: 'Fill',
906                                         xns: Roo.Toolbar
907                                     },
908                                     {
909                                         xtype: 'TextItem',
910                                         xns: Roo.Toolbar,
911                                         text : "Report start :"
912                                     },
913                                     {
914                                         xtype: 'DateField',
915                                         xns: Roo.form,
916                                         listeners : {
917                                             render : function (_self)
918                                             {
919                                                 _this.dateFrom = _self;
920                                             }
921                                         },
922                                         format : 'd/M/Y',
923                                         useIso : true,
924                                         value : (function() { return (new Date()).format('Y') + '-01-01'; })()
925                                     },
926                                     {
927                                         xtype: 'ComboBox',
928                                         xns: Roo.form,
929                                         listeners : {
930                                             render : function (_self)
931                                             {
932                                               _this.datespan  = _self;
933                                             }
934                                         },
935                                         allowBlank : false,
936                                         displayField : 'fname',
937                                         editable : false,
938                                         fieldLabel : 'Status',
939                                         hiddenName : 'cm_status',
940                                         listWidth : 200,
941                                         mode : 'local',
942                                         name : 'cm_status_name',
943                                         triggerAction : 'all',
944                                         value : 12,
945                                         valueField : 'ftype',
946                                         width : 150,
947                                         store : {
948                                             xtype: 'SimpleStore',
949                                             xns: Roo.data,
950                                             data : [ 
951                                                 [ '1', "Single Month Sales"],
952                                                 [ '3', "Quarter Sales"],
953                                                 [ '6', "Half year Sales"] ,
954                                                 [ '12', "Full Year Sales"] 
955                                             ],
956                                             fields : [  'ftype', 'fname']
957                                         }
958                                     },
959                                     {
960                                         xtype: 'Button',
961                                         xns: Roo.Toolbar,
962                                         listeners : {
963                                             click : function (_self, e)
964                                             {
965                                                 if (!_this.brandSel.getValue().length) {
966                                                     Roo.MessageBox.alert("Error", "Select a brand to download");
967                                                     return;
968                                                 }
969                                             
970                                                 new Pman.Download({
971                                                     url : baseURL + '/Xtuple/Reports/SalesByCountryItemYear',
972                                                     params: { 
973                                                         date_from : _this.dateFrom.getValue(),
974                                                         brand : _this.brandSel.getValue(),
975                                                         span : _this.datespan.getValue()
976                                                     }
977                                                 });
978                                                     
979                                             
980                                             }
981                                         },
982                                         text : "Download Sales Report"
983                                     }
984                                 ]
985                             },
986                             footer : {
987                                 xtype: 'PagingToolbar',
988                                 xns: Roo,
989                                 pageSize : 25,
990                                 displayInfo : true,
991                                 displayMsg : "Displaying item{0} - {1} of {2}",
992                                 emptyMsg : "No item found",
993                                 items : [
994                                     {
995                                         xtype: 'Button',
996                                         xns: Roo.Toolbar,
997                                         listeners : {
998                                             click : function (_self, e)
999                                             {
1000                                                new Pman.Download({
1001                                                     method: 'GET',
1002                                                     url : baseURL + '/Roo/item',
1003                                                     params : {
1004                                                         _costgrid : 1
1005                                                     }
1006                                                });
1007                                             }
1008                                         },
1009                                         text : "Download Standard costs"
1010                                     },
1011                                     {
1012                                         xtype: 'Button',
1013                                         xns: Roo.Toolbar,
1014                                         listeners : {
1015                                             click : function (_self, e)
1016                                             {
1017                                                Pman.Dialog.Image.show(
1018                                                    {
1019                                                         _url : baseURL+'/Xtuple/Import/Products'
1020                                                     
1021                                                    },
1022                                                    function (data) {
1023                                                         var msg = [];
1024                                                        
1025                                                         if (data.updated) {
1026                                                             msg.push("Updated " + data.updated + " Products(s)");
1027                                                         }            
1028                                                         if (data.inserted) {
1029                                                             msg.push("Added " + data.inserted + " Products(s)");
1030                                                         }
1031                                                         if (data.skipped) {
1032                                                             msg.push("Skipped " + data.skipped);
1033                                                         }
1034                                                         
1035                                                         if (!msg.length) {
1036                                                             msg.push("No data changed");
1037                                                         }
1038                                                         Roo.MessageBox.alert("Notice", msg.join("\n"));
1039                                             
1040                                                    }
1041                                                );
1042                                             }
1043                                         },
1044                                         text : "Upload new products and costs"
1045                                     },
1046                                     {
1047                                         xtype: 'Button',
1048                                         xns: Roo.Toolbar,
1049                                         listeners : {
1050                                             click : function (_self, e)
1051                                             {
1052                                                 
1053                                                 var sel = _this.grid.selModel.getSelectedCell();
1054                                                 if (!sel) {
1055                                                     Roo.MessageBox.alert("Error", "Select a row");
1056                                                     return;
1057                                                 }
1058                                                 
1059                                                 var rec = _this.grid.ds.getAt(sel[0]);
1060                                                 if(rec.data.item_id * 1 < 1){
1061                                                     return;
1062                                                 }
1063                                                 
1064                                                 Pman.Dialog.Image.show({
1065                                                         id : rec.data.item_image_id ? rec.data.item_image_id : 0,
1066                                                         onid : rec.data.item_id,
1067                                                         ontable : 'Item'
1068                                                     }, function(data) {
1069                                                         if (data) {
1070                                                             _this.grid.footer.onClick('first');
1071                                                             
1072                                                     }
1073                                                     
1074                                                 });
1075                                             }
1076                                         },
1077                                         text : "Upload an image"
1078                                     },
1079                                     {
1080                                         xtype: 'Button',
1081                                         xns: Roo.Toolbar,
1082                                         listeners : {
1083                                             click : function (_self, e)
1084                                             {
1085                                               Roo.MessageBox.progress ("Syncing Stock", "Sending");
1086                                               
1087                                               var offset = 0;
1088                                               
1089                                                function runSync() {
1090                                                    
1091                                                    new Pman.Request( {
1092                                                         url : baseURL+'/Roo/Item',
1093                                                         method : 'GET',
1094                                                         params : {
1095                                                             _syncFromHK : 1,
1096                                                             offset : offset
1097                                                         },
1098                                                         success : function(res) {
1099                                                             Roo.log(res);
1100                                                             if (!res.data.total) {
1101                                                                 Roo.MessageBox.hide();
1102                                                                 return;
1103                                                             }
1104                                                             offset += res.data.limit;
1105                                                             Roo.MessageBox.updateProgress ( offset  / res.data.total, "Done " + offset + '/' + res.data.total);
1106                                                             runSync();
1107                                                         }
1108                                                         
1109                                                     
1110                                                    });
1111                                                }
1112                                                runSync();
1113                                             }
1114                                         },
1115                                         text : "Sync Product Data from HK",
1116                                         hidden : (function() {
1117                                         
1118                                             return baseURL.match(/hk\.php$/) ? true : false;
1119                                         })()
1120                                     }
1121                                 ]
1122                             },
1123                             colModel : [
1124                                 {
1125                                     xtype: 'ColumnModel',
1126                                     xns: Roo.grid,
1127                                     dataIndex : 'item_image_filename',
1128                                     header : 'Image ( Click to download )',
1129                                     width : 150,
1130                                     renderer : function(v,x,r)\r
1131                                     {
1132                                        if(!v){
1133                                         return '';
1134                                        }
1135                                        if(r.data.item_image_from_hk){
1136                                             var url = baseURL.split('/');
1137                                             url.pop();
1138                                             url = url.join('/');
1139                                             return '<img src="' + url + '/hk.php/Images/Thumb/150x150/' + r.data.item_image_id + '/' + v + '" width="150" height="150" />';     
1140                                        }\r
1141                                        return '<img src="' + baseURL + '/Images/Thumb/150x150/' + r.data.item_image_id + '/' + v + '" width="150" height="150" />';\r
1142                                     }
1143                                 },
1144                                 {
1145                                     xtype: 'ColumnModel',
1146                                     xns: Roo.grid,
1147                                     dataIndex : 'item_char_brand',
1148                                     header : 'Brand',
1149                                     sortable : true,
1150                                     width : 100,
1151                                     renderer : function(v) { return String.format('{0}', v); },
1152                                     editor : {
1153                                         xtype: 'GridEditor',
1154                                         xns: Roo.grid,
1155                                         field : {
1156                                             xtype: 'ComboBox',
1157                                             xns: Roo.form,
1158                                             allowBlank : true,
1159                                             alwaysQuery : true,
1160                                             displayField : 'charass_value',
1161                                             editable : true,
1162                                             forceSelection : false,
1163                                             listWidth : 300,
1164                                             loadingText : "Searching...",
1165                                             minChars : 2,
1166                                             pageSize : 20,
1167                                             qtip : "Select Brand",
1168                                             queryParam : 'query[charass_value]',
1169                                             selectOnFocus : true,
1170                                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{charass_value}</b> </div>',
1171                                             triggerAction : 'all',
1172                                             width : 150,
1173                                             store : {
1174                                                 xtype: 'Store',
1175                                                 xns: Roo.data,
1176                                                 listeners : {
1177                                                     beforeload : function (_self, o)
1178                                                     {
1179                                                         o.params = o.params || {};
1180                                                         // staff can see all logs, other companies can only see their own.
1181                                                         // look for all of the charass 's with the same type= eg. brand.
1182                                                         
1183                                                         o.params.charass_char_id_char_name = 'BRAND';
1184                                                         o.params.charass_target_type ='I';
1185                                                         o.params._distinct = 'charass_value';
1186                                                             o.params._columns = 'charass_value';
1187                                                     
1188                                                     }
1189                                                 },
1190                                                 remoteSort : true,
1191                                                 sortInfo : { field : 'charass_value' , direction : 'ASC' },
1192                                                 proxy : {
1193                                                     xtype: 'HttpProxy',
1194                                                     xns: Roo.data,
1195                                                     method : 'GET',
1196                                                     url : baseURL + '/Roo/Charass.php'
1197                                                 },
1198                                                 reader : {
1199                                                     xtype: 'JsonReader',
1200                                                     xns: Roo.data,
1201                                                     totalProperty : 'total',
1202                                                     root : 'data',
1203                                                     id : 'id',
1204                                                     fields : [
1205                                                         {
1206                                                             'name': 'id',
1207                                                             'type': 'int'
1208                                                         },
1209                                                         {
1210                                                             'name': 'person_name',
1211                                                             'type': 'string'
1212                                                         },
1213                                                         {
1214                                                             'name': 'event_when',
1215                                                             'type': 'date',
1216                                                             'dateFormat': 'Y-m-d'
1217                                                         },
1218                                                         {
1219                                                             'name': 'action',
1220                                                             'type': 'string'
1221                                                         },
1222                                                         {
1223                                                             'name': 'ipaddr',
1224                                                             'type': 'string'
1225                                                         },
1226                                                         {
1227                                                             'name': 'on_id',
1228                                                             'type': 'int'
1229                                                         },
1230                                                         {
1231                                                             'name': 'on_table',
1232                                                             'type': 'string'
1233                                                         },
1234                                                         {
1235                                                             'name': 'person_id',
1236                                                             'type': 'int'
1237                                                         },
1238                                                         {
1239                                                             'name': 'remarks',
1240                                                             'type': 'string'
1241                                                         },
1242                                                         {
1243                                                             'name': 'person_id_id',
1244                                                             'type': 'int'
1245                                                         },
1246                                                         {
1247                                                             'name': 'person_id_office_id',
1248                                                             'type': 'int'
1249                                                         },
1250                                                         {
1251                                                             'name': 'person_id_name',
1252                                                             'type': 'string'
1253                                                         },
1254                                                         {
1255                                                             'name': 'person_id_phone',
1256                                                             'type': 'string'
1257                                                         },
1258                                                         {
1259                                                             'name': 'person_id_fax',
1260                                                             'type': 'string'
1261                                                         },
1262                                                         {
1263                                                             'name': 'person_id_email',
1264                                                             'type': 'string'
1265                                                         },
1266                                                         {
1267                                                             'name': 'person_id_company_id',
1268                                                             'type': 'int'
1269                                                         },
1270                                                         {
1271                                                             'name': 'person_id_role',
1272                                                             'type': 'string'
1273                                                         },
1274                                                         {
1275                                                             'name': 'person_id_active',
1276                                                             'type': 'int'
1277                                                         },
1278                                                         {
1279                                                             'name': 'person_id_remarks',
1280                                                             'type': 'string'
1281                                                         },
1282                                                         {
1283                                                             'name': 'person_id_passwd',
1284                                                             'type': 'string'
1285                                                         },
1286                                                         {
1287                                                             'name': 'person_id_owner_id',
1288                                                             'type': 'int'
1289                                                         },
1290                                                         {
1291                                                             'name': 'person_id_lang',
1292                                                             'type': 'string'
1293                                                         },
1294                                                         {
1295                                                             'name': 'person_id_no_reset_sent',
1296                                                             'type': 'int'
1297                                                         },
1298                                                         {
1299                                                             'name': 'person_id_action_type',
1300                                                             'type': 'string'
1301                                                         },
1302                                                         {
1303                                                             'name': 'person_id_project_id',
1304                                                             'type': 'int'
1305                                                         },
1306                                                         {
1307                                                             'name': 'person_id_deleted_by',
1308                                                             'type': 'int'
1309                                                         },
1310                                                         {
1311                                                             'name': 'person_id_deleted_dt',
1312                                                             'type': 'date'
1313                                                         }
1314                                                     ]
1315                                                 }
1316                                             }
1317                                         }
1318                                     }
1319                                 },
1320                                 {
1321                                     xtype: 'ColumnModel',
1322                                     xns: Roo.grid,
1323                                     dataIndex : 'item_char_productgroup',
1324                                     header : 'Product Group',
1325                                     width : 100,
1326                                     renderer : function(v) { return String.format('{0}', v); },
1327                                     editor : {
1328                                         xtype: 'GridEditor',
1329                                         xns: Roo.grid,
1330                                         field : {
1331                                             xtype: 'ComboBox',
1332                                             xns: Roo.form,
1333                                             allowBlank : true,
1334                                             alwaysQuery : true,
1335                                             displayField : 'charass_value',
1336                                             editable : true,
1337                                             forceSelection : false,
1338                                             listWidth : 300,
1339                                             loadingText : "Searching...",
1340                                             minChars : 2,
1341                                             pageSize : 20,
1342                                             qtip : "Select Brand",
1343                                             queryParam : 'query[charass_value]',
1344                                             selectOnFocus : true,
1345                                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{charass_value}</b> </div>',
1346                                             triggerAction : 'all',
1347                                             width : 150,
1348                                             store : {
1349                                                 xtype: 'Store',
1350                                                 xns: Roo.data,
1351                                                 listeners : {
1352                                                     beforeload : function (_self, o)
1353                                                     {
1354                                                         o.params = o.params || {};
1355                                                         // staff can see all logs, other companies can only see their own.
1356                                                         // look for all of the charass 's with the same type= eg. brand.
1357                                                         
1358                                                         o.params.charass_char_id_char_name = 'PRODUCTGROUP';
1359                                                         o.params.charass_target_type ='I';
1360                                                         o.params._distinct = 'charass_value';
1361                                                             o.params._columns = 'charass_value';    
1362                                                     }
1363                                                 },
1364                                                 remoteSort : true,
1365                                                 sortInfo : { field : 'charass_value' , direction : 'ASC' },
1366                                                 proxy : {
1367                                                     xtype: 'HttpProxy',
1368                                                     xns: Roo.data,
1369                                                     method : 'GET',
1370                                                     url : baseURL + '/Roo/Charass.php'
1371                                                 },
1372                                                 reader : {
1373                                                     xtype: 'JsonReader',
1374                                                     xns: Roo.data,
1375                                                     totalProperty : 'total',
1376                                                     root : 'data',
1377                                                     id : 'id',
1378                                                     fields : [
1379                                                         {
1380                                                             'name': 'id',
1381                                                             'type': 'int'
1382                                                         },
1383                                                         {
1384                                                             'name': 'person_name',
1385                                                             'type': 'string'
1386                                                         },
1387                                                         {
1388                                                             'name': 'event_when',
1389                                                             'type': 'date',
1390                                                             'dateFormat': 'Y-m-d'
1391                                                         },
1392                                                         {
1393                                                             'name': 'action',
1394                                                             'type': 'string'
1395                                                         },
1396                                                         {
1397                                                             'name': 'ipaddr',
1398                                                             'type': 'string'
1399                                                         },
1400                                                         {
1401                                                             'name': 'on_id',
1402                                                             'type': 'int'
1403                                                         },
1404                                                         {
1405                                                             'name': 'on_table',
1406                                                             'type': 'string'
1407                                                         },
1408                                                         {
1409                                                             'name': 'person_id',
1410                                                             'type': 'int'
1411                                                         },
1412                                                         {
1413                                                             'name': 'remarks',
1414                                                             'type': 'string'
1415                                                         },
1416                                                         {
1417                                                             'name': 'person_id_id',
1418                                                             'type': 'int'
1419                                                         },
1420                                                         {
1421                                                             'name': 'person_id_office_id',
1422                                                             'type': 'int'
1423                                                         },
1424                                                         {
1425                                                             'name': 'person_id_name',
1426                                                             'type': 'string'
1427                                                         },
1428                                                         {
1429                                                             'name': 'person_id_phone',
1430                                                             'type': 'string'
1431                                                         },
1432                                                         {
1433                                                             'name': 'person_id_fax',
1434                                                             'type': 'string'
1435                                                         },
1436                                                         {
1437                                                             'name': 'person_id_email',
1438                                                             'type': 'string'
1439                                                         },
1440                                                         {
1441                                                             'name': 'person_id_company_id',
1442                                                             'type': 'int'
1443                                                         },
1444                                                         {
1445                                                             'name': 'person_id_role',
1446                                                             'type': 'string'
1447                                                         },
1448                                                         {
1449                                                             'name': 'person_id_active',
1450                                                             'type': 'int'
1451                                                         },
1452                                                         {
1453                                                             'name': 'person_id_remarks',
1454                                                             'type': 'string'
1455                                                         },
1456                                                         {
1457                                                             'name': 'person_id_passwd',
1458                                                             'type': 'string'
1459                                                         },
1460                                                         {
1461                                                             'name': 'person_id_owner_id',
1462                                                             'type': 'int'
1463                                                         },
1464                                                         {
1465                                                             'name': 'person_id_lang',
1466                                                             'type': 'string'
1467                                                         },
1468                                                         {
1469                                                             'name': 'person_id_no_reset_sent',
1470                                                             'type': 'int'
1471                                                         },
1472                                                         {
1473                                                             'name': 'person_id_action_type',
1474                                                             'type': 'string'
1475                                                         },
1476                                                         {
1477                                                             'name': 'person_id_project_id',
1478                                                             'type': 'int'
1479                                                         },
1480                                                         {
1481                                                             'name': 'person_id_deleted_by',
1482                                                             'type': 'int'
1483                                                         },
1484                                                         {
1485                                                             'name': 'person_id_deleted_dt',
1486                                                             'type': 'date'
1487                                                         }
1488                                                     ]
1489                                                 }
1490                                             }
1491                                         }
1492                                     }
1493                                 },
1494                                 {
1495                                     xtype: 'ColumnModel',
1496                                     xns: Roo.grid,
1497                                     dataIndex : 'item_number',
1498                                     header : 'Number',
1499                                     width : 100,
1500                                     renderer : function(v) { return String.format('{0}', v); }
1501                                 },
1502                                 {
1503                                     xtype: 'ColumnModel',
1504                                     xns: Roo.grid,
1505                                     dataIndex : 'item_descrip1',
1506                                     header : 'Description',
1507                                     width : 200,
1508                                     renderer : function(v) { return String.format('{0}', v); }
1509                                 },
1510                                 {
1511                                     xtype: 'ColumnModel',
1512                                     xns: Roo.grid,
1513                                     dataIndex : 'itemsrc_active',
1514                                     header : 'Purchased',
1515                                     width : 75,
1516                                     renderer : function(v) {  
1517                                         var state = v * 1 > 0 ?  '-checked' : '';
1518                                     
1519                                         return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
1520                                                     
1521                                      }
1522                                 },
1523                                 {
1524                                     xtype: 'ColumnModel',
1525                                     xns: Roo.grid,
1526                                     dataIndex : 'item_sold',
1527                                     header : 'is Sold?',
1528                                     width : 75,
1529                                     renderer : function(v) {  
1530                                         var state = v * 1 > 0 ?  '-checked' : '';
1531                                     
1532                                         return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
1533                                                     
1534                                      }
1535                                 },
1536                                 {
1537                                     xtype: 'ColumnModel',
1538                                     xns: Roo.grid,
1539                                     dataIndex : 'item_active',
1540                                     header : 'is Active?',
1541                                     width : 75,
1542                                     renderer : function(v) {  
1543                                         var state = v * 1 > 0 ?  '-checked' : '';
1544                                     
1545                                         return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
1546                                                     
1547                                      }
1548                                 },
1549                                 {
1550                                     xtype: 'ColumnModel',
1551                                     xns: Roo.grid,
1552                                     dataIndex : 'last_purchase_price',
1553                                     header : 'Last purchase price',
1554                                     width : 120,
1555                                     renderer : function(v,x,r) {
1556                                     
1557                                          return String.format('{0}{1}', r.data.last_purchase_price_curr_name, Roo.util.Format.number(v,2)) ; 
1558                                          
1559                                      }
1560                                 },
1561                                 {
1562                                     xtype: 'ColumnModel',
1563                                     xns: Roo.grid,
1564                                     dataIndex : 'item_type',
1565                                     header : 'Item type',
1566                                     width : 100,
1567                                     renderer : function(v) { return String.format('{0}', v); }
1568                                 },
1569                                 {
1570                                     xtype: 'ColumnModel',
1571                                     xns: Roo.grid,
1572                                     dataIndex : 'item_prodcat_id_prodcat_code',
1573                                     header : 'Item prodcat',
1574                                     width : 100,
1575                                     renderer : function(v) { return String.format('{0}', v); }
1576                                 },
1577                                 {
1578                                     xtype: 'ColumnModel',
1579                                     xns: Roo.grid,
1580                                     align : 'right',
1581                                     dataIndex : 'item_actcost',
1582                                     header : 'Cost',
1583                                     width : 75,
1584                                     renderer : function(v,x,r) {
1585                                     
1586                                          return String.format('{0}{1}', r.data.item_curr_name, Roo.util.Format.number(v,2)) ; 
1587                                          
1588                                      }
1589                                 },
1590                                 {
1591                                     xtype: 'ColumnModel',
1592                                     xns: Roo.grid,
1593                                     align : 'right',
1594                                     dataIndex : 'item_base_cost',
1595                                     header : 'Cost (base)',
1596                                     width : 75,
1597                                     renderer : function(v,x,r) {
1598                                     
1599                                          return String.format('{0}{1}', r.data.item_base_curr, Roo.util.Format.number(v,2)) ; 
1600                                          
1601                                      }
1602                                 }
1603                             ]
1604                         }
1605                     }
1606                 ],
1607                 center : {
1608                     xtype: 'LayoutRegion',
1609                     xns: Roo
1610                 },
1611                 east : {
1612                     xtype: 'LayoutRegion',
1613                     xns: Roo
1614                 }
1615             }
1616         };
1617     }
1618 });