Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Tab.XtupleCustomer.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Roo.namespace('Pman.Tab');
6
7 Pman.Tab.XtupleCustomer = new Roo.XComponent({
8     part     :  ["Xtuple", "Customer" ],
9     order    : '700-Pman.Tab.XtupleCustomer',
10     region   : 'center',
11     parent   : 'Pman.Tab.XtupleSales',
12     name     : "unnamed module",
13     disabled : false, 
14     permname : '', 
15     _tree : function()
16     {
17         var _this = this;
18         var MODULE = this;
19         return {
20             grid : {
21                 dataSource : {
22                     proxy : {
23                         '|xns' : 'Roo.data',
24                         url : baseURL + '/Roo/custinfo.php',
25                         xtype : 'HttpProxy',
26                         method : 'GET',
27                         xns : Roo.data
28                     },
29                     reader : {
30                         '|xns' : 'Roo.data',
31                         id : 'id',
32                         root : 'data',
33                         xtype : 'JsonReader',
34                         fields : [
35                             {
36                                 'name': 'cust_active',
37                                 'type': 'boolean'
38                             },
39                             {
40                                 'name': 'cust_custtype_id_custtype_descrip',
41                                 'type': 'string'
42                             },
43                             {
44                                 'name': 'cust_salesrep_id_salesrep_name',
45                                 'type': 'string'
46                             },
47                             {
48                                 'name': 'cust_name',
49                                 'type': 'string'
50                             }
51                         ],
52                         xns : Roo.data,
53                         builderCfg : '{\"cols\":[{\"table\":\"custinfo\",\"column\":\"cust_active\",\"columnshort\":\"cust_active\",\"ctype\":\"bool\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Active\"},{\"table\":\"custtype\",\"column\":\"cust_custtype_id_custtype_descrip\",\"columnshort\":\"custtype_descrip\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Customer type\"},{\"table\":\"salesrep\",\"column\":\"cust_salesrep_id_salesrep_name\",\"columnshort\":\"salesrep_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":0,\"title\":\"Sales Rep\"},{\"table\":\"custinfo\",\"column\":\"cust_name\",\"columnshort\":\"cust_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"Name\"}],\"cols_ex\":[\"cust_name\"],\"table\":\"custinfo\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}',
54                         totalProperty : 'total'
55                     },
56                     '|xns' : 'Roo.data',
57                     xtype : 'Store',
58                     remoteSort : true,
59                     sortInfo : { field : 'cust_name', direction: 'ASC' },
60                     xns : Roo.data,
61                     listeners : {
62                         beforeload : function (_self, o)
63                            {
64                                if (!_this.officeCombo) {
65                                    return false;
66                                }
67                                
68                                o.params = o.params || {};
69                                o.params['search[_mix]'] = _this.searchBox.getValue();
70                                if (!_this.activeBtn.pressed) {
71                                    o.params.cust_active = 1;
72                                    o.params.cust_aropen_active = 1;
73                                } 
74                                var dt = _this.dateSearch.getValue(); 
75                                if (dt) {
76                                    o.params['search[orders_since]'] = dt.format('Y-m-d');
77                                }
78                                dt = _this.dateSearchNo.getValue(); 
79                                if (dt) {
80                                    o.params['search[no_orders_since]'] = dt.format('Y-m-d');
81                                }
82                                
83                                o.params['search[with_orders_since]'] = 1; //
84                                o.params['search[with_balance]'] = 1;
85                                o.params['search[with_address]'] = 1;
86                                o.params['_with_char'] = 1;    
87                                o.params['_with_group_data'] = 1;
88                                o.params['search[_country]'] = _this.country.getValue();
89                                o.params._get = 1; // for download
90                                
91                                o.params['cust_char_internalcompany'] = _this.officeCombo.getValue();
92                            }
93                     },
94                     items : [
95
96                     ]
97
98                 },
99                 footer : {
100                     '|xns' : 'Roo',
101                     pageSize : 25,
102                     xtype : 'PagingToolbar',
103                     emptyMsg : "No custinfo found",
104                     xns : Roo,
105                     displayInfo : true,
106                     displayMsg : "Displaying custinfo{0} - {1} of {2}",
107                     items : [
108                         {
109                             menu : {
110                                 '|xns' : 'Roo.menu',
111                                 xtype : 'Menu',
112                                 xns : Roo.menu,
113                                 items : [
114                                         {
115                                         '|xns' : 'Roo.menu',
116                                         text : "Download Mailing list subscribers",
117                                         xtype : 'Item',
118                                         xns : Roo.menu,
119                                         listeners : {
120                                                 click : function (_self, e)
121                                                    {
122                                                        
123                                                        if (!Pman.hasPerm('Xtuple.CustomerDownload','S')) {
124                                                            Roo.MessageBox.alert("Error", "Permission Denied");
125                                                            return;
126                                                        }
127                                                       
128                                                        var params = {
129                                                            '_group' : 'customer',
130                                                            '_name' : 'subscribers',
131                                                            'limit' : 99999,
132                                                            'csvTitles' : '*',
133                                                            'csvCols' : '*'
134                                                        };
135                                                        
136                                                        
137                                                        new Pman.Download({
138                                                          url : baseURL + '/Roo/Metasql',
139                                                          params :   params,
140                                                          method : 'GET'
141                                                        });
142                                                        
143                                                        Roo.MessageBox.alert("Notice", "Report will download shortly");
144                                                        
145                                                    }
146                                         }
147                                     },
148                                         {
149                                         '|xns' : 'Roo.menu',
150                                         text : "Download Customers",
151                                         xtype : 'Item',
152                                         xns : Roo.menu,
153                                         listeners : {
154                                                 click : function (_self, e)
155                                                    {
156                                                        
157                                                        if (!Pman.hasPerm('Xtuple.CustomerDownload','S')) {
158                                                            Roo.MessageBox.alert("Error", "Permission Denied");
159                                                            return;
160                                                        }
161                                                        _this.grid.ds.proxy.conn.method = 'POST';
162                                                        new Pman.Download({
163                                                            grid : _this.grid
164                                                        });
165                                                        
166                                                    }
167                                         }
168                                     },
169                                         {
170                                         '|xns' : 'Roo.menu',
171                                         text : "Download Customers As Json",
172                                         xtype : 'Item',
173                                         xns : Roo.menu,
174                                         listeners : {
175                                                 click : function (_self, e)
176                                                    {
177                                                        
178                                                        if (!Pman.hasPerm('Admin.Admin_Tab','S')) {
179                                                            Roo.MessageBox.alert("Error", "Permission Denied");
180                                                            return;
181                                                        }
182                                                        
183                                                        var c = _this.country.getValue();
184                                                        if(!c.length){
185                                                            Roo.MessageBox.alert("Error", "Please select a country");
186                                                            return;
187                                                        }
188                                                        
189                                                        new Pman.Download({
190                                                            url : baseURL + '/Roo/custinfo',
191                                                            method : 'GET',
192                                                            params : {
193                                                                _my_json : 1,
194                                                                limit : 9999,
195                                                                'search[_country]' : c,
196                                                                'search[with_address]' : 1
197                                                            }
198                                                            
199                                                        });
200                                                    }
201                                         }
202                                     },
203                                         {
204                                         '|xns' : 'Roo.menu',
205                                         text : "Upload Customers",
206                                         xtype : 'Item',
207                                         xns : Roo.menu,
208                                         listeners : {
209                                                 click : function (_self, e)
210                                                    {
211                                                        
212                                                        if (!Pman.hasPerm('Admin.Admin_Tab','S')) {
213                                                            Roo.MessageBox.alert("Error", "Permission Denied");
214                                                            return;
215                                                        }
216                                                       
217                                                       Pman.Dialog.Image.show(
218                                                           {
219                                                                _url : baseURL+'/Xtuple/Import/Customers' 
220                                                            
221                                                           },
222                                                           function (data) {
223                                                                _this.grid.footer.onClick('first');
224                                                                Roo.MessageBox.alert("Notice", "DONE");
225                                                    //            Roo.MessageBox.alert("Notice", msg.join("\n"));
226                                                    
227                                                           }
228                                                       );
229                                                        
230                                                    }
231                                         }
232                                     },
233                                         {
234                                         '|xns' : 'Roo.menu',
235                                         text : "Upload Customers Json File",
236                                         xtype : 'Item',
237                                         xns : Roo.menu,
238                                         listeners : {
239                                                 click : function (_self, e)
240                                                    {
241                                                        
242                                                        if (!Pman.hasPerm('Admin.Admin_Tab','S')) {
243                                                            Roo.MessageBox.alert("Error", "Permission Denied");
244                                                            return;
245                                                        }
246                                                       
247                                                       Pman.Dialog.Image.show(
248                                                           {
249                                                                _url : baseURL+'/Xtuple/Import/MyCustomers' 
250                                                            
251                                                           },
252                                                           function (data) {
253                                                                _this.grid.footer.onClick('first');
254                                                                Roo.MessageBox.alert("Notice", "DONE");
255                                                    //            Roo.MessageBox.alert("Notice", msg.join("\n"));
256                                                    
257                                                           }
258                                                       );
259                                                        
260                                                    }
261                                         }
262                                     },
263                                         {
264                                         '|xns' : 'Roo.menu',
265                                         text : "Upload AU Post Accounts",
266                                         xtype : 'Item',
267                                         xns : Roo.menu,
268                                         listeners : {
269                                                 click : function (_self, e)
270                                                    {
271                                                        
272                                                        if (!Pman.hasPerm('Admin.Admin_Tab','S')) {
273                                                            Roo.MessageBox.alert("Error", "Permission Denied");
274                                                            return;
275                                                        }
276                                                       
277                                                       Pman.Dialog.Image.show(
278                                                           {
279                                                                _url : baseURL+'/Xtuple/Import/AUPostAccounts' 
280                                                            
281                                                           },
282                                                           function (data) {
283                                                                _this.grid.footer.onClick('first');
284                                                                Roo.MessageBox.alert("Notice", data);
285                                                    
286                                                           }
287                                                       );
288                                                        
289                                                    }
290                                         }
291                                     }
292                                 ]
293
294                             },
295                             '|xns' : 'Roo.Toolbar',
296                             text : "Upload/Download",
297                             xtype : 'Button',
298                             xns : Roo.Toolbar,
299                             items : [
300
301                             ]
302
303                         }
304                     ]
305
306                 },
307                 toolbar : {
308                     '|xns' : 'Roo',
309                     xtype : 'Toolbar',
310                     xns : Roo,
311                     items : [
312                         {
313                             '|xns' : 'Roo.Toolbar',
314                             text : "Search : ",
315                             xtype : 'TextItem',
316                             xns : Roo.Toolbar
317                         },
318                         {
319                             '|xns' : 'Roo.form',
320                             xtype : 'TextField',
321                             xns : Roo.form,
322                             listeners : {
323                                 specialkey : function (_self, e)
324                                    {
325                                        _this.grid.footer.onClick('first');
326                                    },
327                                 render : function (_self)
328                                    {
329                                        _this.searchBox = _self;
330                                    }
331                             }
332                         },
333                         {
334                             '|xns' : 'Roo.Toolbar',
335                             xtype : 'Button',
336                             cls : 'x-btn-icon',
337                             icon : rootURL + '/Pman/templates/images/search.gif',
338                             xns : Roo.Toolbar,
339                             listeners : {
340                                 click : function (_self, e)
341                                    {
342                                    _this.grid.footer.onClick('first');
343                                    }
344                             }
345                         },
346                         {
347                             '|xns' : 'Roo.Toolbar',
348                             xtype : 'Button',
349                             cls : 'x-btn-icon',
350                             icon : rootURL + '/Pman/templates/images/edit-clear.gif',
351                             xns : Roo.Toolbar,
352                             listeners : {
353                                 click : function (_self, e)
354                                    {
355                                        _this.searchBox.setValue('');
356                                        
357                                        
358                                        _this.grid.footer.onClick('first');
359                                    }
360                             }
361                         },
362                         {
363                             store : {
364                                 '|xns' : 'Roo.data',
365                                 xtype : 'SimpleStore',
366                                 data : [ 
367                                     [ ''] ,
368                                     [ 'hk' ],
369                                     [ 'sg' ],
370                                     [ 'my' ],
371                                     [ 'cn' ],
372                                     [ 'au' ]
373                                 ],
374                                 fields : ['office'],
375                                 xns : Roo.data
376                             },
377                             '|xns' : 'Roo.form',
378                             listWidth : 200,
379                             triggerAction : 'all',
380                             fieldLabel : 'Office',
381                             displayField : 'office',
382                             xtype : 'ComboBox',
383                             hiddenName : 'office',
384                             valueField : 'office',
385                             allowBlank : true,
386                             editable : false,
387                             width : 75,
388                             xns : Roo.form,
389                             mode : 'local',
390                             name : 'office',
391                             tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{office}</b> </div>',
392                             listeners : {
393                                 render : function (_self)
394                                    {
395                                      _this.officeCombo  = _self;
396                                    },
397                                 select : function (combo, record, index)
398                                    {
399                                    
400                                        _this.grid.footer.onClick('first');
401                                    }
402                             },
403                             items : [
404
405                             ]
406
407                         },
408                         {
409                             store : {
410                                 proxy : {
411                                     '|xns' : 'Roo.data',
412                                     url : baseURL + '/Roo/Addr.php',
413                                     xtype : 'HttpProxy',
414                                     method : 'GET',
415                                     xns : Roo.data
416                                 },
417                                 reader : {
418                                     '|xns' : 'Roo.data',
419                                     id : 'addr_id',
420                                     root : 'data',
421                                     xtype : 'JsonReader',
422                                     fields : [{"name":"addr_id","type":"int"},{"name":"addr_country","type":"string"}],
423                                     xns : Roo.data,
424                                     totalProperty : 'total'
425                                 },
426                                 '|xns' : 'Roo.data',
427                                 xtype : 'Store',
428                                 remoteSort : true,
429                                 sortInfo : { direction : 'ASC', field: 'addr_country' },
430                                 xns : Roo.data,
431                                 listeners : {
432                                         beforeload : function (_self, o){
433                                                o.params = o.params || {};
434                                                o.params._distinct = 'addr_country';
435                                                o.params._columns ='addr_country';
436                                            }
437                                 },
438                                 items : [
439
440                                 ]
441
442                             },
443                             '|xns' : 'Roo.form',
444                             alwaysQuery : true,
445                             listWidth : 300,
446                             triggerAction : 'all',
447                             fieldLabel : 'Country',
448                             forceSelection : true,
449                             selectOnFocus : true,
450                             pageSize : 20,
451                             displayField : 'addr_country',
452                             emptyText : "Select Country",
453                             hiddenName : 'addr_country',
454                             minChars : 2,
455                             valueField : 'addr_country',
456                             xtype : 'ComboBox',
457                             allowBlank : true,
458                             typeAhead : true,
459                             editable : true,
460                             width : 150,
461                             xns : Roo.form,
462                             name : 'addr_country',
463                             qtip : "Select Country",
464                             queryParam : 'query[addr_country]',
465                             tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{addr_country}</b> </div>',
466                             loadingText : "Searching...",
467                             listeners : {
468                                 render : function (_self)
469                                    {
470                                        _this.country = _self;
471                                    },
472                                 select : function (combo, record, index)
473                                    {
474                                        _this.grid.footer.onClick('first');
475                                    }
476                             },
477                             items : [
478
479                             ]
480
481                         },
482                         {
483                             '|xns' : 'Roo.Toolbar',
484                             text : "Show / Hide Inactive",
485                             enableToggle : true,
486                             pressed : false,
487                             xtype : 'Button',
488                             xns : Roo.Toolbar,
489                             listeners : {
490                                 toggle : function (_self, pressed)
491                                    {
492                                        _this.grid.footer.onClick('first');
493                                    },
494                                 render : function (_self)
495                                    {
496                                        _this.activeBtn = _self;
497                                    }
498                             }
499                         },
500                         {
501                             '|xns' : 'Roo.Toolbar',
502                             text : "Has orders since",
503                             xtype : 'TextItem',
504                             xns : Roo.Toolbar
505                         },
506                         {
507                             '|xns' : 'Roo.form',
508                             format : 'Y-m-d',
509                             xtype : 'DateField',
510                             xns : Roo.form,
511                             listeners : {
512                                 specialkey : function (_self, e)
513                                    {
514                                       _this.grid.footer.onClick('first');
515                                    },
516                                 render : function (_self)
517                                    {
518                                        _this.dateSearch = _self
519                                    },
520                                 select : function (combo, date)
521                                    {
522                                        _this.grid.footer.onClick('first');
523                                    }
524                             }
525                         },
526                         {
527                             '|xns' : 'Roo.Toolbar',
528                             text : "No orders since",
529                             xtype : 'TextItem',
530                             xns : Roo.Toolbar
531                         },
532                         {
533                             '|xns' : 'Roo.form',
534                             format : 'Y-m-d',
535                             xtype : 'DateField',
536                             xns : Roo.form,
537                             listeners : {
538                                 specialkey : function (_self, e)
539                                    {
540                                       _this.grid.footer.onClick('first');
541                                    },
542                                 render : function (_self)
543                                    {
544                                        _this.dateSearchNo = _self
545                                    },
546                                 select : function (combo, date)
547                                    {
548                                       _this.grid.footer.onClick('first');
549                                    }
550                             }
551                         },
552                         {
553                             '|xns' : 'Roo.Toolbar',
554                             xtype : 'Fill',
555                             xns : Roo.Toolbar
556                         },
557                         {
558                             '|xns' : 'Roo.Toolbar',
559                             text : "Add",
560                             xtype : 'Button',
561                             cls : 'x-btn-text-icon',
562                             icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
563                             xns : Roo.Toolbar,
564                             listeners : {
565                                 click : function()
566                                    {
567                                        if (!_this.dialog) return;
568                                        _this.dialog.show( { id : 0 } , function() {
569                                            _this.grid.footer.onClick('first');
570                                       }); 
571                                    }
572                             }
573                         },
574                         {
575                             '|xns' : 'Roo.Toolbar',
576                             text : "Edit",
577                             xtype : 'Button',
578                             cls : 'x-btn-text-icon',
579                             icon : Roo.rootURL + 'images/default/tree/leaf.gif',
580                             xns : Roo.Toolbar,
581                             listeners : {
582                                 click : function()
583                                    {
584                                        var s = _this.grid.getSelectionModel().getSelections();
585                                        if (!s.length || (s.length > 1))  {
586                                            Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
587                                            return;
588                                        }
589                                        if (!_this.dialog) return;
590                                        _this.dialog.show(s[0].data, function() {
591                                            _this.grid.footer.onClick('first');
592                                        }); 
593                                        
594                                    }
595                             }
596                         }
597                     ]
598
599                 },
600                 '|xns' : 'Roo.grid',
601                 autoExpandColumn : 'cust_name',
602                 xtype : 'Grid',
603                 loadMask : true,
604                 xns : Roo.grid,
605                 builderCfg : '{\"cols\":[{\"table\":\"custinfo\",\"column\":\"cust_active\",\"columnshort\":\"cust_active\",\"ctype\":\"bool\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Active\"},{\"table\":\"custtype\",\"column\":\"cust_custtype_id_custtype_descrip\",\"columnshort\":\"custtype_descrip\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Customer type\"},{\"table\":\"salesrep\",\"column\":\"cust_salesrep_id_salesrep_name\",\"columnshort\":\"salesrep_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":0,\"title\":\"Sales Rep\"},{\"table\":\"custinfo\",\"column\":\"cust_name\",\"columnshort\":\"cust_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"Name\"}],\"cols_ex\":[\"cust_name\"],\"table\":\"custinfo\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}',
606                 colModel : [
607                          {
608                                 '|xns' : 'Roo.grid',
609                                 xtype : 'ColumnModel',
610                                 header : 'Active',
611                                 width : 50,
612                                 renderer : function(v) { return String.format('{0}', v? 'Y' : 'N'); },
613                                 xns : Roo.grid,
614                                 dataIndex : 'cust_active',
615                                 builderCfg : '{\"table\":\"custinfo\",\"column\":\"cust_active\",\"columnshort\":\"cust_active\",\"ctype\":\"bool\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Active\"}'
616                             },
617 {
618                                 '|xns' : 'Roo.grid',
619                                 xtype : 'ColumnModel',
620                                 header : 'Last Order',
621                                 width : 80,
622                                 renderer : function(v) { 
623                                     if (!v) { 
624                                         return '-none-';
625                                     }
626                                     var vv = Date.parseDate(v, 'Y-m-d');
627                                     return String.format('{0}',  vv.format('d/M/Y') ); 
628                                 },
629                                 xns : Roo.grid,
630                                 dataIndex : 'last_order'
631                             },
632 {
633                                 '|xns' : 'Roo.grid',
634                                 xtype : 'ColumnModel',
635                                 sortable : true,
636                                 header : 'Tax Status',
637                                 width : 100,
638                                 renderer : function(v) { return String.format('{0}', v); },
639                                 xns : Roo.grid,
640                                 dataIndex : 'cust_taxzone_id_taxzone_descrip',
641                                 builderCfg : '{\"table\":\"custtype\",\"column\":\"cust_custtype_id_custtype_descrip\",\"columnshort\":\"custtype_descrip\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Customer type\"}'
642                             },
643 {
644                                 '|xns' : 'Roo.grid',
645                                 xtype : 'ColumnModel',
646                                 sortable : true,
647                                 header : 'Terms',
648                                 width : 100,
649                                 renderer : function(v) { return String.format('{0}', v); },
650                                 xns : Roo.grid,
651                                 dataIndex : 'cust_terms_id_terms_descrip',
652                                 builderCfg : '{\"table\":\"custtype\",\"column\":\"cust_custtype_id_custtype_descrip\",\"columnshort\":\"custtype_descrip\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Customer type\"}'
653                             },
654 {
655                                 '|xns' : 'Roo.grid',
656                                 xtype : 'ColumnModel',
657                                 sortable : true,
658                                 header : 'Sales Rep',
659                                 width : 100,
660                                 renderer : function(v) { return String.format('{0}', v); },
661                                 xns : Roo.grid,
662                                 dataIndex : 'cust_salesrep_id_salesrep_name',
663                                 builderCfg : '{\"table\":\"salesrep\",\"column\":\"cust_salesrep_id_salesrep_name\",\"columnshort\":\"salesrep_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":0,\"title\":\"Sales Rep\"}'
664                             },
665 {
666                                 '|xns' : 'Roo.grid',
667                                 xtype : 'ColumnModel',
668                                 sortable : true,
669                                 header : 'Curr/Price List',
670                                 width : 80,
671                                 renderer : function(v,x,r) { 
672                                     if (!v.length) {
673                                          return String.format('{0}<br/><span style="color:red">No price list</span>', 
674                                         r.data.cust_curr_id_curr_name  );
675                                      }    
676                                 
677                                     return  String.format('{0}<br/>{1}', 
678                                         r.data.cust_curr_id_curr_name,
679                                        v ); 
680                                    },
681                                 xns : Roo.grid,
682                                 dataIndex : 'ipshead_id_name'
683                             },
684 {
685                                 '|xns' : 'Roo.grid',
686                                 xtype : 'ColumnModel',
687                                 sortable : true,
688                                 header : 'Ref No.',
689                                 width : 80,
690                                 renderer : function(v) { return String.format('{0}', v); },
691                                 xns : Roo.grid,
692                                 dataIndex : 'cust_number'
693                             },
694 {
695                                 '|xns' : 'Roo.grid',
696                                 xtype : 'ColumnModel',
697                                 sortable : true,
698                                 header : 'Name',
699                                 width : 200,
700                                 renderer : function(v,x,r) {
701                                     if (!r.data.cust_char_internalcompany.length) {
702                                          return String.format('{0}', v); 
703                                      }
704                                     return String.format('<span style="color:red">[Internal company : {0}] {1}</span>',
705                                         r.data.cust_char_internalcompany,  v); 
706                                  },
707                                 xns : Roo.grid,
708                                 dataIndex : 'cust_name'
709                             },
710 {
711                                 '|xns' : 'Roo.grid',
712                                 xtype : 'ColumnModel',
713                                 sortable : true,
714                                 header : 'Billing Address',
715                                 width : 200,
716                                 renderer : function(v,x,r) 
717                                 { 
718                                     if(!v.length){
719                                         var add = [];\r
720                                         Roo.each([ 'line1', 'line2', 'line3', 'city', 'state', 'country'], function (k) {\r
721                                             if (!r.data['cntct_addr_' + k].length) {\r
722                                                 return;\r
723                                             }\r
724                                             add.push(String.format("{0}", r.data['cntct_addr_' + k]));\r
725                                         \r
726                                         });
727                                         return add.join('<BR/>');
728                                     }
729                                     
730                                     var v = v.split("\r\n").join("<br/>");
731                                     return v; 
732                                 },
733                                 xns : Roo.grid,
734                                 dataIndex : 'cust_bill_info'
735                             },
736 {
737                                 '|xns' : 'Roo.grid',
738                                 xtype : 'ColumnModel',
739                                 sortable : true,
740                                 header : 'Shipping Address',
741                                 width : 200,
742                                 renderer : function(v,x,r) 
743                                 { 
744                                     if(!v.length){
745                                         var add = [];\r
746                                         Roo.each([ 'line1', 'line2', 'line3', 'city', 'state', 'country'], function (k) {\r
747                                             if (!r.data['cntct_addr_' + k].length) {\r
748                                                 return;\r
749                                             }\r
750                                             add.push(String.format("{0}", r.data['cntct_addr_' + k]));\r
751                                         \r
752                                         });
753                                         return add.join('<BR/>');
754                                     }
755                                     
756                                     var v = v.split("\r\n").join("<br/>");
757                                     return v; 
758                                 },
759                                 xns : Roo.grid,
760                                 dataIndex : 'cust_ship_info'
761                             },
762 {
763                                 '|xns' : 'Roo.grid',
764                                 xtype : 'ColumnModel',
765                                 sortable : true,
766                                 header : 'Contact',
767                                 width : 150,
768                                 renderer : function(v,x,r) 
769                                 { 
770                                     return String.format(
771                                         'Name: {0}<br/>' + 
772                                         'Phone: {1}<br/>' + 
773                                         'Email: <a href="mailto:{2}">{2}</a>',
774                                     
775                                         r.data.cust_cntct_id_cntct_first_name,
776                                         r.data.cust_cntct_id_cntct_phone,
777                                         r.data.cust_cntct_id_cntct_email
778                                     );
779                                 },
780                                 xns : Roo.grid,
781                                 dataIndex : 'cust_cntct_id_cntct_first_name'
782                             },
783 {
784                                 '|xns' : 'Roo.grid',
785                                 hidden : true,
786                                 xtype : 'ColumnModel',
787                                 sortable : true,
788                                 header : 'AU Post#',
789                                 width : 150,
790                                 renderer : function(v,x,r) 
791                                 { 
792                                     return String.format('{0}', v);
793                                 },
794                                 xns : Roo.grid,
795                                 dataIndex : 'cust_char_au_post_accno'
796                             },
797 {
798                                 '|xns' : 'Roo.grid',
799                                 hidden : true,
800                                 xtype : 'ColumnModel',
801                                 sortable : true,
802                                 header : 'Contact Number',
803                                 width : 150,
804                                 renderer : function(v,x,r) 
805                                 { 
806                                     return String.format('{0}',v);
807                                 },
808                                 xns : Roo.grid,
809                                 dataIndex : 'cust_cntct_id_cntct_phone'
810                             },
811 {
812                                 '|xns' : 'Roo.grid',
813                                 hidden : true,
814                                 xtype : 'ColumnModel',
815                                 sortable : true,
816                                 header : 'Email',
817                                 width : 150,
818                                 renderer : function(v,x,r) 
819                                 { 
820                                     return String.format('<a href="mailto:{0}">{0}</a>', v);
821                                 },
822                                 xns : Roo.grid,
823                                 dataIndex : 'cust_cntct_id_cntct_email'
824                             },
825 {
826                                 '|xns' : 'Roo.grid',
827                                 align : 'right',
828                                 hidden : true,
829                                 xtype : 'ColumnModel',
830                                 sortable : true,
831                                 header : 'City',
832                                 width : 75,
833                                 renderer : function(v) { return String.format('{0}', v ? v : ''); },
834                                 xns : Roo.grid,
835                                 dataIndex : 'cntct_addr_city'
836                             },
837 {
838                                 '|xns' : 'Roo.grid',
839                                 align : 'right',
840                                 hidden : true,
841                                 xtype : 'ColumnModel',
842                                 sortable : true,
843                                 header : 'State',
844                                 width : 75,
845                                 renderer : function(v) { return String.format('{0}', v ? v : ''); },
846                                 xns : Roo.grid,
847                                 dataIndex : 'cntct_addr_state'
848                             },
849 {
850                                 '|xns' : 'Roo.grid',
851                                 align : 'right',
852                                 xtype : 'ColumnModel',
853                                 sortable : true,
854                                 header : 'Country',
855                                 width : 75,
856                                 renderer : function(v) { return String.format('{0}', v ? v : ''); },
857                                 xns : Roo.grid,
858                                 dataIndex : 'cntct_addr_country'
859                             },
860 {
861                                 '|xns' : 'Roo.grid',
862                                 xtype : 'ColumnModel',
863                                 sortable : true,
864                                 header : 'Currency',
865                                 width : 50,
866                                 renderer : function(v) { return String.format('{0}', v); },
867                                 xns : Roo.grid,
868                                 dataIndex : 'cust_curr_id_curr_name',
869                                 builderCfg : '{\"table\":\"custtype\",\"column\":\"cust_custtype_id_custtype_descrip\",\"columnshort\":\"custtype_descrip\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Customer type\"}'
870                             },
871 {
872                                 '|xns' : 'Roo.grid',
873                                 align : 'right',
874                                 xtype : 'ColumnModel',
875                                 header : 'Balance',
876                                 width : 75,
877                                 renderer : function(v,x,r) { 
878                                 
879                                      
880                                     return String.format('{0}{1}', r.data.cust_curr_id_curr_symbol, Roo.util.Format.number(v,2)); 
881                                 },
882                                 xns : Roo.grid,
883                                 dataIndex : 'balance'
884                             }
885                 ],
886                 listeners : {
887                         rowdblclick : function (_self, rowIndex, e)
888                            {
889                                if (!_this.dialog) return;
890                                _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
891                                    _this.grid.footer.onClick('refresh');
892                                }); 
893                            },
894                         render : function() 
895                            {
896                                _this.grid = this; 
897                                _this.dialog = Pman.Dialog.XtupleCustomer;
898                                if (_this.panel.active) {
899                                   this.footer.onClick('first');
900                                }
901                            }
902                 },
903                 items : [
904
905                 ]
906
907             },
908             '|xns' : 'Roo',
909             fitToframe : true,
910             region : 'center',
911             background : true,
912             title : "Customers",
913             xtype : 'GridPanel',
914             fitContainer : true,
915             xns : Roo,
916             builderCfg : '{\"cols\":[{\"table\":\"custinfo\",\"column\":\"cust_active\",\"columnshort\":\"cust_active\",\"ctype\":\"bool\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Active\"},{\"table\":\"custtype\",\"column\":\"cust_custtype_id_custtype_descrip\",\"columnshort\":\"custtype_descrip\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Customer type\"},{\"table\":\"salesrep\",\"column\":\"cust_salesrep_id_salesrep_name\",\"columnshort\":\"salesrep_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":0,\"title\":\"Sales Rep\"},{\"table\":\"custinfo\",\"column\":\"cust_name\",\"columnshort\":\"cust_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"Name\"}],\"cols_ex\":[\"cust_name\"],\"table\":\"custinfo\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}',
917             tableName : 'custinfo',
918             listeners : {
919                 activate : function() {
920                        _this.panel = this;
921                        if (_this.grid) {
922                            _this.grid.footer.onClick('first');
923                        }
924                    }
925             },
926             items : [
927
928             ]
929
930         };    }
931 });