Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Tab.XtupleSalesHistory.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.XtupleSalesHistory = new Roo.XComponent({
6     part     :  ["Xtuple","SalesHistory"],
7     order    : '400-Pman.Tab.XtupleSalesHistory',
8     region   : 'center',
9     parent   : 'Pman.Tab.XtupleSales',
10     name     : "Pman.Tab.XtupleSalesHistory",
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.hpanel = this;
23                     if (_this.hgrid) {
24                         _this.hgrid.footer.onClick('first');
25                     }
26                 }
27             },
28             background : true,
29             fitContainer : true,
30             fitToframe : true,
31             region : 'center',
32             tableName : 'cohist',
33             title : "Sales History",
34             grid : {
35                 xtype: 'Grid',
36                 xns: Roo.grid,
37                 listeners : {
38                     render : function() 
39                     {
40                         _this.hgrid = this; 
41                         //_this.dialog = Pman.Dialog.FILL_IN
42                         if (_this.hpanel.active) {
43                            this.footer.onClick('first');
44                         }
45                     },
46                     rowdblclick : function (_self, rowIndex, e)
47                     {
48                         if (!_this.dialog) return;
49                         _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {
50                             _this.grid.footer.onClick('first');
51                         }); 
52                     }
53                 },
54                 autoExpandColumn : 'item_descrip1',
55                 loadMask : true,
56                 dataSource : {
57                     xtype: 'Store',
58                     xns: Roo.data,
59                     listeners : {
60                         beforeload : function (_self, o)
61                         {
62                           
63                             Roo.apply(o.params, {
64                                 _group : 'salesHistory',
65                                 _name : 'bydate',
66                              
67                                 'credit:text' : 'credit',
68                                 'return:text' : 'return',
69                                 'includeFormatted:int' :  1,
70                                 'startDate:text' : _this.dateFrom.getValue(),
71                                 'endDate:text' :  _this.dateTo.getValue()
72                                 
73                             });
74                             
75                             if (_this.custSel.getValue()) {
76                                o.params['cust_id:number'] = _this.custSel.getValue();
77                             }
78                             
79                             if (_this.countrySel.getValue()) {
80                                o.params['addr_country:text'] = _this.countrySel.getValue();
81                             }
82                             
83                             if (_this.postalCodeSel.getValue()) {
84                                o.params['addr_postalcode:text'] = _this.postalCodeSel.getValue();
85                             }
86                             
87                             if (_this.itemSel.getValue()) {
88                                o.params['item_id:number'] = _this.itemSel.getValue();
89                             }
90                             
91                             if (_this.orderRep.getValue()) {
92                                o.params['cohist_salesrep_id:number'] = _this.orderRep.getValue();
93                             }
94                             
95                             if (_this.custRep.getValue()) {
96                                o.params['cust_salesrep_id:number'] = _this.custRep.getValue();
97                             }
98                             
99                         }
100                     },
101                     remoteSort : true,
102                     sortInfo : { field : 'cohist_shipvia', direction: 'ASC' },
103                     proxy : {
104                         xtype: 'HttpProxy',
105                         xns: Roo.data,
106                         method : 'GET',
107                         url : baseURL + '/Roo/metasql.php'
108                     },
109                     reader : {
110                         xtype: 'JsonReader',
111                         xns: Roo.data,
112                         totalProperty : 'total',
113                         root : 'data',
114                         id : 'id',
115                         fields : [
116                             {
117                                 'name': 'cohist_id',
118                                 'type': 'int'
119                             },
120                             {
121                                 'name': 'cohist_cust_id',
122                                 'type': 'int'
123                             },
124                             {
125                                 'name': 'cohist_itemsite_id',
126                                 'type': 'int'
127                             },
128                             {
129                                 'name': 'cohist_shipdate',
130                                 'type': 'date',
131                                 'dateFormat': 'Y-m-d'
132                             },
133                             {
134                                 'name': 'cohist_shipvia',
135                                 'type': 'string'
136                             },
137                             {
138                                 'name': 'cohist_ordernumber',
139                                 'type': 'string'
140                             },
141                             {
142                                 'name': 'cohist_orderdate',
143                                 'type': 'date',
144                                 'dateFormat': 'Y-m-d'
145                             },
146                             {
147                                 'name': 'cohist_invcnumber',
148                                 'type': 'string'
149                             },
150                             {
151                                 'name': 'cohist_invcdate',
152                                 'type': 'date',
153                                 'dateFormat': 'Y-m-d'
154                             },
155                             {
156                                 'name': 'cohist_qtyshipped',
157                                 'type': 'float'
158                             },
159                             {
160                                 'name': 'cohist_unitprice',
161                                 'type': 'float'
162                             },
163                             {
164                                 'name': 'cohist_shipto_id',
165                                 'type': 'int'
166                             },
167                             {
168                                 'name': 'cohist_salesrep_id',
169                                 'type': 'int'
170                             },
171                             {
172                                 'name': 'cohist_duedate',
173                                 'type': 'date',
174                                 'dateFormat': 'Y-m-d'
175                             },
176                             {
177                                 'name': 'cohist_imported',
178                                 'type': 'int'
179                             },
180                             {
181                                 'name': 'cohist_billtoname',
182                                 'type': 'string'
183                             },
184                             {
185                                 'name': 'cohist_billtoaddress1',
186                                 'type': 'string'
187                             },
188                             {
189                                 'name': 'cohist_billtoaddress2',
190                                 'type': 'string'
191                             },
192                             {
193                                 'name': 'cohist_billtoaddress3',
194                                 'type': 'string'
195                             },
196                             {
197                                 'name': 'cohist_billtocity',
198                                 'type': 'string'
199                             },
200                             {
201                                 'name': 'cohist_billtostate',
202                                 'type': 'string'
203                             },
204                             {
205                                 'name': 'cohist_billtozip',
206                                 'type': 'string'
207                             },
208                             {
209                                 'name': 'cohist_shiptoname',
210                                 'type': 'string'
211                             },
212                             {
213                                 'name': 'cohist_shiptoaddress1',
214                                 'type': 'string'
215                             },
216                             {
217                                 'name': 'cohist_shiptoaddress2',
218                                 'type': 'string'
219                             },
220                             {
221                                 'name': 'cohist_shiptoaddress3',
222                                 'type': 'string'
223                             },
224                             {
225                                 'name': 'cohist_shiptocity',
226                                 'type': 'string'
227                             },
228                             {
229                                 'name': 'cohist_shiptostate',
230                                 'type': 'string'
231                             },
232                             {
233                                 'name': 'cohist_shiptozip',
234                                 'type': 'string'
235                             },
236                             {
237                                 'name': 'cohist_commission',
238                                 'type': 'float'
239                             },
240                             {
241                                 'name': 'cohist_commissionpaid',
242                                 'type': 'int'
243                             },
244                             {
245                                 'name': 'cohist_unitcost',
246                                 'type': 'float'
247                             },
248                             {
249                                 'name': 'cohist_misc_type',
250                                 'type': 'string'
251                             },
252                             {
253                                 'name': 'cohist_misc_descrip',
254                                 'type': 'string'
255                             },
256                             {
257                                 'name': 'cohist_misc_id',
258                                 'type': 'int'
259                             },
260                             {
261                                 'name': 'cohist_doctype',
262                                 'type': 'string'
263                             },
264                             {
265                                 'name': 'cohist_promisedate',
266                                 'type': 'date',
267                                 'dateFormat': 'Y-m-d'
268                             },
269                             {
270                                 'name': 'cohist_ponumber',
271                                 'type': 'string'
272                             },
273                             {
274                                 'name': 'cohist_curr_id',
275                                 'type': 'int'
276                             },
277                             {
278                                 'name': 'cohist_sequence',
279                                 'type': 'int'
280                             },
281                             {
282                                 'name': 'cohist_taxtype_id',
283                                 'type': 'int'
284                             },
285                             {
286                                 'name': 'cohist_taxzone_id',
287                                 'type': 'int'
288                             },
289                             {
290                                 'name': 'cohist_curr_id_curr_id',
291                                 'type': 'int'
292                             },
293                             {
294                                 'name': 'cohist_curr_id_curr_base',
295                                 'type': 'int'
296                             },
297                             {
298                                 'name': 'cohist_curr_id_curr_name',
299                                 'type': 'string'
300                             },
301                             {
302                                 'name': 'cohist_curr_id_curr_symbol',
303                                 'type': 'string'
304                             },
305                             {
306                                 'name': 'cohist_curr_id_curr_abbr',
307                                 'type': 'string'
308                             },
309                             {
310                                 'name': 'cohist_taxzone_id_taxzone_id',
311                                 'type': 'int'
312                             },
313                             {
314                                 'name': 'cohist_taxzone_id_taxzone_code',
315                                 'type': 'string'
316                             },
317                             {
318                                 'name': 'cohist_taxzone_id_taxzone_descrip',
319                                 'type': 'string'
320                             },
321                             {
322                                 'name': 'cohist_taxtype_id_taxtype_id',
323                                 'type': 'int'
324                             },
325                             {
326                                 'name': 'cohist_taxtype_id_taxtype_name',
327                                 'type': 'string'
328                             },
329                             {
330                                 'name': 'cohist_taxtype_id_taxtype_descrip',
331                                 'type': 'string'
332                             },
333                             {
334                                 'name': 'cohist_taxtype_id_taxtype_sys',
335                                 'type': 'int'
336                             }
337                         ]
338                     }
339                 },
340                 footer : {
341                     xtype: 'PagingToolbar',
342                     xns: Roo,
343                     displayInfo : true,
344                     displayMsg : "Displaying Sales History {0} - {1} of {2}",
345                     emptyMsg : "No cohist found",
346                     pageSize : 25,
347                     items : [
348                         {
349                             xtype: 'TextItem',
350                             xns: Roo.Toolbar,
351                             text : "<span class=\"sales-footer-text\"></span>"
352                         }
353                     ]
354                 },
355                 toolbar : {
356                     xtype: 'Toolbar',
357                     xns: Roo,
358                     items : [
359                         {
360                             xtype: 'ComboBox',
361                             xns: Roo.form,
362                             listeners : {
363                                 render : function (_self)
364                                 {
365                                    _this.custSel = _self;
366                                 }
367                             },
368                             allowBlank : true,
369                             displayField : 'cust_name',
370                             editable : true,
371                             emptyText : "Select Customer",
372                             fieldLabel : 'cust_name',
373                             forceSelection : true,
374                             hiddenName : 'cust_id',
375                             listWidth : 400,
376                             loadingText : "Searching...",
377                             minChars : 2,
378                             name : 'cust_name',
379                             pageSize : 20,
380                             qtip : "Select Customer",
381                             queryParam : 'query[cust_name]',
382                             selectOnFocus : true,
383                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{cust_name}</b> </div>',
384                             triggerAction : 'all',
385                             typeAhead : true,
386                             valueField : 'cust_id',
387                             width : 150,
388                             store : {
389                                 xtype: 'Store',
390                                 xns: Roo.data,
391                                 listeners : {
392                                     beforeload : function (_self, o){
393                                         o.params = o.params || {};
394                                         // set more here
395                                     }
396                                 },
397                                 remoteSort : true,
398                                 sortInfo : { direction : 'ASC', field: 'cust_name' },
399                                 proxy : {
400                                     xtype: 'HttpProxy',
401                                     xns: Roo.data,
402                                     method : 'GET',
403                                     url : baseURL + '/Roo/custinfo.php'
404                                 },
405                                 reader : {
406                                     xtype: 'JsonReader',
407                                     xns: Roo.data,
408                                     id : 'cust_id',
409                                     root : 'data',
410                                     totalProperty : 'total',
411                                     fields : [{"name":"cust_id","type":"int"},"cust_name"]
412                                 }
413                             }
414                         },
415                         {
416                             xtype: 'ComboBox',
417                             xns: Roo.form,
418                             listeners : {
419                                 render : function (_self)
420                                 {
421                                     _this.countrySel = _self;
422                                 }
423                             },
424                             allowBlank : true,
425                             displayField : 'addr_country',
426                             editable : true,
427                             emptyText : "Select Country",
428                             fieldLabel : 'addr_country',
429                             forceSelection : true,
430                             hiddenName : 'addr_country',
431                             listWidth : 400,
432                             loadingText : "Searching...",
433                             minChars : 2,
434                             name : 'addr_country',
435                             pageSize : 20,
436                             qtip : "Select Country",
437                             queryParam : 'query[addr_country]',
438                             selectOnFocus : true,
439                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{addr_country}</b> </div>',
440                             triggerAction : 'all',
441                             typeAhead : true,
442                             valueField : 'addr_country',
443                             width : 100,
444                             store : {
445                                 xtype: 'Store',
446                                 xns: Roo.data,
447                                 listeners : {
448                                     beforeload : function (_self, o){
449                                         o.params = o.params || {};
450                                         o.params._distinct = 'addr_country';
451                                         o.params._columns = 'addr_country';   
452                                         o.params['!addr_country'] = '';        
453                                         // set more here
454                                     }
455                                 },
456                                 remoteSort : true,
457                                 sortInfo : { direction : 'ASC', field: 'addr_country' },
458                                 proxy : {
459                                     xtype: 'HttpProxy',
460                                     xns: Roo.data,
461                                     method : 'GET',
462                                     url : baseURL + '/Roo/addr.php'
463                                 },
464                                 reader : {
465                                     xtype: 'JsonReader',
466                                     xns: Roo.data,
467                                     id : 'addr_country',
468                                     root : 'data',
469                                     totalProperty : 'total',
470                                     fields : [{"name":"addr_country","type":"string"}]
471                                 }
472                             }
473                         },
474                         {
475                             xtype: 'ComboBox',
476                             xns: Roo.form,
477                             listeners : {
478                                 render : function (_self)
479                                 {
480                                     _this.postalCodeSel = _self;
481                                 }
482                             },
483                             allowBlank : true,
484                             displayField : 'addr_postalcode',
485                             editable : true,
486                             emptyText : "Select Postal Code",
487                             fieldLabel : 'addr_postalcode',
488                             forceSelection : true,
489                             hiddenName : 'addr_postalcode',
490                             listWidth : 400,
491                             loadingText : "Searching...",
492                             minChars : 2,
493                             name : 'addr_postalcode',
494                             pageSize : 20,
495                             qtip : "Select Postal Code",
496                             queryParam : 'query[addr_postalcode]',
497                             selectOnFocus : true,
498                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{addr_postalcode}</b> </div>',
499                             triggerAction : 'all',
500                             typeAhead : true,
501                             valueField : 'addr_postalcode',
502                             width : 100,
503                             store : {
504                                 xtype: 'Store',
505                                 xns: Roo.data,
506                                 listeners : {
507                                     beforeload : function (_self, o){
508                                         o.params = o.params || {};
509                                         o.params._distinct = 'addr_postalcode';
510                                         o.params._columns = 'addr_postalcode';   
511                                         o.params['!addr_postalcode'] = '';        
512                                         // set more here
513                                     }
514                                 },
515                                 remoteSort : true,
516                                 sortInfo : { direction : 'ASC', field: 'addr_postalcode' },
517                                 proxy : {
518                                     xtype: 'HttpProxy',
519                                     xns: Roo.data,
520                                     method : 'GET',
521                                     url : baseURL + '/Roo/addr.php'
522                                 },
523                                 reader : {
524                                     xtype: 'JsonReader',
525                                     xns: Roo.data,
526                                     id : 'addr_postalcode',
527                                     root : 'data',
528                                     totalProperty : 'total',
529                                     fields : [{"name":"addr_postalcode","type":"string"}]
530                                 }
531                             }
532                         },
533                         {
534                             xtype: 'ComboBox',
535                             xns: Roo.form,
536                             listeners : {
537                                 render : function (_self)
538                                 {
539                                    _this.itemSel = _self;
540                                 }
541                             },
542                             allowBlank : true,
543                             displayField : 'item_number',
544                             editable : true,
545                             emptyText : "Select Item Number",
546                             fieldLabel : 'item_number',
547                             forceSelection : true,
548                             hiddenName : 'item_number',
549                             listWidth : 400,
550                             loadingText : "Searching...",
551                             minChars : 2,
552                             name : 'item_number',
553                             pageSize : 20,
554                             qtip : "Select Item Number",
555                             queryParam : 'query[number_or_name]',
556                             selectOnFocus : true,
557                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{item_number}</b> </div>',
558                             triggerAction : 'all',
559                             typeAhead : true,
560                             valueField : 'item_id',
561                             width : 100,
562                             store : {
563                                 xtype: 'Store',
564                                 xns: Roo.data,
565                                 listeners : {
566                                     beforeload : function (_self, o){
567                                         o.params = o.params || {};
568                                         // set more here
569                                     }
570                                 },
571                                 remoteSort : true,
572                                 sortInfo : { direction : 'ASC', field: 'item_number' },
573                                 proxy : {
574                                     xtype: 'HttpProxy',
575                                     xns: Roo.data,
576                                     method : 'GET',
577                                     url : baseURL + '/Roo/Item.php'
578                                 },
579                                 reader : {
580                                     xtype: 'JsonReader',
581                                     xns: Roo.data,
582                                     id : 'item_id',
583                                     root : 'data',
584                                     totalProperty : 'total',
585                                     fields : [{"name":"item_id","type":"int"},"item_number"]
586                                 }
587                             }
588                         },
589                         {
590                             xtype: 'ComboBox',
591                             xns: Roo.form,
592                             listeners : {
593                                 render : function (_self)
594                                 {
595                                    _this.orderRep = _self;
596                                 }
597                             },
598                             allowBlank : true,
599                             displayField : 'salesrep_name',
600                             editable : true,
601                             emptyText : "Order Sales Rep",
602                             fieldLabel : 'Order Sales Rep',
603                             forceSelection : true,
604                             hiddenName : 'salesrep_name',
605                             listWidth : 400,
606                             loadingText : "Searching...",
607                             minChars : 2,
608                             name : 'salesrep_name',
609                             pageSize : 20,
610                             qtip : "Select Order Sales Rep",
611                             queryParam : 'query[name]',
612                             selectOnFocus : true,
613                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{salesrep_name}</b> </div>',
614                             triggerAction : 'all',
615                             typeAhead : true,
616                             valueField : 'salesrep_id',
617                             width : 120,
618                             store : {
619                                 xtype: 'Store',
620                                 xns: Roo.data,
621                                 listeners : {
622                                     beforeload : function (_self, o){
623                                         o.params = o.params || {};
624                                         o.params.salesrep_active = 1
625                                     }
626                                 },
627                                 remoteSort : true,
628                                 sortInfo : { direction : 'ASC', field: 'salesrep_id' },
629                                 proxy : {
630                                     xtype: 'HttpProxy',
631                                     xns: Roo.data,
632                                     method : 'GET',
633                                     url : baseURL + '/Roo/Salesrep.php'
634                                 },
635                                 reader : {
636                                     xtype: 'JsonReader',
637                                     xns: Roo.data,
638                                     id : 'salesrep_id',
639                                     root : 'data',
640                                     totalProperty : 'total',
641                                     fields : [{"name":"salesrep_id","type":"int"}]
642                                 }
643                             }
644                         },
645                         {
646                             xtype: 'ComboBox',
647                             xns: Roo.form,
648                             listeners : {
649                                 render : function (_self)
650                                 {
651                                    _this.custRep = _self;
652                                 }
653                             },
654                             allowBlank : true,
655                             displayField : 'salesrep_name',
656                             editable : true,
657                             emptyText : "Customer Sales Rep",
658                             fieldLabel : 'Customer Sales Rep',
659                             forceSelection : true,
660                             hiddenName : 'salesrep_name',
661                             listWidth : 400,
662                             loadingText : "Searching...",
663                             minChars : 2,
664                             name : 'salesrep_name',
665                             pageSize : 20,
666                             qtip : "Select Customer Sales Rep",
667                             queryParam : 'query[name]',
668                             selectOnFocus : true,
669                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{salesrep_name}</b> </div>',
670                             triggerAction : 'all',
671                             typeAhead : true,
672                             valueField : 'salesrep_id',
673                             width : 120,
674                             store : {
675                                 xtype: 'Store',
676                                 xns: Roo.data,
677                                 listeners : {
678                                     beforeload : function (_self, o){
679                                         o.params = o.params || {};
680                                         o.params.salesrep_active = 1
681                                     }
682                                 },
683                                 remoteSort : true,
684                                 sortInfo : { direction : 'ASC', field: 'salesrep_id' },
685                                 proxy : {
686                                     xtype: 'HttpProxy',
687                                     xns: Roo.data,
688                                     method : 'GET',
689                                     url : baseURL + '/Roo/Salesrep.php'
690                                 },
691                                 reader : {
692                                     xtype: 'JsonReader',
693                                     xns: Roo.data,
694                                     id : 'salesrep_id',
695                                     root : 'data',
696                                     totalProperty : 'total',
697                                     fields : [{"name":"salesrep_id","type":"int"}]
698                                 }
699                             }
700                         },
701                         {
702                             xtype: 'TextItem',
703                             xns: Roo.Toolbar,
704                             text : "From"
705                         },
706                         {
707                             xtype: 'DateField',
708                             xns: Roo.form,
709                             listeners : {
710                                 render : function (_self)
711                                 {
712                                   _this.dateFrom = _self;
713                                 }
714                             },
715                             format : 'd/M/Y',
716                             useIso : true,
717                             value : (function() {return (new Date()).add(Date.MONTH, -3); })()
718                         },
719                         {
720                             xtype: 'TextItem',
721                             xns: Roo.Toolbar,
722                             text : "To"
723                         },
724                         {
725                             xtype: 'DateField',
726                             xns: Roo.form,
727                             listeners : {
728                                 render : function (_self)
729                                 {
730                                 _this.dateTo = _self;
731                                 }
732                             },
733                             format : 'd/M/Y',
734                             useIso : true,
735                             value : (function() {return (new Date()) })()
736                         },
737                         {
738                             xtype: 'Button',
739                             xns: Roo.Toolbar,
740                             listeners : {
741                                 click : function (_self, e)
742                                 {
743                                     _this.hgrid.footer.onClick('first');
744                                 }
745                             },
746                             text : "Refresh"
747                         },
748                         {
749                             xtype: 'Fill',
750                             xns: Roo.Toolbar
751                         },
752                         {
753                             xtype: 'Button',
754                             xns: Roo.Toolbar,
755                             text : "Download",
756                             menu : {
757                                 xtype: 'Menu',
758                                 xns: Roo.menu,
759                                 items : [
760                                     {
761                                         xtype: 'Item',
762                                         xns: Roo.menu,
763                                         listeners : {
764                                             click : function (_self, e)
765                                             {
766                                               var o = { params : {}};
767                                                  Roo.apply(o.params, {
768                                                     _group : 'salesHistory',
769                                                     _name : 'bydate',
770                                                     csvCols : '*', csvTitles : '*',
771                                                     'credit:text' : 'credit',
772                                                     'return:text' : 'return',
773                                                     'includeFormatted:int' :  1,
774                                                     'startDate:text' : _this.dateFrom.getValue(),
775                                                     'endDate:text' :  _this.dateTo.getValue(),
776                                                     limit : 99999
777                                                     
778                                                 });
779                                                 
780                                                 if (_this.custSel.getValue()) {
781                                                    o.params['cust_id:number'] = _this.custSel.getValue();
782                                                 }
783                                                 
784                                                 if (_this.countrySel.getValue()) {
785                                                    o.params['addr_country:text'] = _this.countrySel.getValue();
786                                                 }
787                                                 
788                                                 if (_this.postalCodeSel.getValue()) {
789                                                    o.params['addr_postalcode:text'] = _this.postalCodeSel.getValue();
790                                                 }
791                                                 
792                                                 if (_this.itemSel.getValue()) {
793                                                    o.params['item_id:number'] = _this.itemSel.getValue();
794                                                 }
795                                                 
796                                                 if (_this.orderRep.getValue()) {
797                                                    o.params['cohist_salesrep_id:number'] = _this.orderRep.getValue();
798                                                 }
799                                                 
800                                                 if (_this.custRep.getValue()) {
801                                                    o.params['cust_salesrep_id:number'] = _this.custRep.getValue();
802                                                 }
803                                                 
804                                                 
805                                                 new Pman.Download({
806                                                     url: baseURL + '/Roo/Metasql',
807                                                     params : o.params,
808                                                     limit : 100000,
809                                                     newWindow : true
810                                                 });
811                                             }
812                                         },
813                                         text : "Sales History"
814                                     },
815                                     {
816                                         xtype: 'Item',
817                                         xns: Roo.menu,
818                                         listeners : {
819                                             click : function (_self, e)
820                                             {
821                                              var o = { params : {}};
822                                                  Roo.apply(o.params, {
823                                                     _group : 'salesHistory',
824                                                     _name : 'stockist',
825                                                   csvCols : '*', csvTitles : '*',
826                                                     'credit:text' : 'credit',
827                                                     'return:text' : 'return',
828                                                     'includeFormatted:int' :  1,
829                                                     'startDate:text' : _this.dateFrom.getValue(),
830                                                     'endDate:text' :  _this.dateTo.getValue(),
831                                                     limit : 99999
832                                                     
833                                                 });
834                                                 
835                                                 if (_this.custSel.getValue()) {
836                                                    o.params['cust_id:number'] = _this.custSel.getValue();
837                                                 }
838                                                 
839                                                 if (_this.countrySel.getValue()) {
840                                                    o.params['addr_country:text'] = _this.countrySel.getValue();
841                                                 }
842                                                 
843                                                 if (_this.postalCodeSel.getValue()) {
844                                                    o.params['addr_postalcode:text'] = _this.postalCodeSel.getValue();
845                                                 }
846                                                 
847                                                 if (_this.itemSel.getValue()) {
848                                                    o.params['item_id:number'] = _this.itemSel.getValue();
849                                                 }
850                                                 
851                                                 if (_this.orderRep.getValue()) {
852                                                    o.params['cohist_salesrep_id:number'] = _this.orderRep.getValue();
853                                                 }
854                                                 
855                                                 if (_this.custRep.getValue()) {
856                                                    o.params['cust_salesrep_id:number'] = _this.custRep.getValue();
857                                                 }
858                                                 
859                                                 
860                                                 new Pman.Download({
861                                                     url: baseURL + '/Roo/Metasql',
862                                                     params : o.params,
863                                                     limit : 100000,
864                                                     newWindow : true
865                                                 });
866                                             }
867                                         },
868                                         text : "Stockists Summary"
869                                     }
870                                 ]
871                             }
872                         }
873                     ]
874                 },
875                 colModel : [
876                     {
877                         xtype: 'ColumnModel',
878                         xns: Roo.grid,
879                         dataIndex : 'cust_id',
880                         header : 'Cust#',
881                         width : 50,
882                         renderer : function(v) { return String.format('{0}', v); }
883                     },
884                     {
885                         xtype: 'ColumnModel',
886                         xns: Roo.grid,
887                         dataIndex : 'cust_name',
888                         header : 'Customer',
889                         width : 75,
890                         renderer : function(v) { return String.format('{0}', v); }
891                     },
892                     {
893                         xtype: 'ColumnModel',
894                         xns: Roo.grid,
895                         dataIndex : 'order_salesrep_name',
896                         header : 'Order Sales Rep',
897                         width : 100,
898                         renderer : function(v) { return String.format('{0}', v); }
899                     },
900                     {
901                         xtype: 'ColumnModel',
902                         xns: Roo.grid,
903                         dataIndex : 'cust_salesrep_name',
904                         header : 'Customer Sales Rep',
905                         hidden : true,
906                         width : 100,
907                         renderer : function(v) { return String.format('{0}', v); }
908                     },
909                     {
910                         xtype: 'ColumnModel',
911                         xns: Roo.grid,
912                         dataIndex : 'addr_country',
913                         header : 'Country',
914                         width : 75,
915                         renderer : function(v) { return String.format('{0}', v); }
916                     },
917                     {
918                         xtype: 'ColumnModel',
919                         xns: Roo.grid,
920                         dataIndex : 'addr_city',
921                         header : 'City',
922                         hidden : true,
923                         width : 75,
924                         renderer : function(v) { return String.format('{0}', v); }
925                     },
926                     {
927                         xtype: 'ColumnModel',
928                         xns: Roo.grid,
929                         dataIndex : 'addr_state',
930                         header : 'State',
931                         hidden : true,
932                         width : 75,
933                         renderer : function(v) { return String.format('{0}', v); }
934                     },
935                     {
936                         xtype: 'ColumnModel',
937                         xns: Roo.grid,
938                         dataIndex : 'addr_postalcode',
939                         header : 'Postal Code',
940                         width : 75,
941                         renderer : function(v) { return String.format('{0}', v); }
942                     },
943                     {
944                         xtype: 'ColumnModel',
945                         xns: Roo.grid,
946                         dataIndex : 'cohist_ordernumber',
947                         header : 'Order',
948                         width : 75,
949                         renderer : function(v) { return String.format('{0}', v); }
950                     },
951                     {
952                         xtype: 'ColumnModel',
953                         xns: Roo.grid,
954                         dataIndex : 'cohead_orderdate',
955                         header : 'Order date',
956                         width : 75,
957                         renderer : function(v) { 
958                             var d = Date.parseDate(v, 'Y-m-d');
959                             return String.format('{0}', d ? d.format('d/M/Y') : '');
960                          }
961                     },
962                     {
963                         xtype: 'ColumnModel',
964                         xns: Roo.grid,
965                         dataIndex : 'invmonth',
966                         header : 'Invoice Month',
967                         width : 75,
968                         renderer : function(v) { 
969                            
970                             return String.format('{0}', v);
971                          }
972                     },
973                     {
974                         xtype: 'ColumnModel',
975                         xns: Roo.grid,
976                         dataIndex : 'cohist_invcdate',
977                         header : 'Invoice date',
978                         width : 75,
979                         renderer : function(v) { 
980                             var d = Date.parseDate(v, 'Y-m-d');
981                             return String.format('{0}', d ? d.format('d/M/Y') : '');
982                          }
983                     },
984                     {
985                         xtype: 'ColumnModel',
986                         xns: Roo.grid,
987                         dataIndex : 'cohist_invcnumber',
988                         header : 'Invoice#',
989                         width : 75,
990                         renderer : function(v) { return String.format('{0}', v); }
991                     },
992                     {
993                         xtype: 'ColumnModel',
994                         xns: Roo.grid,
995                         dataIndex : 'item_brand',
996                         header : 'Brand',
997                         width : 75,
998                         renderer : function(v) { return String.format('{0}', v ? v   : ''); }
999                     },
1000                     {
1001                         xtype: 'ColumnModel',
1002                         xns: Roo.grid,
1003                         dataIndex : 'item_number',
1004                         header : 'Item No.',
1005                         width : 75,
1006                         renderer : function(v) { return String.format('{0}', v ? v   : ''); }
1007                     },
1008                     {
1009                         xtype: 'ColumnModel',
1010                         xns: Roo.grid,
1011                         dataIndex : 'item_descrip1',
1012                         header : 'Description',
1013                         width : 200,
1014                         renderer : function(v) { return String.format('{0}', v); }
1015                     },
1016                     {
1017                         xtype: 'ColumnModel',
1018                         xns: Roo.grid,
1019                         align : 'right',
1020                         dataIndex : 'cohist_qtyshipped',
1021                         header : 'Shipped',
1022                         width : 70,
1023                         renderer : function(v) { return parseInt(v); }
1024                     },
1025                     {
1026                         xtype: 'ColumnModel',
1027                         xns: Roo.grid,
1028                         dataIndex : 'currabbr',
1029                         header : 'Currency',
1030                         width : 75,
1031                         renderer : function(v) { return String.format('{0}', v.split(/\s+/)[0]); }
1032                     },
1033                     {
1034                         xtype: 'ColumnModel',
1035                         xns: Roo.grid,
1036                         align : 'right',
1037                         dataIndex : 'cohist_unitprice',
1038                         header : 'Unit Price',
1039                         width : 75,
1040                         renderer : function(v) { return Roo.util.Format.number( v, 2); }
1041                     },
1042                     {
1043                         xtype: 'ColumnModel',
1044                         xns: Roo.grid,
1045                         align : 'right',
1046                         dataIndex : 'extprice',
1047                         header : 'Ext Cost',
1048                         width : 75,
1049                         renderer : function(v) { return Roo.util.Format.number( v, 2); }
1050                     },
1051                     {
1052                         xtype: 'ColumnModel',
1053                         xns: Roo.grid,
1054                         align : 'right',
1055                         dataIndex : 'extpricebase',
1056                         header : 'Ext Price (Base)',
1057                         width : 75,
1058                         renderer : function(v) { return Roo.util.Format.number( v, 2); }
1059                     },
1060                     {
1061                         xtype: 'ColumnModel',
1062                         xns: Roo.grid,
1063                         align : 'right',
1064                         dataIndex : 'baseunitprice',
1065                         header : 'Unit Price (Base)',
1066                         hidden : true,
1067                         width : 75,
1068                         renderer : function(v) { return Roo.util.Format.number( v, 2); }
1069                     },
1070                     {
1071                         xtype: 'ColumnModel',
1072                         xns: Roo.grid,
1073                         align : 'right',
1074                         dataIndex : 'basefifovalue',
1075                         header : 'Fifo Cost',
1076                         width : 75,
1077                         renderer : function(v) { return Roo.util.Format.number( v, 2); }
1078                     }
1079                 ]
1080             }
1081         };
1082     }
1083 });