Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Tab.XtupleGeneralLedger.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.XtupleGeneralLedger = new Roo.XComponent({
8     part     :  ["Xtuple", "GeneralLedger" ],
9     order    : '100-Pman.Tab.XtupleGeneralLedger',
10     region   : 'center',
11     parent   : 'Pman.Tab.XtupleAccountsTab',
12     name     : "unnamed module",
13     disabled : false, 
14     permname : '', 
15     _tree : function()
16     {
17         var _this = this;
18         var MODULE = this;
19         return {
20             layout : {
21                 center : {
22                     '|xns' : 'Roo',
23                     xtype : 'LayoutRegion',
24                     tabPosition : 'top',
25                     xns : Roo
26                 },
27                 west : {
28                     '|xns' : 'Roo',
29                     xtype : 'LayoutRegion',
30                     tabPosition : 'top',
31                     width : 600,
32                     xns : Roo,
33                     split : true
34                 },
35                 '|xns' : 'Roo',
36                 xtype : 'BorderLayout',
37                 xns : Roo,
38                 items : [
39                         {
40                         grid : {
41                             toolbar : {
42                                 '|xns' : 'Roo',
43                                 xtype : 'Toolbar',
44                                 xns : Roo,
45                                 items : [
46                                         {
47                                         '|xns' : 'Roo.form',
48                                         xtype : 'TextField',
49                                         xns : Roo.form,
50                                         width : 100,
51                                         listeners : {
52                                                 specialkey : function (_self, e)
53                                                    {
54                                                      _this.wgrid.ds.load({});
55                                                    },
56                                                 render : function (_self)
57                                                    {
58                                                        _this.searchBox = _self;
59                                                    }
60                                         }
61                                     },
62                                         {
63                                         '|xns' : 'Roo.Toolbar',
64                                         xtype : 'Button',
65                                         cls : 'x-btn-icon',
66                                         icon : rootURL + '/Pman/templates/images/search.gif',
67                                         xns : Roo.Toolbar,
68                                         listeners : {
69                                                 click : function (_self, e)
70                                                    {
71                                                        _this.wgrid.ds.load({});
72                                                    }
73                                         }
74                                     },
75                                         {
76                                         '|xns' : 'Roo.Toolbar',
77                                         xtype : 'Button',
78                                         cls : 'x-btn-icon',
79                                         icon : rootURL + '/Pman/templates/images/edit-clear.gif',
80                                         xns : Roo.Toolbar,
81                                         listeners : {
82                                                 click : function (_self, e)
83                                                    {
84                                                        _this.searchBox.setValue('');\r
85                                                        _this.wgrid.ds.load({});\r
86                                                    }
87                                         }
88                                     },
89                                         {
90                                         '|xns' : 'Roo.form',
91                                         format : 'd/M/Y',
92                                         xtype : 'DateField',
93                                         allowBlank : false,
94                                         width : 100,
95                                         xns : Roo.form,
96                                         listeners : {
97                                                 render : function (_self)\r
98                                                    {\r
99                                                        _this.dateSel = _self;\r
100                                                       _self.setValue(  new Date() );\r
101                                                    },
102                                                 select : function (combo, date)
103                                                    {
104                                                        _this.wgrid.ds.load({});
105                                                    }
106                                         }
107                                     },
108                                         {
109                                         '|xns' : 'Roo.Toolbar',
110                                         xtype : 'Fill',
111                                         xns : Roo.Toolbar
112                                     },
113                                         {
114                                         '|xns' : 'Roo.form',
115                                         xtype : 'TextField',
116                                         xns : Roo.form,
117                                         width : 80,
118                                         listeners : {
119                                                 render : function (_self)
120                                                    {
121                                                        _this.orderBox = _self;
122                                                    }
123                                         }
124                                     },
125                                         {
126                                         menu : {
127                                             '|xns' : 'Roo.menu',
128                                             xtype : 'Menu',
129                                             xns : Roo.menu,
130                                             items : [
131                                                 {
132                                                     '|xns' : 'Roo.menu',
133                                                     text : "Show Inactive",
134                                                     xtype : 'Item',
135                                                     xns : Roo.menu,
136                                                     listeners : {
137                                                         click : function (_self, e)
138                                                            {
139                                                                _this.active = (_this.active) ? 0 : 1;
140                                                                this.setText(_this.active ? "Show Inactive" : "Hide Inactive");
141                                                                _this.wgrid.ds.load({});
142                                                            }
143                                                     }
144                                                 },
145                                                 {
146                                                     '|xns' : 'Roo.menu',
147                                                     xtype : 'Separator',
148                                                     xns : Roo.menu
149                                                 },
150                                                 {
151                                                     '|xns' : 'Roo.menu',
152                                                     text : "Export Account Details",
153                                                     xtype : 'Item',
154                                                     xns : Roo.menu,
155                                                     listeners : {
156                                                         click : function (_self, e)
157                                                            {
158                                                                
159                                                              new Pman.Download({
160                                                                    url : baseURL + '/Roo/Metasql',
161                                                                    method : 'GET',
162                                                                    timeout: 60000,
163                                                                    newWindow : true,
164                                                                    params : {
165                                                                        _group : 'accnt',
166                                                                        _name : 'export',
167                                                                        csvCols : '*',
168                                                                        csvTitles : '*', 
169                                                                        limit : 9999         
170                                                                        
171                                                                    }
172                                                                });;
173                                                                Roo.MessageBox.alert("Notice", "Downloading");
174                                                            }
175                                                     }
176                                                 },
177                                                 {
178                                                     '|xns' : 'Roo.menu',
179                                                     text : "Download Balances",
180                                                     xtype : 'Item',
181                                                     xns : Roo.menu,
182                                                     listeners : {
183                                                         click : function (_self, e)
184                                                            {
185                                                                
186                                                                new Pman.download({
187                                                                    url : baseURL + '/Roo/accnt.php',
188                                                                    method : 'GET',
189                                                                    params : {
190                                                                        'start' : 0,
191                                                                        'limit' : 9999,
192                                                                        _with_xt_balances : 1,
193                                                                        'csvTitles[0]' : 'Name', 'csvCols[0]' : 'accnt_name',
194                                                                        'csvTitles[1]' : 'Description', 'csvCols[1]' : 'accnt_descrip',
195                                                                        'csvTitles[2]' : 'Alternative Code', 'csvCols[2]' : 'accnt_code_alt',
196                                                                        'csvTitles[3]' : 'Alternative Description', 'csvCols[3]' : 'accnt_code_descrip',
197                                                                        'csvTitles[4]' : 'ADJUST', 'csvCols[4]' : 'balance_base'
198                                                                    }
199                                                                    
200                                                                });
201                                                            }
202                                                     }
203                                                 },
204                                                 {
205                                                     '|xns' : 'Roo.menu',
206                                                     xtype : 'Separator',
207                                                     xns : Roo.menu
208                                                 },
209                                                 {
210                                                     '|xns' : 'Roo.menu',
211                                                     text : "Upload JE adjustment",
212                                                     xtype : 'Item',
213                                                     xns : Roo.menu,
214                                                     listeners : {
215                                                         click : function (_self, e)
216                                                            {
217                                                               Pman.Dialog.XtupleUploadBalances.show( {} , function(res) {
218                                                                    Pman.Dialog.Image.show({
219                                                                        _url : baseURL + '/Xtuple/Import/JournalEntry?' + Roo.urlEncode(res)
220                                                                    }, function(data) {
221                                                                         _this.wgrid.ds.load({});
222                                                                    });
223                                                               }); 
224                                                            }
225                                                     }
226                                                 },
227                                                 {
228                                                     '|xns' : 'Roo.menu',
229                                                     text : "Upload Account Details",
230                                                     xtype : 'Item',
231                                                     xns : Roo.menu,
232                                                     listeners : {
233                                                         click : function (_self, e)
234                                                            {
235                                                               Pman.Dialog.Image.show(
236                                                                   {
237                                                                        _url : baseURL+'/Xtuple/Import/Accounts',
238                                                                        timeout : 90000
239                                                                    
240                                                                   },
241                                                                   function (data) {
242                                                                        Roo.MessageBox.alert("Notice", data); 
243                                                                        _this.grid.footer.onClick('first');
244                                                            
245                                                                   }
246                                                               );
247                                                            }
248                                                     }
249                                                 },
250                                                 {
251                                                     '|xns' : 'Roo.menu',
252                                                     xtype : 'Separator',
253                                                     xns : Roo.menu
254                                                 },
255                                                 {
256                                                     '|xns' : 'Roo.menu',
257                                                     text : "Download AP - Day by Day Comparison",
258                                                     xtype : 'Item',
259                                                     xns : Roo.menu,
260                                                     listeners : {
261                                                         click : function (_self, e)
262                                                            {
263                                                                
264                                                              new Pman.Download({
265                                                                    url : baseURL + '/Roo/Metasql',
266                                                                    method : 'GET',
267                                                                    timeout: 60000,
268                                                                    newWindow : true,
269                                                                    params : {
270                                                                        _group : 'apopen',
271                                                                        _name : 'bydate',
272                                                                        csvCols : '*',
273                                                                        csvTitles : '*', 
274                                                                        limit : 9999         
275                                                                        
276                                                                    }
277                                                                });;
278                                                                Roo.MessageBox.alert("Notice", "This may take some time to calculate");
279                                                            }
280                                                     }
281                                                 },
282                                                 {
283                                                     '|xns' : 'Roo.menu',
284                                                     text : "Download AP open vs GL - summary of bad days",
285                                                     xtype : 'Item',
286                                                     xns : Roo.menu,
287                                                     listeners : {
288                                                         click : function (_self, e)
289                                                            {
290                                                                
291                                                              new Pman.Download({
292                                                                    url : baseURL + '/Roo/Metasql',
293                                                                    method : 'GET',
294                                                                    timeout: 90000,
295                                                                    params : {
296                                                                        _group : 'apopen',
297                                                                        _name : 'bydatesummary',
298                                                                        csvCols : '*',
299                                                                        csvTitles : '*', 
300                                                                        limit : 9999         
301                                                                        
302                                                                    }
303                                                                });;
304                                                                Roo.MessageBox.alert("Notice", "This may take some time to calculate");
305                                                            }
306                                                     }
307                                                 },
308                                                 {
309                                                     '|xns' : 'Roo.menu',
310                                                     text : "Download AP - Transactions on a single day",
311                                                     xtype : 'Item',
312                                                     xns : Roo.menu,
313                                                     listeners : {
314                                                         click : function (_self, e)
315                                                            {
316                                                                
317                                                              new Pman.Download({
318                                                                    url : baseURL + '/Roo/Metasql',
319                                                                    method : 'GET',
320                                                                    timeout: 90000,
321                                                                    params : {
322                                                                         'startDate:text' : _this.dateSel.getValue().format('Y-m-d'),
323                                                                        'endDate:text' :  _this.dateSel.getValue().add(Date.DAY,1).format('Y-m-d'),
324                                                                    
325                                                                        _group : 'apopen',
326                                                                        _name : 'all',
327                                                                        csvCols : '*',
328                                                                        csvTitles : '*', 
329                                                                        limit : 9999         
330                                                                        
331                                                                    }
332                                                                });;
333                                                                Roo.MessageBox.alert("Notice", "This may take some time to calculate");
334                                                            }
335                                                     }
336                                                 },
337                                                 {
338                                                     '|xns' : 'Roo.menu',
339                                                     text : "Download AP Aging at this date",
340                                                     xtype : 'Item',
341                                                     xns : Roo.menu,
342                                                     listeners : {
343                                                         click : function (_self, e)
344                                                            {
345                                                                
346                                                              new Pman.Download({
347                                                                    url : baseURL + '/Roo/Metasql',
348                                                                    method : 'GET',
349                                                                    timeout: 90000,
350                                                                    newWindow : 1,
351                                                                    params : {
352                                                                         'relDate:text' : _this.dateSel.getValue().format('Y-m-d'),
353                                                                        'useDocDate:text' :  'FALSE',
354                                                                        
355                                                                        _group : 'apAging',
356                                                                        _name : 'bydate',
357                                                                        csvCols : '*',
358                                                                        csvTitles : '*', 
359                                                                        limit : 9999         
360                                                                        
361                                                                    }
362                                                                });;
363                                                                Roo.MessageBox.alert("Notice", "This may take some time to calculate");
364                                                            }
365                                                     }
366                                                 },
367                                                 {
368                                                     '|xns' : 'Roo.menu',
369                                                     text : "Download AP Aging Comparison back from this date",
370                                                     xtype : 'Item',
371                                                     xns : Roo.menu,
372                                                     listeners : {
373                                                         click : function (_self, e)
374                                                            {
375                                                                
376                                                              new Pman.Download({
377                                                                    url : baseURL + '/Roo/Metasql',
378                                                                    method : 'GET',
379                                                                    timeout: 90000,
380                                                                    params : {
381                                                                          'relDate:text' : _this.dateSel.getValue().format('Y-m-d'),
382                                                                        
383                                                                        _group : 'apopen',
384                                                                        _name : 'history',
385                                                                        csvCols : '*',
386                                                                        csvTitles : '*', 
387                                                                        limit : 9999         
388                                                                        
389                                                                    }
390                                                                });
391                                                                Roo.MessageBox.alert("Notice", "This may take some time to calculate");
392                                                            }
393                                                     }
394                                                 },
395                                                 {
396                                                     '|xns' : 'Roo.menu',
397                                                     xtype : 'Separator',
398                                                     xns : Roo.menu
399                                                 },
400                                                 {
401                                                     '|xns' : 'Roo.menu',
402                                                     text : "Download AR - Transactions on a day",
403                                                     xtype : 'Item',
404                                                     xns : Roo.menu,
405                                                     listeners : {
406                                                         click : function (_self, e)
407                                                            {
408                                                                
409                                                                 new Pman.Download({
410                                                                    url : baseURL + '/Roo/Metasql',
411                                                                    method : 'GET',
412                                                                    params : {
413                                                                        _group : 'aropen',
414                                                                        _name : 'all',
415                                                                        'startDate:text' : _this.dateSel.getValue().format('Y-m-d'),
416                                                                        'endDate:text' :  _this.dateSel.getValue().add(Date.DAY,1).format('Y-m-d'),
417                                                                        csvCols : '*',
418                                                                        csvTitles : '*', 
419                                                                        limit : 9999        
420                                                                        
421                                                                    }
422                                                                });;
423                                                            }
424                                                     }
425                                                 },
426                                                 {
427                                                     '|xns' : 'Roo.menu',
428                                                     text : "Download AR - Day by Day Comparison",
429                                                     xtype : 'Item',
430                                                     xns : Roo.menu,
431                                                     listeners : {
432                                                         click : function (_self, e)
433                                                            {
434                                                                
435                                                                 new Pman.Download({
436                                                                    url : baseURL + '/Roo/Metasql',
437                                                                    method : 'GET',
438                                                                    params : {
439                                                                        _group : 'aropen',
440                                                                        _name : 'bydate',
441                                                                        csvCols : '*',
442                                                                        csvTitles : '*', 
443                                                                        limit : 9999         
444                                                                        
445                                                                    }
446                                                                });;
447                                                            }
448                                                     }
449                                                 },
450                                                 {
451                                                     '|xns' : 'Roo.menu',
452                                                     xtype : 'Separator',
453                                                     xns : Roo.menu
454                                                 },
455                                                 {
456                                                     menu : {
457                                                         '|xns' : 'Roo.menu',
458                                                         xtype : 'Menu',
459                                                         xns : Roo.menu,
460                                                         items : [
461                                                                 {
462                                                                 '|xns' : 'Roo.menu',
463                                                                 text : "Download Gltrans vs Stock By Date",
464                                                                 xtype : 'Item',
465                                                                 xns : Roo.menu,
466                                                                 listeners : {
467                                                                         click : function (_self, e)
468                                                                            {
469                                                                                
470                                                                                 new Pman.Download({
471                                                                                    url : baseURL + '/Roo/Metasql',
472                                                                                    method : 'GET',
473                                                                                    timeout: 600000,
474                                                                                    params : {
475                                                                                        _group : 'gltrans_stock',
476                                                                                        _name : 'bydate',
477                                                                                        csvCols : '*',
478                                                                                        csvTitles : '*', 
479                                                                                        limit : 9999       
480                                                                                    }
481                                                                                });
482                                                                            }
483                                                                 }
484                                                             },
485                                                                 {
486                                                                 '|xns' : 'Roo.menu',
487                                                                 text : "Download Gltrans vs Sales Order",
488                                                                 xtype : 'Item',
489                                                                 xns : Roo.menu,
490                                                                 listeners : {
491                                                                         click : function (_self, e)
492                                                                            {
493                                                                                
494                                                                                 new Pman.Download({
495                                                                                    url : baseURL + '/Roo/Metasql',
496                                                                                    method : 'GET',
497                                                                                    timeout: 600000,
498                                                                                    params : {
499                                                                                        _group : 'gltrans_stock',
500                                                                                        _name : 'bycohead',
501                                                                                        csvCols : '*',
502                                                                                        csvTitles : '*', 
503                                                                                        limit : 9999       
504                                                                                    }
505                                                                                });
506                                                                            }
507                                                                 }
508                                                             },
509                                                                 {
510                                                                 '|xns' : 'Roo.menu',
511                                                                 text : "Download Gltrans",
512                                                                 xtype : 'Item',
513                                                                 xns : Roo.menu,
514                                                                 listeners : {
515                                                                         click : function (_self, e)
516                                                                            {
517                                                                                var dt = _this.dateSel.getValue();
518                                                                                 new Pman.Download({
519                                                                                    url : baseURL + '/Roo/Metasql',
520                                                                                    method : 'GET',
521                                                                                    params : {
522                                                                                        _group : 'gltrans_stock',
523                                                                                        _name : 'gltrans',
524                                                                                        '_as_of:text' : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
525                                                                                        csvCols : '*',
526                                                                                        csvTitles : '*', 
527                                                                                        limit : 9999       
528                                                                                    }
529                                                                                });
530                                                                            }
531                                                                 }
532                                                             },
533                                                                 {
534                                                                 '|xns' : 'Roo.menu',
535                                                                 text : "Download Stock",
536                                                                 xtype : 'Item',
537                                                                 xns : Roo.menu,
538                                                                 listeners : {
539                                                                         click : function (_self, e)
540                                                                            {
541                                                                                var dt = _this.dateSel.getValue();
542                                                                                 new Pman.Download({
543                                                                                    url : baseURL + '/Roo/Metasql',
544                                                                                    method : 'GET',
545                                                                                    params : {
546                                                                                        _group : 'gltrans_stock',
547                                                                                        _name : 'stock',
548                                                                                        '_as_of:text' : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
549                                                                                        csvCols : '*',
550                                                                                        csvTitles : '*', 
551                                                                                        limit : 9999       
552                                                                                    }
553                                                                                });
554                                                                            }
555                                                                 }
556                                                             }
557                                                         ]
558
559                                                     },
560                                                     '|xns' : 'Roo.menu',
561                                                     text : "Gltrans vs Stock (COHEAD)",
562                                                     xtype : 'Item',
563                                                     xns : Roo.menu,
564                                                     items : [
565
566                                                     ]
567
568                                                 },
569                                                 {
570                                                     '|xns' : 'Roo.menu',
571                                                     xtype : 'Separator',
572                                                     xns : Roo.menu
573                                                 },
574                                                 {
575                                                     menu : {
576                                                         '|xns' : 'Roo.menu',
577                                                         xtype : 'Menu',
578                                                         xns : Roo.menu,
579                                                         items : [
580                                                                 {
581                                                                 '|xns' : 'Roo.menu',
582                                                                 text : "Download Gltrans vs Stock By PO",
583                                                                 xtype : 'Item',
584                                                                 xns : Roo.menu,
585                                                                 listeners : {
586                                                                         click : function (_self, e)
587                                                                            {
588                                                                                
589                                                                                 new Pman.Download({
590                                                                                    url : baseURL + '/Roo/Metasql',
591                                                                                    method : 'GET',
592                                                                                    timeout: 600000,
593                                                                                    params : {
594                                                                                        _group : 'gltrans_stock',
595                                                                                        _name : 'byorder',
596                                                                                        csvCols : '*',
597                                                                                        csvTitles : '*', 
598                                                                                        limit : 9999       
599                                                                                    }
600                                                                                });
601                                                                            }
602                                                                 }
603                                                             },
604                                                                 {
605                                                                 '|xns' : 'Roo.menu',
606                                                                 text : "Download Gltrans",
607                                                                 xtype : 'Item',
608                                                                 xns : Roo.menu,
609                                                                 listeners : {
610                                                                         click : function (_self, e)
611                                                                            {
612                                                                                var ord = _this.orderBox.getValue();
613                                                                                
614                                                                                if(!ord.length){
615                                                                                    Roo.MessageBox.alert('Error','Please enter a PO number');
616                                                                                    return;
617                                                                                }
618                                                                                
619                                                                                
620                                                                                 new Pman.Download({
621                                                                                    url : baseURL + '/Roo/Metasql',
622                                                                                    method : 'GET',
623                                                                                    params : {
624                                                                                        _group : 'gltrans_stock',
625                                                                                        _name : 'byordergltrans',
626                                                                                        'docnumber:text' : ord,
627                                                                                        csvCols : '*',
628                                                                                        csvTitles : '*', 
629                                                                                        limit : 9999       
630                                                                                    }
631                                                                                });
632                                                                            }
633                                                                 }
634                                                             },
635                                                                 {
636                                                                 '|xns' : 'Roo.menu',
637                                                                 text : "Download Stock",
638                                                                 xtype : 'Item',
639                                                                 xns : Roo.menu,
640                                                                 listeners : {
641                                                                         click : function (_self, e)
642                                                                            {
643                                                                                var ord = _this.orderBox.getValue();
644                                                                                
645                                                                                if(!ord.length){
646                                                                                    Roo.MessageBox.alert('Error','Please enter a PO number');
647                                                                                    return;
648                                                                                }
649                                                                                
650                                                                                
651                                                                                 new Pman.Download({
652                                                                                    url : baseURL + '/Roo/Metasql',
653                                                                                    method : 'GET',
654                                                                                    params : {
655                                                                                        _group : 'gltrans_stock',
656                                                                                        _name : 'byorderstock',
657                                                                                        'docnumber:text' : ord,
658                                                                                        csvCols : '*',
659                                                                                        csvTitles : '*', 
660                                                                                        limit : 9999      
661                                                                                    }
662                                                                                });
663                                                                            }
664                                                                 }
665                                                             }
666                                                         ]
667
668                                                     },
669                                                     '|xns' : 'Roo.menu',
670                                                     text : "Gltrans vs Stock (PO)",
671                                                     xtype : 'Item',
672                                                     xns : Roo.menu,
673                                                     items : [
674
675                                                     ]
676
677                                                 },
678                                                 {
679                                                     '|xns' : 'Roo.menu',
680                                                     xtype : 'Separator',
681                                                     xns : Roo.menu
682                                                 },
683                                                 {
684                                                     menu : {
685                                                         '|xns' : 'Roo.menu',
686                                                         xtype : 'Menu',
687                                                         xns : Roo.menu,
688                                                         items : [
689                                                                 {
690                                                                 '|xns' : 'Roo.menu',
691                                                                 text : "Currency",
692                                                                 xtype : 'Item',
693                                                                 xns : Roo.menu,
694                                                                 listeners : {
695                                                                         click : function (_self, e)
696                                                                            {
697                                                                                
698                                                                                 new Pman.Download({
699                                                                                    url : baseURL+'/Xtuple/Kingdee/Currency',
700                                                                                    method : 'GET',
701                                                                                    timeout: 600000
702                                                                                });
703                                                                                Roo.MessageBox.alert("Notice", "Report will download shortly");
704                                                                            }
705                                                                 }
706                                                             },
707                                                                 {
708                                                                 '|xns' : 'Roo.menu',
709                                                                 text : "Exchange Rate",
710                                                                 xtype : 'Item',
711                                                                 xns : Roo.menu,
712                                                                 listeners : {
713                                                                         click : function (_self, e)
714                                                                            {
715                                                                                
716                                                                                 new Pman.Download({
717                                                                                    url : baseURL+'/Xtuple/Kingdee/Rate',
718                                                                                    method : 'GET',
719                                                                                    timeout: 600000
720                                                                                });
721                                                                                Roo.MessageBox.alert("Notice", "Report will download shortly");
722                                                                            }
723                                                                 }
724                                                             },
725                                                                 {
726                                                                 '|xns' : 'Roo.menu',
727                                                                 text : "Accounts",
728                                                                 xtype : 'Item',
729                                                                 xns : Roo.menu,
730                                                                 listeners : {
731                                                                         click : function (_self, e)
732                                                                            {
733                                                                                
734                                                                                 new Pman.Download({
735                                                                                    url : baseURL+'/Xtuple/Kingdee/Account',
736                                                                                    method : 'GET',
737                                                                                    timeout: 600000
738                                                                                });
739                                                                                Roo.MessageBox.alert("Notice", "Report will download shortly");
740                                                                            }
741                                                                 }
742                                                             },
743                                                                 {
744                                                                 '|xns' : 'Roo.menu',
745                                                                 text : "Voucher Category",
746                                                                 xtype : 'Item',
747                                                                 xns : Roo.menu,
748                                                                 listeners : {
749                                                                         click : function (_self, e)
750                                                                            {
751                                                                                new Pman.Download({
752                                                                                    url : baseURL+'/Xtuple/Kingdee/VoucherGroup',
753                                                                                    method : 'GET',
754                                                                                    timeout: 600000
755                                                                                });
756                                                                                Roo.MessageBox.alert("Notice", "Report will download shortly");
757                                                                            }
758                                                                 }
759                                                             },
760                                                                 {
761                                                                 '|xns' : 'Roo.menu',
762                                                                 text : "Transactions",
763                                                                 xtype : 'Item',
764                                                                 xns : Roo.menu,
765                                                                 listeners : {
766                                                                         click : function (_self, e)
767                                                                            {
768                                                                                var dt = _this.dateSel.getValue();
769                                                                                new Pman.Download({
770                                                                                    url : baseURL+'/Xtuple/Kingdee/Voucher',
771                                                                                    method : 'GET',
772                                                                                    timeout: 600000,
773                                                                                    params : {
774                                                                                        _as_of : (typeof(dt) == 'string') ? dt : dt.format('Y-m-d')
775                                                                                    }
776                                                                                });
777                                                                                Roo.MessageBox.alert("Notice", "Report will download shortly - If you wanna import again, please delete all the exist!");
778                                                                            }
779                                                                 }
780                                                             }
781                                                         ]
782
783                                                     },
784                                                     '|xns' : 'Roo.menu',
785                                                     text : "Kingdee",
786                                                     xtype : 'Item',
787                                                     xns : Roo.menu,
788                                                     items : [
789
790                                                     ]
791
792                                                 }
793                                             ]
794
795                                         },
796                                         '|xns' : 'Roo.Toolbar',
797                                         text : "Download / Upload",
798                                         xtype : 'Button',
799                                         xns : Roo.Toolbar,
800                                         items : [
801
802                                         ]
803
804                                     }
805                                 ]
806
807                             },
808                             dataSource : {
809                                 proxy : {
810                                     '|xns' : 'Roo.data',
811                                     url : baseURL + '/Roo/accnt.php',
812                                     xtype : 'HttpProxy',
813                                     method : 'GET',
814                                     xns : Roo.data,
815                                     listeners : {
816                                         loadexception : function (This, o, arg, e)
817                                            {
818                                            
819                                            }
820                                     }
821                                 },
822                                 reader : {
823                                     '|xns' : 'Roo.data',
824                                     id : 'accnt_id',
825                                     root : 'data',
826                                     xtype : 'JsonReader',
827                                     fields : [
828                                         {
829                                             'name': 'accnt_id',
830                                             'type': 'int'
831                                         },
832                                         {
833                                             'name': 'accnt_name',
834                                             'type': 'string'
835                                         },
836                                         {
837                                             'name': 'accnt_descrip',
838                                             'type': 'string'
839                                         },
840                                         {
841                                             'name': 'accnt_type',
842                                             'type': 'string'
843                                         },
844                                         {
845                                             'name': 'accnt_subaccnttype_code',
846                                             'type': 'string'
847                                         },
848                                         {
849                                             'name': 'accnt_curr_id_curr_name',
850                                             'type': 'string'
851                                         },
852                                         {
853                                             'name': 'accnt_curr_id_curr_id',
854                                             'type': 'int'
855                                         }
856                                     ],
857                                     xns : Roo.data,
858                                     totalProperty : 'total'
859                                 },
860                                 '|xns' : 'Roo.data',
861                                 xtype : 'Store',
862                                 remoteSort : true,
863                                 sortInfo : { field : 'accnt_name', direction: 'ASC' },
864                                 xns : Roo.data,
865                                 listeners : {
866                                         beforeload : function (_self, options)
867                                            {
868                                                options.params = options.params || {};
869                                                
870                                                options.params.limit = 9999;
871                                                
872                                                options.params._general_ledger = 1;
873                                                
874                                                options.params['search[name]'] = _this.searchBox.getValue();
875                                                
876                                                if (_this.active) {\r
877                                                    options.params.accnt_active = 1;
878                                                    options.params._with_balances = 1;\r
879                                                }
880                                                
881                                               
882                                                \r    var dt = _this.dateSel.getValue();\r
883                                                options.params._as_of = typeof(dt) == 'string' ? dt : dt.format('Y-m-d');
884                                                
885                                            
886                                            }
887                                 },
888                                 items : [
889
890                                 ]
891
892                             },
893                             '|xns' : 'Roo.grid',
894                             autoExpandColumn : 'accnt_descrip',
895                             xtype : 'Grid',
896                             loadMask : true,
897                             xns : Roo.grid,
898                             colModel : [
899                                  {
900                                         '|xns' : 'Roo.grid',
901                                         xtype : 'ColumnModel',
902                                         sortable : true,
903                                         header : 'Name',
904                                         width : 100,
905                                         renderer : function(v) { return String.format('{0}', v); },
906                                         xns : Roo.grid,
907                                         dataIndex : 'accnt_name'
908                                     },
909 {
910                                         '|xns' : 'Roo.grid',
911                                         hidden : true,
912                                         xtype : 'ColumnModel',
913                                         sortable : true,
914                                         header : 'Alternative Code',
915                                         width : 50,
916                                         renderer : function(v) { return String.format('{0}', v); },
917                                         xns : Roo.grid,
918                                         dataIndex : 'accnt_code_alt'
919                                     },
920 {
921                                         '|xns' : 'Roo.grid',
922                                         hidden : true,
923                                         xtype : 'ColumnModel',
924                                         sortable : true,
925                                         header : 'Alternative Description',
926                                         width : 50,
927                                         renderer : function(v) { return String.format('{0}', v); },
928                                         xns : Roo.grid,
929                                         dataIndex : 'accnt_descrip_alt'
930                                     },
931 {
932                                         '|xns' : 'Roo.grid',
933                                         xtype : 'ColumnModel',
934                                         sortable : true,
935                                         header : 'Type',
936                                         width : 50,
937                                         renderer : function(v,x,r) {
938                                              return String.format('{0}-{1}', v,r.data.accnt_subaccnttype_code); 
939                                          },
940                                         xns : Roo.grid,
941                                         dataIndex : 'accnt_type'
942                                     },
943 {
944                                         '|xns' : 'Roo.grid',
945                                         xtype : 'ColumnModel',
946                                         sortable : true,
947                                         header : 'Description',
948                                         width : 200,
949                                         renderer : function(v,x,r) 
950                                         { 
951                                             if(r.data.accnt_descrip_alt){
952                                                 return String.format('{0} ({1})', v, r.data.accnt_descrip_alt);     
953                                             }
954                                             
955                                             return String.format('{0}', v); 
956                                         },
957                                         xns : Roo.grid,
958                                         dataIndex : 'accnt_descrip'
959                                     },
960 {
961                                         '|xns' : 'Roo.grid',
962                                         align : 'right',
963                                         xtype : 'ColumnModel',
964                                         sortable : true,
965                                         header : 'Currency',
966                                         width : 50,
967                                         renderer : function(v) { 
968                                             var base = baseURL.match(/sg\.php$/) ? 'SGD' : 'HKD';
969                                             if (v != base) {
970                                                 return String.format('<span style="color:green">{0}</span>', v);     
971                                             }
972                                         
973                                             return String.format('{0}', v); 
974                                         },
975                                         xns : Roo.grid,
976                                         dataIndex : 'accnt_curr_id_curr_name'
977                                     },
978 {
979                                         '|xns' : 'Roo.grid',
980                                         xtype : 'ColumnModel',
981                                         sortable : true,
982                                         header : 'Balance',
983                                         width : 100,
984                                         renderer : function(v) { \r
985                                            return String.format('<span style="color:blue;text-decoration:underline;">{0}</span>',\r
986                                                     Roo.util.Format.usMoney(v) ); 
987                                         },
988                                         xns : Roo.grid,
989                                         dataIndex : 'balance'
990                                     }
991                             ],
992                             listeners : {
993                                 rowdblclick : function (_self, rowIndex, e)
994                                    {
995                                        var ret = _this.wgrid.ds.getAt(rowIndex).data;
996                                        if(ret.accnt_id * 1 < 1){
997                                            Roo.MessageBox.alert("Error", "Error occur on getting the account id!");
998                                            return;
999                                        }
1000                                        Pman.Dialog.XtupleGLAccountNameEdit.show( {accnt_id : ret.accnt_id}, function() {
1001                                            _this.wgrid.ds.load({});
1002                                        }); 
1003                                    },
1004                                 render : function() 
1005                                    {
1006                                        _this.wgrid = this; 
1007                                        _this.active = 1;
1008                                        //_this.dialog = Pman.Dialog.FILL_IN
1009                                        if (_this.wpanel.active) {
1010                                           this.ds.load({});
1011                                        }
1012                                    },
1013                                 rowclick : function (_self, rowIndex, e)
1014                                    {
1015                                        var s = _this.wgrid.ds.getAt(rowIndex);
1016                                        
1017                                        if(s.data.accnt_id * 1 < 1){
1018                                            return;
1019                                        }
1020                                        
1021                                        _this.grid.footer.onClick('first');
1022                                        
1023                                        
1024                                    }
1025                             },
1026                             items : [
1027
1028                             ]
1029
1030                         },
1031                         '|xns' : 'Roo',
1032                         fitToframe : true,
1033                         background : false,
1034                         region : 'west',
1035                         title : "Account",
1036                         xtype : 'GridPanel',
1037                         fitContainer : true,
1038                         xns : Roo,
1039                         tableName : 'accnt',
1040                         listeners : {
1041                                 activate : function() {
1042                                        _this.wpanel = this;
1043                                        if (_this.wgrid) {
1044                                            _this.wgrid.ds.load({});
1045                                        }
1046                                    }
1047                         },
1048                         items : [
1049
1050                         ]
1051
1052                     },
1053                         {
1054                         grid : {
1055                             toolbar : {
1056                                 '|xns' : 'Roo',
1057                                 xtype : 'Toolbar',
1058                                 xns : Roo,
1059                                 items : [
1060                                         {
1061                                         '|xns' : 'Roo.form',
1062                                         xtype : 'TextField',
1063                                         xns : Roo.form,
1064                                         listeners : {
1065                                                 specialkey : function (_self, e)
1066                                                    {
1067                                                      _this.grid.footer.onClick('first');
1068                                                    },
1069                                                 render : function (_self)
1070                                                    {
1071                                                        _this.gltransBox = _self;
1072                                                    }
1073                                         }
1074                                     },
1075                                         {
1076                                         store : {
1077                                             '|xns' : 'Roo.data',
1078                                             xtype : 'SimpleStore',
1079                                             data : [ 
1080                                                 [ 'ALL', "All Transactions"],
1081                                                 [ 'S/R' , "Sales Return"],
1082                                                 [ 'S/O', "Sales Orders"] ,
1083                                                 [ 'A/P', "Accounts Payable"] ,
1084                                                 [ 'A/R', "Accounts Recievable"] ,
1085                                                 [ 'I/M', "Inventory "] ,
1086                                                 [ 'G/L', "General Ledger "] 
1087                                                 
1088                                                 
1089                                             ],
1090                                             fields : [  'gltrans_source', 'gltrans_source_name'],
1091                                             xns : Roo.data
1092                                         },
1093                                         '|xns' : 'Roo.form',
1094                                         listWidth : 200,
1095                                         triggerAction : 'all',
1096                                         displayField : 'gltrans_source_name',
1097                                         hiddenName : 'gltrans_source',
1098                                         value : "ALL",
1099                                         valueField : 'gltrans_source',
1100                                         xtype : 'ComboBox',
1101                                         allowBlank : false,
1102                                         editable : false,
1103                                         width : 150,
1104                                         xns : Roo.form,
1105                                         mode : 'local',
1106                                         name : 'gltrans_source_name',
1107                                         tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{gltrans_source_name}</b> </div>',
1108                                         listeners : {
1109                                                 render : function (_self)
1110                                                    {
1111                                                      _this.sourceCombo = _self;
1112                                                    },
1113                                                 select : function (combo, record, index)
1114                                                    {
1115                                                        Roo.log('select');
1116                                                        _this.grid.footer.onClick('first');
1117                                                    }
1118                                         },
1119                                         items : [
1120
1121                                         ]
1122
1123                                     },
1124                                         {
1125                                         '|xns' : 'Roo.Toolbar',
1126                                         xtype : 'Button',
1127                                         cls : 'x-btn-icon',
1128                                         icon : rootURL + '/Pman/templates/images/search.gif',
1129                                         xns : Roo.Toolbar,
1130                                         listeners : {
1131                                                 click : function (_self, e)
1132                                                    {
1133                                                        _this.grid.footer.onClick('first');
1134                                                    }
1135                                         }
1136                                     },
1137                                         {
1138                                         '|xns' : 'Roo.Toolbar',
1139                                         xtype : 'Button',
1140                                         cls : 'x-btn-icon',
1141                                         icon : rootURL + '/Pman/templates/images/edit-clear.gif',
1142                                         xns : Roo.Toolbar,
1143                                         listeners : {
1144                                                 click : function (_self, e)
1145                                                    {
1146                                                        _this.gltransBox.setValue('');\r
1147                                                        _this.grid.footer.onClick('first');\r
1148                                                    }
1149                                         }
1150                                     },
1151                                         {
1152                                         '|xns' : 'Roo.Toolbar',
1153                                         xtype : 'Fill',
1154                                         xns : Roo.Toolbar
1155                                     },
1156                                         {
1157                                         menu : {
1158                                             '|xns' : 'Roo.menu',
1159                                             xtype : 'Menu',
1160                                             xns : Roo.menu,
1161                                             items : [
1162                                                 {
1163                                                     '|xns' : 'Roo.menu',
1164                                                     text : "Transactions from search result",
1165                                                     xtype : 'Item',
1166                                                     xns : Roo.menu,
1167                                                     listeners : {
1168                                                         click : function (_self, e)
1169                                                            {
1170                                                                
1171                                                                new Pman.Download({
1172                                                                    grid : _this.grid,
1173                                                                    csvCols : '*',
1174                                                                    csvTitles : '*',
1175                                                                    method : 'GET'
1176                                                                });
1177                                                                
1178                                                                Roo.MessageBox.alert("Notice", "Search Transactions Report for " + s.data.accnt_descrip + " will download shortly");
1179                                                            }
1180                                                     }
1181                                                 },
1182                                                 {
1183                                                     '|xns' : 'Roo.menu',
1184                                                     xtype : 'Separator',
1185                                                     xns : Roo.menu
1186                                                 },
1187                                                 {
1188                                                     '|xns' : 'Roo.menu',
1189                                                     text : "All Transactions",
1190                                                     xtype : 'Item',
1191                                                     xns : Roo.menu,
1192                                                     listeners : {
1193                                                         click : function (_self, e)
1194                                                            {
1195                                                                var s = _this.wgrid.getSelectionModel().getSelected();
1196                                                                
1197                                                                if(!s){
1198                                                                    Roo.MessageBox.alert("Error", "Please select a account"); 
1199                                                                    return false;
1200                                                                }
1201                                                                
1202                                                                var dt = _this.dateSel.getValue();
1203                                                                
1204                                                                if(!dt){
1205                                                                    Roo.MessageBox.alert("Error", "Please select a date on the right"); 
1206                                                                    return false;
1207                                                                }  
1208                                                                
1209                                                                var g = _this.gltransBox.getValue();
1210                                                                
1211                                                                var params = {
1212                                                                    '_group' : 'account',
1213                                                                    '_name' : 'summary',
1214                                                                    'limit' : 99999,
1215                                                                    'accnt_id:number' : s.data.accnt_id,
1216                                                                    'endDate:text' : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
1217                                                                    'csvTitles' : '*',
1218                                                                    'csvCols' : '*'
1219                                                                };
1220                                                                
1221                                                                if(g.length){
1222                                                                    params['search:text'] = g;
1223                                                                }
1224                                                                
1225                                                                new Pman.Download({
1226                                                                  url : baseURL + '/Roo/Metasql',
1227                                                                  params :   params,
1228                                                                  method : 'GET'
1229                                                                });
1230                                                                
1231                                                                Roo.MessageBox.alert("Notice", "All Transactions Report for " + s.data.accnt_descrip + " will download shortly");
1232                                                            }
1233                                                     }
1234                                                 },
1235                                                 {
1236                                                     '|xns' : 'Roo.menu',
1237                                                     text : "All Transactions (Selected Financial Year)",
1238                                                     xtype : 'Item',
1239                                                     xns : Roo.menu,
1240                                                     listeners : {
1241                                                         click : function (_self, e)
1242                                                            {
1243                                                                var s = _this.wgrid.getSelectionModel().getSelected();
1244                                                                
1245                                                                if(!s){
1246                                                                    Roo.MessageBox.alert("Error", "Please select a account"); 
1247                                                                    return false;
1248                                                                }
1249                                                                
1250                                                                var dt = _this.dateSel.getValue();
1251                                                                
1252                                                                if(!dt){
1253                                                                    Roo.MessageBox.alert("Error", "Please select a date on the right"); 
1254                                                                    return false;
1255                                                                }  
1256                                                                
1257                                                                new Pman.Download({
1258                                                                    url : baseURL + '/Roo/Gltrans.php',
1259                                                                    method :'GET',
1260                                                                    params : {
1261                                                                        gltrans_accnt_id : s.data.accnt_id,
1262                                                                        _as_of : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
1263                                                                        _download : 1
1264                                                                    }
1265                                                                });
1266                                                                
1267                                                                Roo.MessageBox.alert("Notice", "Financial Year Report for " + s.data.accnt_descrip + " will download shortly");
1268                                                            }
1269                                                     }
1270                                                 },
1271                                                 {
1272                                                     '|xns' : 'Roo.menu',
1273                                                     text : "All Transactions  / All Accounts (Selected Financial Year)",
1274                                                     xtype : 'Item',
1275                                                     xns : Roo.menu,
1276                                                     listeners : {
1277                                                         click : function (_self, e)
1278                                                            {   
1279                                                                var dt = _this.dateSel.getValue();
1280                                                                
1281                                                                if(!dt){
1282                                                                    Roo.MessageBox.alert("Error", "Please select a date on the right"); 
1283                                                                    return false;
1284                                                                }   
1285                                                                   
1286                                                                new Pman.Download({
1287                                                                    url : baseURL + '/Roo/Gltrans.php',
1288                                                                    method :'GET',
1289                                                                    timeout : 900000,
1290                                                                    params : {
1291                                                                        _as_of : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
1292                                                                        _download : 1
1293                                                                    }
1294                                                                });
1295                                                                
1296                                                                Roo.MessageBox.alert("Notice", "Financial Year Report for all accounts will download shortly! it might take several minutes");
1297                                                            }
1298                                                     }
1299                                                 }
1300                                             ]
1301
1302                                         },
1303                                         '|xns' : 'Roo.Toolbar',
1304                                         text : "Download",
1305                                         xtype : 'Button',
1306                                         cls : 'x-btn-text-icon',
1307                                         icon : rootURL + '/Pman/templates/images/spreadsheet.gif',
1308                                         xns : Roo.Toolbar,
1309                                         items : [
1310
1311                                         ]
1312
1313                                     }
1314                                 ]
1315
1316                             },
1317                             dataSource : {
1318                                 proxy : {
1319                                     '|xns' : 'Roo.data',
1320                                     url : baseURL + '/Roo/Metasql.php',
1321                                     method : 'GET',
1322                                     xtype : 'HttpProxy',
1323                                     timeout : 600000,
1324                                     xns : Roo.data
1325                                 },
1326                                 reader : {
1327                                     '|xns' : 'Roo.data',
1328                                     id : 'gltrans_id',
1329                                     root : 'data',
1330                                     xtype : 'JsonReader',
1331                                     fields : [
1332                                         {
1333                                             'name': 'gltrans_id',
1334                                             'type': 'int'
1335                                         },
1336                                         {
1337                                             'name': 'gltrans_accnt_id',
1338                                             'type': 'int'
1339                                         },
1340                                         {
1341                                             'name': 'gltrans_source',
1342                                             'type': 'string'
1343                                         },
1344                                         {
1345                                             'name': 'gltrans_amount',
1346                                             'type': 'int'
1347                                         },
1348                                         {
1349                                             'name': 'gltrans_notes',
1350                                             'type': 'string'
1351                                         }
1352                                     ],
1353                                     xns : Roo.data,
1354                                     totalProperty : 'total'
1355                                 },
1356                                 '|xns' : 'Roo.data',
1357                                 xtype : 'Store',
1358                                 remoteSort : true,
1359                                 xns : Roo.data,
1360                                 listeners : {
1361                                         beforeload : function (_self, options)
1362                                            {
1363                                                options.params = options.params || {};
1364                                                
1365                                                var s = _this.wgrid.getSelectionModel().getSelected();
1366                                                
1367                                                if(!s){
1368                                                    return;
1369                                                }
1370                                                
1371                                                var dt = _this.dateSel.getValue();
1372                                                var g = _this.gltransBox.getValue();
1373                                                
1374                                                var params = {
1375                                                    _group : 'account',
1376                                                    _name : 'summary',
1377                                                    'accnt_id:number' : s.data.accnt_id,
1378                                                    'endDate:text' : typeof(dt) == 'string' ? dt : dt.format('Y-m-d')
1379                                                };
1380                                                
1381                                                // can not do source + search..
1382                                                var source = _this.sourceCombo.getValue();
1383                                                if (source != 'ALL') {
1384                                                    params['search:text']  = source;
1385                                                }
1386                                                
1387                                                if(g.length){
1388                                                    params['search:text'] = g;
1389                                                }
1390                                                
1391                                                Roo.apply(options.params,params);
1392                                                
1393                                                var cm = _this.grid.getColumnModel();
1394                                                var hide = (g.length) ? true : false;
1395                                                
1396                                                cm.setHidden(cm.getIndexByDataIndex('gltrans_balance'), hide);
1397                                                
1398                                                
1399                                            }
1400                                 },
1401                                 items : [
1402
1403                                 ]
1404
1405                             },
1406                             footer : {
1407                                 '|xns' : 'Roo',
1408                                 pageSize : 100,
1409                                 xtype : 'PagingToolbar',
1410                                 xns : Roo,
1411                                 items : [
1412                                         {
1413                                         '|xns' : 'Roo.Toolbar',
1414                                         text : "Double Click To Edit",
1415                                         xtype : 'TextItem',
1416                                         xns : Roo.Toolbar
1417                                     }
1418                                 ]
1419
1420                             },
1421                             '|xns' : 'Roo.grid',
1422                             autoExpandColumn : 'gltrans_notes',
1423                             xtype : 'EditorGrid',
1424                             loadMask : true,
1425                             clicksToEdit : 2,
1426                             xns : Roo.grid,
1427                             colModel : [
1428                                  {
1429                                         '|xns' : 'Roo.grid',
1430                                         xtype : 'ColumnModel',
1431                                         sortable : true,
1432                                         header : 'Date',
1433                                         width : 100,
1434                                         renderer : function(v,x,r) { 
1435                                             return String.format('{0}<br/><i style="color:#ccc;">{1}</i>',
1436                                                  v ? v : '', r.data.gltrans_sequence
1437                                              ); 
1438                                         },
1439                                         xns : Roo.grid,
1440                                         dataIndex : 'gltrans_date'
1441                                     },
1442 {
1443                                         '|xns' : 'Roo.grid',
1444                                         hidden : true,
1445                                         xtype : 'ColumnModel',
1446                                         sortable : true,
1447                                         header : 'Date',
1448                                         width : 100,
1449                                         renderer : function(v,x,r) { 
1450                                             return String.format('{0}', v); 
1451                                         },
1452                                         xns : Roo.grid,
1453                                         dataIndex : 'gltrans_created'
1454                                     },
1455 {
1456                                         '|xns' : 'Roo.grid',
1457                                         xtype : 'ColumnModel',
1458                                         sortable : true,
1459                                         header : 'Source / Who',
1460                                         width : 100,
1461                                         renderer : function(v,x,r) { 
1462                                             return String.format('{0} - {1}<br/>{2} <i style="color:#ccc;">{3}</i>',
1463                                             
1464                                                      v,r.data.gltrans_doctype, 
1465                                                      r.data.gltrans_username,
1466                                                      r.data.gltrans_created);
1467                                          },
1468                                         xns : Roo.grid,
1469                                         dataIndex : 'gltrans_source'
1470                                     },
1471 {
1472                                         '|xns' : 'Roo.grid',
1473                                         hidden : true,
1474                                         xtype : 'ColumnModel',
1475                                         sortable : true,
1476                                         header : 'Doc Number',
1477                                         width : 100,
1478                                         xns : Roo.grid,
1479                                         dataIndex : 'gltrans_docnumber'
1480                                     },
1481 {
1482                                         editor : {
1483                                             field : {
1484                                                 '|xns' : 'Roo.form',
1485                                                 xtype : 'TextArea',
1486                                                 xns : Roo.form
1487                                             },
1488                                             '|xns' : 'Roo.grid',
1489                                             xtype : 'GridEditor',
1490                                             xns : Roo.grid,
1491                                             items : [
1492
1493                                             ]
1494
1495                                         },
1496                                         '|xns' : 'Roo.grid',
1497                                         xtype : 'ColumnModel',
1498                                         header : 'Account / Notes',
1499                                         width : 200,
1500                                         renderer : function(v,x,r) 
1501                                         { 
1502                                             return String.format(
1503                                                     '<u class="dragon-ref-accounts">{3}</u> - <span qtip="{2}"><b>{0}</b>' + "\n" + '{1}', 
1504                                                     r.data.gltrans_docnumber,
1505                                                      v, 
1506                                                     v.split('\n').join('<br/>'),
1507                                                     r.data.related_accounts
1508                                                     
1509                                                 ).split('\n').join('<br/>');
1510                                             
1511                                         },
1512                                         xns : Roo.grid,
1513                                         dataIndex : 'gltrans_notes',
1514                                         items : [
1515
1516                                         ]
1517
1518                                     },
1519 {
1520                                         '|xns' : 'Roo.grid',
1521                                         align : 'right',
1522                                         xtype : 'ColumnModel',
1523                                         sortable : true,
1524                                         header : 'Currency',
1525                                         width : 75,
1526                                         renderer : function(v) { 
1527                                             return String.format('{0}', v); 
1528                                         },
1529                                         xns : Roo.grid,
1530                                         dataIndex : 'gltrans_base_curr'
1531                                     },
1532 {
1533                                         '|xns' : 'Roo.grid',
1534                                         align : 'right',
1535                                         xtype : 'ColumnModel',
1536                                         sortable : true,
1537                                         header : 'Credit',
1538                                         width : 100,
1539                                         renderer : function(v,x,r) { 
1540                                             return String.format('{0}', v ? Roo.util.Format.number(v*1,2)  : ''  );
1541                                         },
1542                                         xns : Roo.grid,
1543                                         dataIndex : 'gltrans_credit_amount'
1544                                     },
1545 {
1546                                         '|xns' : 'Roo.grid',
1547                                         align : 'right',
1548                                         xtype : 'ColumnModel',
1549                                         sortable : true,
1550                                         header : 'Debit',
1551                                         width : 100,
1552                                         renderer : function(v,x,r) { 
1553                                             return String.format('{0}', v ? Roo.util.Format.number(v*1,2)  : ''  );
1554                                         },
1555                                         xns : Roo.grid,
1556                                         dataIndex : 'gltrans_debit_amount'
1557                                     },
1558 {
1559                                         '|xns' : 'Roo.grid',
1560                                         align : 'right',
1561                                         xtype : 'ColumnModel',
1562                                         sortable : true,
1563                                         header : 'Amount',
1564                                         width : 100,
1565                                         renderer : function(v) { 
1566                                             var c =v >= 0.0 ? 'black' :  'red';
1567                                         \r
1568                                            return String.format('<span style="color:' + c + ';">{0}</span>',\r
1569                                                     Roo.util.Format.number(v,2) ); 
1570                                         },
1571                                         xns : Roo.grid,
1572                                         dataIndex : 'gltrans_balance'
1573                                     }
1574                             ],
1575                             listeners : {
1576                                 render : function() 
1577                                    {
1578                                        _this.grid = this; 
1579                                        //_this.dialog = Pman.Dialog.FILL_IN
1580                                       /* if (_this.panel.active) {
1581                                           this.ds.load({});
1582                                        } */
1583                                    },
1584                                 celldblclick : function (_self, rowIndex, columnIndex, e)
1585                                    {
1586                                        var cm = this.colModel.config[columnIndex].dataIndex;
1587                                        var r = this.ds.getAt(rowIndex);
1588                                        if (cm != 'gltrans_date') {
1589                                            return;
1590                                        }
1591                                        new Pman.Download({
1592                                            url : baseURL+ '/Roo/Metasql',
1593                                            method : 'GET',
1594                                            params : {
1595                                                _group : 'gltrans',
1596                                                _name : 'sequence',
1597                                                'gltrans_sequence:number' : r.data.gltrans_sequence,
1598                                                limit : 9999
1599                                            }
1600                                        });
1601                                        
1602                                    },
1603                                 cellclick : function (_self, rowIndex, columnIndex, e)
1604                                    {
1605                                        if (!Roo.get(e.getTarget()).hasClass('dragon-ref-accounts')) {
1606                                            return;
1607                                        }
1608                                        var r = this.ds.getAt(rowIndex);
1609                                        Pman.Dialog.XtupleJournalEntry.show({
1610                                            gltrans_id : r.data.gltrans_id
1611                                        }, function()
1612                                        {
1613                                            // no need to refresh as it's viewed only?
1614                                        });
1615                                        
1616                                        
1617                                    },
1618                                 rowclass : function (gridview, rowcfg)
1619                                    {
1620                                      rowcfg.rowClass = 'dragon-gl-fixedheight';
1621                                    },
1622                                 afteredit : function (e)
1623                                    {   
1624                                        var r = _this.grid.ds.getAt(e.row);
1625                                        
1626                                        if(e.value == e.originalValue || !r){
1627                                            return;
1628                                        }
1629                                    
1630                                        new Pman.Request({
1631                                            url : baseURL + '/Roo/Gltrans.php',
1632                                            method :'POST',
1633                                            params : {
1634                                                gltrans_id : r.data.gltrans_id,
1635                                                gltrans_notes : e.value,
1636                                                _update_notes : 1
1637                                                
1638                                            },
1639                                            success : function() {
1640                                               
1641                                                _this.grid.footer.onClick('refresh');
1642                                                
1643                                            }
1644                                        });
1645                                        
1646                                    }
1647                             },
1648                             items : [
1649
1650                             ]
1651
1652                         },
1653                         '|xns' : 'Roo',
1654                         fitToframe : true,
1655                         background : false,
1656                         region : 'center',
1657                         title : "Transactions",
1658                         xtype : 'GridPanel',
1659                         fitContainer : true,
1660                         xns : Roo,
1661                         tableName : 'gltrans',
1662                         listeners : {
1663                                 activate : function() {
1664                                        _this.panel = this;
1665                                     /*   if (_this.grid) {
1666                                            _this.grid.ds.load({});
1667                                        } */
1668                                    }
1669                         },
1670                         items : [
1671
1672                         ]
1673
1674                     }
1675                 ]
1676
1677             },
1678             '|xns' : 'Roo',
1679             fitToFrame : true,
1680             background : true,
1681             region : 'center',
1682             title : "General Ledger",
1683             xtype : 'NestedLayoutPanel',
1684             fitContainer : true,
1685             xns : Roo,
1686             items : [
1687
1688             ]
1689
1690         };    }
1691 });