Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Dialog.XtupleJournalEntry.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Dialog.XtupleJournalEntry = {
6
7     dialog : false,
8     callback:  false,
9
10     show : function(data, cb)
11     {
12         if (!this.dialog) {
13             this.create();
14         }
15
16         this.callback = cb;
17         this.data = data;
18         this.dialog.show(this.data._el);
19         if (this.form) {
20            this.form.reset();
21            this.form.setValues(data);
22            this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
23         }
24
25     },
26
27     create : function()
28     {
29         var _this = this;
30         this.dialog = Roo.factory({
31             xtype: 'LayoutDialog',
32             xns: Roo,
33             closable : false,
34             collapsible : false,
35             height : 600,
36             modal : true,
37             resizable : false,
38             title : "Create / View  Transaction",
39             width : 800,
40             items : [
41                 {
42                     xtype: 'ContentPanel',
43                     xns: Roo,
44                     region : 'north',
45                     items : [
46                         {
47                             xtype: 'Form',
48                             xns: Roo.form,
49                             listeners : {
50                                 actioncomplete : function(_self,action)
51                                 {
52                                     if (action.type == 'setdata') {
53                                        //_this.dialog.el.mask("Loading");
54                                        if (_this.data.gltrans_id) {
55                                             this.load({ method: 'GET', params: { '_id' : _this.data.gltrans_id }});
56                                            return;
57                                        }
58                                        _this.grid.footer.onClick('first'); // clear..
59                                        return;
60                                     }
61                                     if (action.type == 'load') {
62                                          _this.grid.footer.onClick('first');
63                                         return;
64                                     }
65                                     if (action.type =='submit') {
66                                     
67                                         
68                                         _this.dialog.hide();
69                                     
70                                          if (_this.callback) {
71                                             _this.callback.call(_this, _this.form.getValues());
72                                          }
73                                          _this.form.reset();
74                                          return;
75                                     }
76                                 },
77                                 rendered : function (form)
78                                 {
79                                     _this.form= form;
80                                 }
81                             },
82                             labelAlign : 'right',
83                             method : 'POST',
84                             style : 'margin:10px;',
85                             url : baseURL + '/Roo/gltrans.php',
86                             items : [
87                                 {
88                                     xtype: 'Row',
89                                     xns: Roo.form,
90                                     labelAlign : 'right',
91                                     items : [
92                                         {
93                                             xtype: 'TextField',
94                                             xns: Roo.form,
95                                             fieldLabel : 'Sequence',
96                                             name : 'gltrans_sequence',
97                                             readOnly : true,
98                                             width : 100
99                                         },
100                                         {
101                                             xtype: 'TextField',
102                                             xns: Roo.form,
103                                             fieldLabel : 'Journal No.',
104                                             name : 'gltrans_journalnumber',
105                                             readOnly : true,
106                                             width : 75
107                                         },
108                                         {
109                                             xtype: 'TextField',
110                                             xns: Roo.form,
111                                             fieldLabel : 'Created By',
112                                             name : 'gltrans_username',
113                                             width : 200
114                                         }
115                                     ]
116                                 },
117                                 {
118                                     xtype: 'Row',
119                                     xns: Roo.form,
120                                     labelAlign : 'right',
121                                     items : [
122                                         {
123                                             xtype: 'DateField',
124                                             xns: Roo.form,
125                                             fieldLabel : 'Date',
126                                             format : 'd/M/Y',
127                                             name : 'gltrans_date',
128                                             useIso : true,
129                                             width : 100
130                                         },
131                                         {
132                                             xtype: 'TextField',
133                                             xns: Roo.form,
134                                             fieldLabel : 'Created',
135                                             name : 'gltrans_created',
136                                             readOnly : true,
137                                             width : 150
138                                         }
139                                     ]
140                                 },
141                                 {
142                                     xtype: 'Row',
143                                     xns: Roo.form,
144                                     items : [
145                                         {
146                                             xtype: 'Checkbox',
147                                             xns: Roo.form,
148                                             boxLabel : 'Posted',
149                                             fieldLabel : 'Status',
150                                             name : 'gltrans_posted',
151                                             width : 100,
152                                             inputValue : true
153                                         },
154                                         {
155                                             xtype: 'Row',
156                                             xns: Roo.form,
157                                             hideLabels : true,
158                                             items : [
159                                                 {
160                                                     xtype: 'Checkbox',
161                                                     xns: Roo.form,
162                                                     boxLabel : 'Recorded in Bank Reconcile',
163                                                     fieldLabel : '&nbsp;',
164                                                     inputValue : true,
165                                                     name : 'gltrans_rec',
166                                                     width : 200
167                                                 },
168                                                 {
169                                                     xtype: 'Checkbox',
170                                                     xns: Roo.form,
171                                                     boxLabel : 'Deleted',
172                                                     fieldLabel : 'Deleted',
173                                                     inputValue : true,
174                                                     name : 'gltrans_deleted',
175                                                     width : 75
176                                                 }
177                                             ]
178                                         }
179                                     ]
180                                 },
181                                 {
182                                     xtype: 'Row',
183                                     xns: Roo.form,
184                                     items : [
185                                         {
186                                             xtype: 'TextField',
187                                             xns: Roo.form,
188                                             fieldLabel : 'Source',
189                                             name : 'gltrans_source',
190                                             readOnly : true,
191                                             width : 100
192                                         },
193                                         {
194                                             xtype: 'TextField',
195                                             xns: Roo.form,
196                                             fieldLabel : 'Doc Type',
197                                             name : 'gltrans_doctype',
198                                             readOnly : true,
199                                             width : 100
200                                         },
201                                         {
202                                             xtype: 'TextField',
203                                             xns: Roo.form,
204                                             fieldLabel : 'References',
205                                             name : 'gltrans_misc_id',
206                                             readOnly : true,
207                                             width : 75
208                                         },
209                                         {
210                                             xtype: 'Button',
211                                             xns: Roo,
212                                             text : "Show"
213                                         }
214                                     ]
215                                 },
216                                 {
217                                     xtype: 'Row',
218                                     xns: Roo.form,
219                                     items : [
220                                         {
221                                             xtype: 'TextField',
222                                             xns: Roo.form,
223                                             fieldLabel : 'Doc No.',
224                                             name : 'gltrans_docnumber',
225                                             width : 100
226                                         },
227                                         {
228                                             xtype: 'TextField',
229                                             xns: Roo.form,
230                                             fieldLabel : 'Notes',
231                                             name : 'gltrans_notes',
232                                             width : 300
233                                         }
234                                     ]
235                                 }
236                             ]
237                         }
238                     ]
239                 },
240                 {
241                     xtype: 'GridPanel',
242                     xns: Roo,
243                     listeners : {
244                         activate : function() {
245                             _this.panel = this;
246                             if (_this.grid) {
247                                 _this.grid.footer.onClick('first');
248                             }
249                         }
250                     },
251                     background : false,
252                     fitContainer : true,
253                     fitToframe : true,
254                     region : 'center',
255                     tableName : 'gltrans',
256                     title : "gltrans",
257                     grid : {
258                         xtype: 'Grid',
259                         xns: Roo.grid,
260                         listeners : {
261                             render : function() 
262                             {
263                                 _this.grid = this; 
264                                 //_this.dialog = Pman.Dialog.FILL_IN
265                                 if (_this.panel.active) {
266                                    this.footer.onClick('first');
267                                 }
268                             },
269                             rowdblclick : function (_self, rowIndex, e)
270                             {
271                                 if (!_this.dialog) return;
272                                 _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
273                                     _this.grid.footer.onClick('first');
274                                 }); 
275                             }
276                         },
277                         autoExpandColumn : 'gltrans_accnt_id',
278                         loadMask : true,
279                         dataSource : {
280                             xtype: 'Store',
281                             xns: Roo.data,
282                             listeners : {
283                                 beforeload : function (_self, options)
284                                 {
285                                     this.removeAll();
286                                     if (!_this.form.findField('gltrans_sequence').getValue()) {
287                                         return false;
288                                     }
289                                     options.params.gltrans_sequence = _this.form.findField('gltrans_sequence').getValue();
290                                 }
291                             },
292                             remoteSort : true,
293                             sortInfo : { field : 'gltrans_source', direction: 'ASC' },
294                             proxy : {
295                                 xtype: 'HttpProxy',
296                                 xns: Roo.data,
297                                 method : 'GET',
298                                 url : baseURL + '/Roo/gltrans.php'
299                             },
300                             reader : {
301                                 xtype: 'JsonReader',
302                                 xns: Roo.data,
303                                 totalProperty : 'total',
304                                 root : 'data',
305                                 id : 'id',
306                                 fields : [
307                                     {
308                                         'name': 'gltrans_id',
309                                         'type': 'int'
310                                     },
311                                     {
312                                         'name': 'gltrans_exported',
313                                         'type': 'int'
314                                     },
315                                     {
316                                         'name': 'gltrans_created',
317                                         'type': 'date',
318                                         'dateFormat': 'Y-m-d'
319                                     },
320                                     {
321                                         'name': 'gltrans_date',
322                                         'type': 'date',
323                                         'dateFormat': 'Y-m-d'
324                                     },
325                                     {
326                                         'name': 'gltrans_sequence',
327                                         'type': 'int'
328                                     },
329                                     {
330                                         'name': 'gltrans_accnt_id',
331                                         'type': 'int'
332                                     },
333                                     {
334                                         'name': 'gltrans_source',
335                                         'type': 'string'
336                                     },
337                                     {
338                                         'name': 'gltrans_docnumber',
339                                         'type': 'string'
340                                     },
341                                     {
342                                         'name': 'gltrans_misc_id',
343                                         'type': 'int'
344                                     },
345                                     {
346                                         'name': 'gltrans_amount',
347                                         'type': 'float'
348                                     },
349                                     {
350                                         'name': 'gltrans_notes',
351                                         'type': 'string'
352                                     },
353                                     {
354                                         'name': 'gltrans_journalnumber',
355                                         'type': 'int'
356                                     },
357                                     {
358                                         'name': 'gltrans_posted',
359                                         'type': 'int'
360                                     },
361                                     {
362                                         'name': 'gltrans_doctype',
363                                         'type': 'string'
364                                     },
365                                     {
366                                         'name': 'gltrans_rec',
367                                         'type': 'int'
368                                     },
369                                     {
370                                         'name': 'gltrans_username',
371                                         'type': 'string'
372                                     },
373                                     {
374                                         'name': 'gltrans_deleted',
375                                         'type': 'int'
376                                     }
377                                 ]
378                             }
379                         },
380                         footer : {
381                             xtype: 'PagingToolbar',
382                             xns: Roo,
383                             pageSize : 25,
384                             displayInfo : true,
385                             displayMsg : "Displaying gltrans{0} - {1} of {2}",
386                             emptyMsg : "No gltrans found"
387                         },
388                         toolbar : {
389                             xtype: 'Toolbar',
390                             xns: Roo,
391                             items : [
392                                 {
393                                     xtype: 'Button',
394                                     xns: Roo.Toolbar,
395                                     text : "Add",
396                                     cls : 'x-btn-text-icon',
397                                     icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
398                                     listeners : {
399                                         click : function()
400                                         {
401                                             if (!_this.dialog) return;
402                                             _this.dialog.show( { id : 0 } , function() {
403                                                 _this.grid.footer.onClick('first');
404                                            }); 
405                                         }
406                                     }
407                                 },
408                                 {
409                                     xtype: 'Fill',
410                                     xns: Roo.Toolbar
411                                 },
412                                 {
413                                     xtype: 'Button',
414                                     xns: Roo.Toolbar,
415                                     text : "Delete",
416                                     cls : 'x-btn-text-icon',
417                                     icon : rootURL + '/Pman/templates/images/trash.gif',
418                                     listeners : {
419                                         click : function()
420                                         {
421                                              Pman.genericDelete(_this, 'gltrans'); 
422                                         }
423                                     }
424                                 }
425                             ]
426                         },
427                         colModel : [
428                             {
429                                 xtype: 'ColumnModel',
430                                 xns: Roo.grid,
431                                 dataIndex : 'gltrans_id',
432                                 header : 'ID#',
433                                 width : 50,
434                                 renderer : function(v) { return String.format('{0}', v); }
435                             },
436                             {
437                                 xtype: 'ColumnModel',
438                                 xns: Roo.grid,
439                                 dataIndex : 'gltrans_accnt_id',
440                                 header : 'Account',
441                                 width : 75,
442                                 renderer : function(v,x,r) {
443                                 
444                                      return String.format('{0}', r.data.gltrans_accnt_id_accnt_descrip); 
445                                  }
446                             },
447                             {
448                                 xtype: 'ColumnModel',
449                                 xns: Roo.grid,
450                                 align : 'right',
451                                 dataIndex : 'gltrans_amount',
452                                 header : 'Gltrans amount',
453                                 width : 100,
454                                 renderer : function(v) { 
455                                 
456                                     var vv = Roo.util.Format.number(v,2);
457                                     if (v*1 < 0 ) {
458                                         return '<span style="color:red">' + vv + '</span>';
459                                     }
460                                     return vv; 
461                                 }
462                             }
463                         ]
464                     }
465                 }
466             ],
467             north : {
468                 xtype: 'LayoutRegion',
469                 xns: Roo,
470                 height : 150
471             },
472             center : {
473                 xtype: 'LayoutRegion',
474                 xns: Roo
475             },
476             buttons : [
477                 {
478                     xtype: 'Button',
479                     xns: Roo,
480                     listeners : {
481                         click : function (_self, e)
482                         {
483                             _this.dialog.hide();
484                         }
485                     },
486                     text : "Cancel"
487                 },
488                 {
489                     xtype: 'Button',
490                     xns: Roo,
491                     listeners : {
492                         click : function (_self, e)
493                         {
494                             // do some checks?
495                              
496                             if (_this.data.gltrans_id) {
497                                 return;
498                             }
499                         
500                             _this.form.doAction("submit");
501                         
502                         }
503                     },
504                     text : "Save"
505                 }
506             ]
507         });
508     }
509 };