Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Tab.XtupleCreditMemos.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.XtupleCreditMemos = new Roo.XComponent({
6     part     :  ["Xtuple","CreditMemos"],
7     order    : '200-Pman.Tab.XtupleCreditMemos',
8     region   : 'center',
9     parent   : 'Pman.Tab.XtupleSales',
10     name     : "Pman.Tab.XtupleCreditMemos",
11     disabled : false, 
12     permname : '', 
13     _tree : function()
14     {
15         var _this = this;
16         var MODULE = this;
17         return {
18             xtype: 'GridPanel',
19             xns: Roo,
20             listeners : {
21                 activate : function() {
22                     _this.panel = this;
23                     if (_this.grid) {
24                         _this.grid.footer.onClick('first');
25                     }
26                 }
27             },
28             background : true,
29             fitContainer : true,
30             fitToframe : true,
31             region : 'center',
32             tableName : 'cmhead',
33             title : "Credit Memos",
34             grid : {
35                 xtype: 'Grid',
36                 xns: Roo.grid,
37                 listeners : {
38                     render : function() 
39                     {
40                         _this.grid = this; 
41                         //_this.dialog = Pman.Dialog.FILL_IN
42                         if (_this.panel.active) {
43                            this.footer.onClick('first');
44                         }
45                     },
46                     rowdblclick : function (_self, rowIndex, e)
47                     {
48                         var s = this.dataSource.getAt(rowIndex);
49                         Pman.Dialog.XtupleCreditMemo.show({
50                             cmhead_id : s.data.cmhead_id
51                         },function() {
52                             _this.grid.footer.onClick('first');
53                         
54                         });
55                     /*    if (!_this.dialog) return;
56                         _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
57                             _this.grid.footer.onClick('first');
58                         }); */
59                     }
60                 },
61                 autoExpandColumn : 'cmhead_cust_id_cust_name',
62                 loadMask : true,
63                 dataSource : {
64                     xtype: 'Store',
65                     xns: Roo.data,
66                     listeners : {
67                         beforeload : function (_self, o)
68                         {
69                             if ( _this.customer &&  _this.customer.getValue() ) {
70                                o.params.cmhead_cust_id = _this.customer.getValue();
71                             }
72                             if (_this.cmnumber && _this.cmnumber.getValue() ) {
73                                o.params.cmhead_id =  _this.cmnumber.getValue();
74                             }
75                             if (_this.status) { 
76                                 o.params['query[status]'] = _this.status.getValue();
77                             }
78                             
79                             o.params._with_aropen = 1;
80                         }
81                     },
82                     remoteSort : true,
83                     sortInfo : { field : 'cmhead_id', direction: 'DESC' },
84                     proxy : {
85                         xtype: 'HttpProxy',
86                         xns: Roo.data,
87                         method : 'GET',
88                         url : baseURL + '/Roo/cmhead.php'
89                     },
90                     reader : {
91                         xtype: 'JsonReader',
92                         xns: Roo.data,
93                         totalProperty : 'total',
94                         root : 'data',
95                         id : 'id',
96                         fields : [
97                             {
98                                 'name': 'cmhead_id',
99                                 'type': 'int'
100                             },
101                             {
102                                 'name': 'cmhead_number',
103                                 'type': 'string'
104                             },
105                             {
106                                 'name': 'cmhead_posted',
107                                 'type': 'int'
108                             },
109                             {
110                                 'name': 'cmhead_invcnumber',
111                                 'type': 'string'
112                             },
113                             {
114                                 'name': 'cmhead_custponumber',
115                                 'type': 'string'
116                             },
117                             {
118                                 'name': 'cmhead_cust_id',
119                                 'type': 'int'
120                             },
121                             {
122                                 'name': 'cmhead_docdate',
123                                 'type': 'date',
124                                 'dateFormat': 'Y-m-d'
125                             },
126                             {
127                                 'name': 'cmhead_shipto_id',
128                                 'type': 'int'
129                             },
130                             {
131                                 'name': 'cmhead_shipto_name',
132                                 'type': 'string'
133                             },
134                             {
135                                 'name': 'cmhead_shipto_address1',
136                                 'type': 'string'
137                             },
138                             {
139                                 'name': 'cmhead_shipto_address2',
140                                 'type': 'string'
141                             },
142                             {
143                                 'name': 'cmhead_shipto_address3',
144                                 'type': 'string'
145                             },
146                             {
147                                 'name': 'cmhead_shipto_city',
148                                 'type': 'string'
149                             },
150                             {
151                                 'name': 'cmhead_shipto_state',
152                                 'type': 'string'
153                             },
154                             {
155                                 'name': 'cmhead_shipto_zipcode',
156                                 'type': 'string'
157                             },
158                             {
159                                 'name': 'cmhead_salesrep_id',
160                                 'type': 'int'
161                             },
162                             {
163                                 'name': 'cmhead_freight',
164                                 'type': 'float'
165                             },
166                             {
167                                 'name': 'cmhead_misc',
168                                 'type': 'float'
169                             },
170                             {
171                                 'name': 'cmhead_comments',
172                                 'type': 'string'
173                             },
174                             {
175                                 'name': 'cmhead_printed',
176                                 'type': 'int'
177                             },
178                             {
179                                 'name': 'cmhead_billtoname',
180                                 'type': 'string'
181                             },
182                             {
183                                 'name': 'cmhead_billtoaddress1',
184                                 'type': 'string'
185                             },
186                             {
187                                 'name': 'cmhead_billtoaddress2',
188                                 'type': 'string'
189                             },
190                             {
191                                 'name': 'cmhead_billtoaddress3',
192                                 'type': 'string'
193                             },
194                             {
195                                 'name': 'cmhead_billtocity',
196                                 'type': 'string'
197                             },
198                             {
199                                 'name': 'cmhead_billtostate',
200                                 'type': 'string'
201                             },
202                             {
203                                 'name': 'cmhead_billtozip',
204                                 'type': 'string'
205                             },
206                             {
207                                 'name': 'cmhead_hold',
208                                 'type': 'int'
209                             },
210                             {
211                                 'name': 'cmhead_commission',
212                                 'type': 'float'
213                             },
214                             {
215                                 'name': 'cmhead_misc_accnt_id',
216                                 'type': 'int'
217                             },
218                             {
219                                 'name': 'cmhead_misc_descrip',
220                                 'type': 'string'
221                             },
222                             {
223                                 'name': 'cmhead_rsncode_id',
224                                 'type': 'int'
225                             },
226                             {
227                                 'name': 'cmhead_curr_id',
228                                 'type': 'int'
229                             },
230                             {
231                                 'name': 'cmhead_freighttaxtype_id',
232                                 'type': 'int'
233                             },
234                             {
235                                 'name': 'cmhead_gldistdate',
236                                 'type': 'date',
237                                 'dateFormat': 'Y-m-d'
238                             },
239                             {
240                                 'name': 'cmhead_billtocountry',
241                                 'type': 'string'
242                             },
243                             {
244                                 'name': 'cmhead_shipto_country',
245                                 'type': 'string'
246                             },
247                             {
248                                 'name': 'cmhead_rahead_id',
249                                 'type': 'int'
250                             },
251                             {
252                                 'name': 'cmhead_taxzone_id',
253                                 'type': 'int'
254                             },
255                             {
256                                 'name': 'cmhead_prj_id',
257                                 'type': 'int'
258                             }
259                         ]
260                     }
261                 },
262                 footer : {
263                     xtype: 'PagingToolbar',
264                     xns: Roo,
265                     pageSize : 25,
266                     displayInfo : true,
267                     displayMsg : "Displaying cmhead{0} - {1} of {2}",
268                     emptyMsg : "No cmhead found",
269                     items : [
270                         {
271                             xtype: 'Button',
272                             xns: Roo.Toolbar,
273                             listeners : {
274                                 click : function (_self, e)
275                                 {
276                                  new Pman.Download({
277                                         grid : _this.grid
278                                     });
279                                     Roo.MessageBox.alert("Notice", "Report is downloading");
280                                 }
281                             },
282                             text : "Download"
283                         }
284                     ]
285                 },
286                 toolbar : {
287                     xtype: 'Toolbar',
288                     xns: Roo,
289                     items : [
290                         {
291                             xtype: 'ComboBox',
292                             xns: Roo.form,
293                             listeners : {
294                                 render : function (_self)
295                                 {
296                                     _this.cmnumber = _self;
297                                 },
298                                 select : function (combo, record, index)
299                                 {
300                                     Roo.log('select');
301                                     _this.grid.footer.onClick('first');
302                                 }
303                             },
304                             allowBlank : true,
305                             displayField : 'cmhead_number',
306                             editable : true,
307                             emptyText : "Order",
308                             fieldLabel : 'ordernumber',
309                             forceSelection : true,
310                             hiddenName : 'cmhead_id',
311                             listWidth : 400,
312                             loadingText : "Searching...",
313                             minChars : 2,
314                             name : 'cmhead_number',
315                             pageSize : 20,
316                             qtip : "Select invchead",
317                             queryParam : 'query[cmhead_number]',
318                             selectOnFocus : true,
319                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{cmhead_number}</b> </div>',
320                             triggerAction : 'all',
321                             typeAhead : false,
322                             valueField : 'cmhead_id',
323                             width : 150,
324                             store : {
325                                 xtype: 'Store',
326                                 xns: Roo.data,
327                                 listeners : {
328                                     beforeload : function (_self, o){
329                                         o.params = o.params || {};
330                                         // set more here
331                                     }
332                                 },
333                                 remoteSort : true,
334                                 sortInfo : { direction : 'ASC', field: 'cmhead_number' },
335                                 proxy : {
336                                     xtype: 'HttpProxy',
337                                     xns: Roo.data,
338                                     method : 'GET',
339                                     url : baseURL + '/Roo/cmhead.php'
340                                 },
341                                 reader : {
342                                     xtype: 'JsonReader',
343                                     xns: Roo.data,
344                                     id : 'cmhead_id',
345                                     root : 'data',
346                                     totalProperty : 'total',
347                                     fields : [{"name":"cmhead_id","type":"int"},"cmhead_number"]
348                                 }
349                             }
350                         },
351                         {
352                             xtype: 'ComboBox',
353                             xns: Roo.form,
354                             listeners : {
355                                 render : function (_self)
356                                 {
357                                     _this.customer = _self;
358                                 },
359                                 select : function (combo, record, index)
360                                 {
361                                     _this.grid.footer.onClick('first');
362                                 }
363                             },
364                             allowBlank : true,
365                             displayField : 'cust_name',
366                             editable : true,
367                             emptyText : "Select Customer",
368                             fieldLabel : 'cust_name',
369                             forceSelection : true,
370                             hiddenName : 'cust_id',
371                             listWidth : 400,
372                             loadingText : "Searching...",
373                             minChars : 2,
374                             name : 'cust_name',
375                             pageSize : 20,
376                             qtip : "Select custinfo",
377                             queryParam : 'query[cust_name]',
378                             selectOnFocus : true,
379                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{cust_name}</b> </div>',
380                             triggerAction : 'all',
381                             typeAhead : false,
382                             valueField : 'cust_id',
383                             width : 200,
384                             store : {
385                                 xtype: 'Store',
386                                 xns: Roo.data,
387                                 sortInfo : { direction : 'ASC', field: 'cust_name' },
388                                 remoteSort : true,
389                                 listeners : {
390                                     beforeload : function (_self, o){
391                                         o.params = o.params || {};
392                                         // set more here
393                                     }
394                                 },
395                                 proxy : {
396                                     xtype: 'HttpProxy',
397                                     xns: Roo.data,
398                                     method : 'GET',
399                                     url : baseURL + '/Roo/custinfo.php'
400                                 },
401                                 reader : {
402                                     xtype: 'JsonReader',
403                                     xns: Roo.data,
404                                     id : 'cust_id',
405                                     root : 'data',
406                                     totalProperty : 'total',
407                                     fields : [{"name":"cust_id","type":"int"},"cust_name"]
408                                 }
409                             }
410                         },
411                         {
412                             xtype: 'ComboBox',
413                             xns: Roo.form,
414                             listeners : {
415                                 render : function (_self)
416                                 {
417                                   _this.status = _self;
418                                 },
419                                 select : function (combo, record, index)
420                                 {
421                                     Roo.log('select');
422                                     _this.grid.footer.onClick('first');
423                                 }
424                             },
425                             allowBlank : false,
426                             displayField : 'fname',
427                             editable : false,
428                             fieldLabel : 'Status',
429                             hiddenName : 'cm_status',
430                             listWidth : 200,
431                             mode : 'local',
432                             name : 'cm_status_name',
433                             triggerAction : 'all',
434                             value : "NOTCLOSED",
435                             valueField : 'ftype',
436                             width : 150,
437                             store : {
438                                 xtype: 'SimpleStore',
439                                 xns: Roo.data,
440                                 data : [ 
441                                     [ 'NOTCLOSED', "Not Closed"],
442                                     [ 'CLOSED' , "Closed"],
443                                     [ 'UNPOSTED', "Unposted only"] ,
444                                     [ 'UNUSED', "Posted and not used"] ,
445                                     [ 'VOIDED', "Voided"],
446                                     [ 'NOTVOIDED', "Not Voided"],
447                                     [ 'ALL', "Show All"],
448                                 ],
449                                 fields : [  'ftype', 'fname']
450                             }
451                         },
452                         {
453                             xtype: 'Fill',
454                             xns: Roo.Toolbar
455                         },
456                         {
457                             xtype: 'Button',
458                             xns: Roo.Toolbar,
459                             cls : 'x-btn-text-icon',
460                             text : "Add",
461                             icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
462                             menu : {
463                                 xtype: 'Menu',
464                                 xns: Roo.menu,
465                                 items : [
466                                     {
467                                         xtype: 'Item',
468                                         xns: Roo.menu,
469                                         listeners : {
470                                             click : function (_self, e)
471                                             {
472                                                Pman.Dialog.XtupleCreditMemoNew.show( {} , function() {
473                                                     _this.grid.footer.onClick('first');
474                                                }); 
475                                             
476                                             }
477                                         },
478                                         cls : 'x-btn-text-icon',
479                                         text : "New Credit Memo",
480                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
481                                     },
482                                     {
483                                         xtype: 'Separator',
484                                         xns: Roo.menu
485                                     },
486                                     {
487                                         xtype: 'Item',
488                                         xns: Roo.menu,
489                                         listeners : {
490                                             click : function (_self, e)
491                                             {
492                                                var s = _this.grid.getSelectionModel().getSelections();
493                                             
494                                                 if (!s.length || (s.length > 1))  {
495                                                     Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
496                                                     return;
497                                                 }    
498                                                 if(s[0].data.checkhead_total == 0){
499                                                     Roo.MessageBox.alert("Error", "you cannot create the miscellaneous check for the credit memo coz the total amount remaining is 0! ");
500                                                     return;
501                                                 }
502                                                 if(!s[0].data.cmhead_posted){
503                                                     Roo.MessageBox.alert("Error", "This credit memo  has not been posted!");
504                                                     return;
505                                                 }
506                                                 var data = {
507                                                     'checkhead_recip_id' : s[0].data.cmhead_cust_id,
508                                                     'checkhead_recip_type' : 'C',
509                                                     'checkhead_checkdate' : new Date(),
510                                                     'checkhead_amount' : s[0].data.checkhead_total,
511                                                     'remaining_total' : s[0].data.checkhead_total,
512                                                     'checkhead_curr_id' : s[0].data.cmhead_curr_id,
513                                                     'checkhead_curr_id_curr_name' : s[0].data.cmhead_curr_id_curr_name,
514                                                     'checkhead_misc' : true,
515                                                     'aropen_id' : s[0].data.cmhead_aropen_id_aropen_id,
516                                                         'cmhead_number' : s[0].data.cmhead_number,
517                                                 'cust_name' : s[0].data.cmhead_cust_id_cust_name,
518                                                 '_create_and_post' : 1
519                                             
520                                                 };
521                                                 
522                                                 
523                                                 Pman.Dialog.XtupleMiscellaneousCheck.show( data , function() {
524                                                     _this.grid.footer.onClick('first');
525                                                }); 
526                                             
527                                             }
528                                         },
529                                         cls : 'x-btn-text-icon',
530                                         text : "New Miscellaneous Check",
531                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
532                                     }
533                                 ]
534                             }
535                         },
536                         {
537                             xtype: 'Separator',
538                             xns: Roo.Toolbar
539                         },
540                         {
541                             xtype: 'Button',
542                             xns: Roo.Toolbar,
543                             listeners : {
544                                 click : function()
545                                 {
546                                     var s = _this.grid.getSelectionModel().getSelections();
547                                 
548                                     if (!s.length || (s.length > 1))  {
549                                         Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
550                                         return;
551                                     }
552                                 
553                                     var postit = function()
554                                     {
555                                         new Pman.Request(
556                                         {
557                                             url : baseURL + '/Roo/Cmhead',
558                                             mask: 'Voiding',
559                                             method : 'POST',
560                                             params : {
561                                                 cmhead_id : s[0].data.cmhead_id,
562                                                 _void : 1
563                                             },
564                                             success : function()
565                                             {
566                                                 _this.grid.footer.onClick('refresh');
567                                             } 
568                                         });
569                                     
570                                     };
571                                 
572                                 
573                                     Roo.MessageBox.confirm(
574                                         "Confirm",
575                                         "Are you sure to void this credit memo?",
576                                         function(r) {
577                                             if (r != 'yes') {
578                                                 return;
579                                             }
580                                             postit();
581                                         }
582                                     );
583                                     
584                                 }
585                             },
586                             cls : 'x-btn-text-icon',
587                             text : "Void Credit Memo",
588                             icon : Roo.rootURL + 'images/default/tree/leaf.gif'
589                         },
590                         {
591                             xtype: 'Separator',
592                             xns: Roo.Toolbar
593                         },
594                         {
595                             xtype: 'Button',
596                             xns: Roo.Toolbar,
597                             listeners : {
598                                 click : function()
599                                 {
600                                     var s = _this.grid.getSelectionModel().getSelections();
601                                 
602                                     if (!s.length || (s.length > 1))  {
603                                         Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
604                                         return;
605                                     }
606                                     if (s[0].data.cmhead_posted ) { 
607                                         Roo.MessageBox.alert("Error", 
608                                             "You can not delete posted credit memo's - you have to create an invoice to reverse them");
609                                         return;
610                                     }
611                                     
612                                     
613                                 
614                                     var postit = function()
615                                     {
616                                         new Pman.Request(
617                                         {
618                                             url : baseURL + '/Roo/Cmhead',
619                                             mask: 'Deleting',
620                                             method : 'POST',
621                                             params : {
622                                                 _delete  : s[0].data.cmhead_id 
623                                             },
624                                             success : function()
625                                             {
626                                                 _this.grid.footer.onClick('refresh');
627                                             } 
628                                         });
629                                     
630                                     };
631                                 
632                                 
633                                     Roo.MessageBox.confirm(
634                                         "Confirm Deletion",
635                                         "You will have to make sure this credit memo has no line items associated before deleting it. ",
636                                         function(r) {
637                                             if (r != 'yes') {
638                                                 return;
639                                             }
640                                             postit();
641                                         }
642                                     );
643                                     
644                                 }
645                             },
646                             cls : 'x-btn-text-icon',
647                             text : "Delete Credit Memo",
648                             icon : Roo.rootURL + 'images/default/tree/leaf.gif'
649                         },
650                         {
651                             xtype: 'Separator',
652                             xns: Roo.Toolbar
653                         },
654                         {
655                             xtype: 'Button',
656                             xns: Roo.Toolbar,
657                             listeners : {
658                                 click : function()
659                                 {
660                                     var s = _this.grid.getSelectionModel().getSelections();
661                                 
662                                     if (!s.length || (s.length > 1))  {
663                                         Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
664                                         return;
665                                     }
666                                 
667                                     var postit = function()
668                                     {
669                                         new Pman.Request(
670                                         {
671                                             url : baseURL + '/Roo/Cmhead',
672                                             mask: 'Posting',
673                                             method : 'POST',
674                                             params : {
675                                                 cmhead_id : s[0].data.cmhead_id,
676                                                 _post : 1
677                                             },
678                                             success : function()
679                                             {
680                                                 _this.grid.footer.onClick('refresh');
681                                             } 
682                                         });
683                                     
684                                     };
685                                 
686                                 
687                                     Roo.MessageBox.confirm(
688                                         "Confirm Posting",
689                                         "Are you sure that is complete, <B>Voiding a Credit memo invoices creating a sales order and invoice</B>, so make sure this is correct before posting",
690                                         function(r) {
691                                             if (r != 'yes') {
692                                                 return;
693                                             }
694                                             postit();
695                                         }
696                                     ); 
697                                     
698                                 }
699                             },
700                             cls : 'x-btn-text-icon',
701                             text : "POST",
702                             icon : Roo.rootURL + 'images/default/tree/leaf.gif'
703                         },
704                         {
705                             xtype: 'Separator',
706                             xns: Roo.Toolbar
707                         },
708                         {
709                             xtype: 'Button',
710                             xns: Roo.Toolbar,
711                             listeners : {
712                                 click : function ()
713                                 {
714                                     var s = _this.grid.getSelectionModel().getSelected();
715                                       if (!s || !s.data.cmhead_id) {
716                                         Roo.MessageBox.alert("Error", "Select a credit memo");
717                                         return
718                                       }
719                                       
720                                       var ext = baseURL.split('/').pop().replace(/\.php/, '');
721                                       new Pman.Download({
722                                         url : baseURL + '/Xtuple/Print',
723                                         params :  {
724                                             template: 'creditmemo-' + ext,
725                                             filename : 'creditmemo-' + s.data.cmhead_id,
726                                             'param[0]':   "cmhead_id:string='" + s.data.cmhead_id + "'"
727                                            
728                                         },
729                                         method : 'GET'
730                                      });
731                                      Roo.MessageBox.alert("Notice", "Report will download shortly");
732                                             
733                                             
734                                    
735                                 }
736                             },
737                             cls : 'x-btn-text-icon',
738                             text : "Print",
739                             icon : rootURL + '/Pman/templates/images/pdf.gif'
740                         },
741                         {
742                             xtype: 'Separator',
743                             xns: Roo.Toolbar
744                         },
745                         {
746                             xtype: 'Button',
747                             xns: Roo.Toolbar,
748                             cls : 'x-btn-text-icon',
749                             text : "Tools",
750                             icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
751                             menu : {
752                                 xtype: 'Menu',
753                                 xns: Roo.menu,
754                                 items : [
755                                     {
756                                         xtype: 'Separator',
757                                         xns: Roo.menu
758                                     },
759                                     {
760                                         xtype: 'Item',
761                                         xns: Roo.menu,
762                                         listeners : {
763                                             click : function (_self, e)
764                                             {
765                                                Roo.MessageBox.confirm(
766                                                     "Confirm",
767                                                     "It is going to fill in all the blank return stock. Are you sure?",
768                                                     function(r) {
769                                                         if (r != 'yes') {
770                                                             return;
771                                                         }
772                                                         new Pman.Request(
773                                                         {
774                                                             url : baseURL + '/Roo/Cmhead',
775                                                             mask: 'Processing',
776                                                             method : 'POST',
777                                                             params : {
778                                                                 _fix_stock : 1
779                                                             },
780                                                             success : function()
781                                                             {
782                                                                 Roo.MessageBox.alert('Notice','Fixed');
783                                                                 _this.grid.footer.onClick('refresh');
784                                                             } 
785                                                         });
786                                                     }
787                                                 ); 
788                                             }
789                                         },
790                                         cls : 'x-btn-text-icon',
791                                         text : "Fix Blank Return Stock",
792                                         icon : Roo.rootURL + 'images/default/tree/leaf.gif'
793                                     }
794                                 ]
795                             }
796                         }
797                     ]
798                 },
799                 colModel : [
800                     {
801                         xtype: 'ColumnModel',
802                         xns: Roo.grid,
803                         dataIndex : 'cmhead_number',
804                         header : 'Ref #',
805                         sortable : true,
806                         width : 150,
807                         renderer : function(v) { return String.format('{0}', v); }
808                     },
809                     {
810                         xtype: 'ColumnModel',
811                         xns: Roo.grid,
812                         dataIndex : 'cmhead_docdate',
813                         header : 'Date',
814                         sortable : true,
815                         width : 100,
816                         renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
817                     },
818                     {
819                         xtype: 'ColumnModel',
820                         xns: Roo.grid,
821                         dataIndex : 'cmhead_salesrep_id_salesrep_name',
822                         header : 'Sales Rep',
823                         sortable : true,
824                         width : 80,
825                         renderer : function(v) { return String.format('{0}', v  ); }
826                     },
827                     {
828                         xtype: 'ColumnModel',
829                         xns: Roo.grid,
830                         dataIndex : 'cust_salesrep_salesrep_name',
831                         header : 'Cust. Sales Rep',
832                         sortable : true,
833                         width : 80,
834                         renderer : function(v) { return String.format('{0}', v  ); }
835                     },
836                     {
837                         xtype: 'ColumnModel',
838                         xns: Roo.grid,
839                         dataIndex : 'cmhead_cust_id_cust_name',
840                         header : 'Customer',
841                         width : 200,
842                         renderer : function(v) { return String.format('{0}', v); }
843                     },
844                     {
845                         xtype: 'ColumnModel',
846                         xns: Roo.grid,
847                         align : 'right',
848                         dataIndex : 'cmhead_curr_id_curr_symbol',
849                         header : 'Currency',
850                         width : 70,
851                         renderer : function(v)
852                         {
853                             return String.format('{0}', v ? v : '??');
854                         }
855                     },
856                     {
857                         xtype: 'ColumnModel',
858                         xns: Roo.grid,
859                         align : 'right',
860                         dataIndex : 'cmhead_value',
861                         header : 'Value',
862                         width : 100,
863                         renderer : function(v)
864                         {
865                             return Roo.util.Format.usMoney(v);
866                         }
867                     },
868                     {
869                         xtype: 'ColumnModel',
870                         xns: Roo.grid,
871                         align : 'right',
872                         dataIndex : 'cmhead_unpaid',
873                         header : 'Open Value',
874                         width : 100,
875                         renderer : function(v,x,r)
876                         {
877                             if (!r.data.cmhead_posted) {
878                                 return '';
879                             }
880                             return Roo.util.Format.usMoney(v);
881                         }
882                     },
883                     {
884                         xtype: 'ColumnModel',
885                         xns: Roo.grid,
886                         dataIndex : 'cmhead_posted',
887                         header : 'Posted',
888                         width : 75,
889                         renderer : function(v) { return String.format('{0}', v ? 'Yes':''); }
890                     }
891                 ]
892             }
893         };
894     }
895 });