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