Pman.Dialog.XtupleJournalEntry.bjs
[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                                             inputValue : true,
151                                             name : 'Posted',
152                                             width : 100
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: 'TextField',
218                                     xns: Roo.form,
219                                     fieldLabel : 'Doc No.',
220                                     name : 'gltrans_docnumber',
221                                     width : 400
222                                 }
223                             ]
224                         }
225                     ]
226                 },
227                 {
228                     xtype: 'GridPanel',
229                     xns: Roo,
230                     listeners : {
231                         activate : function() {
232                             _this.panel = this;
233                             if (_this.grid) {
234                                 _this.grid.footer.onClick('first');
235                             }
236                         }
237                     },
238                     background : false,
239                     fitContainer : true,
240                     fitToframe : true,
241                     region : 'center',
242                     tableName : 'gltrans',
243                     title : "gltrans",
244                     grid : {
245                         xtype: 'Grid',
246                         xns: Roo.grid,
247                         listeners : {
248                             render : function() 
249                             {
250                                 _this.grid = this; 
251                                 //_this.dialog = Pman.Dialog.FILL_IN
252                                 if (_this.panel.active) {
253                                    this.footer.onClick('first');
254                                 }
255                             },
256                             rowdblclick : function (_self, rowIndex, e)
257                             {
258                                 if (!_this.dialog) return;
259                                 _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
260                                     _this.grid.footer.onClick('first');
261                                 }); 
262                             }
263                         },
264                         autoExpandColumn : 'gltrans_accnt_id',
265                         loadMask : true,
266                         dataSource : {
267                             xtype: 'Store',
268                             xns: Roo.data,
269                             listeners : {
270                                 beforeload : function (_self, options)
271                                 {
272                                     this.removeAll();
273                                     if (!_this.form.findField('gltrans_sequence').getValue()) {
274                                         return false;
275                                     }
276                                     options.params.gltrans_sequence = _this.form.findField('gltrans_sequence').getValue();
277                                 }
278                             },
279                             remoteSort : true,
280                             sortInfo : { field : 'gltrans_source', direction: 'ASC' },
281                             proxy : {
282                                 xtype: 'HttpProxy',
283                                 xns: Roo.data,
284                                 method : 'GET',
285                                 url : baseURL + '/Roo/gltrans.php'
286                             },
287                             reader : {
288                                 xtype: 'JsonReader',
289                                 xns: Roo.data,
290                                 totalProperty : 'total',
291                                 root : 'data',
292                                 id : 'id',
293                                 fields : [
294                                     {
295                                         'name': 'gltrans_id',
296                                         'type': 'int'
297                                     },
298                                     {
299                                         'name': 'gltrans_exported',
300                                         'type': 'int'
301                                     },
302                                     {
303                                         'name': 'gltrans_created',
304                                         'type': 'date',
305                                         'dateFormat': 'Y-m-d'
306                                     },
307                                     {
308                                         'name': 'gltrans_date',
309                                         'type': 'date',
310                                         'dateFormat': 'Y-m-d'
311                                     },
312                                     {
313                                         'name': 'gltrans_sequence',
314                                         'type': 'int'
315                                     },
316                                     {
317                                         'name': 'gltrans_accnt_id',
318                                         'type': 'int'
319                                     },
320                                     {
321                                         'name': 'gltrans_source',
322                                         'type': 'string'
323                                     },
324                                     {
325                                         'name': 'gltrans_docnumber',
326                                         'type': 'string'
327                                     },
328                                     {
329                                         'name': 'gltrans_misc_id',
330                                         'type': 'int'
331                                     },
332                                     {
333                                         'name': 'gltrans_amount',
334                                         'type': 'float'
335                                     },
336                                     {
337                                         'name': 'gltrans_notes',
338                                         'type': 'string'
339                                     },
340                                     {
341                                         'name': 'gltrans_journalnumber',
342                                         'type': 'int'
343                                     },
344                                     {
345                                         'name': 'gltrans_posted',
346                                         'type': 'int'
347                                     },
348                                     {
349                                         'name': 'gltrans_doctype',
350                                         'type': 'string'
351                                     },
352                                     {
353                                         'name': 'gltrans_rec',
354                                         'type': 'int'
355                                     },
356                                     {
357                                         'name': 'gltrans_username',
358                                         'type': 'string'
359                                     },
360                                     {
361                                         'name': 'gltrans_deleted',
362                                         'type': 'int'
363                                     }
364                                 ]
365                             }
366                         },
367                         footer : {
368                             xtype: 'PagingToolbar',
369                             xns: Roo,
370                             pageSize : 25,
371                             displayInfo : true,
372                             displayMsg : "Displaying gltrans{0} - {1} of {2}",
373                             emptyMsg : "No gltrans found"
374                         },
375                         toolbar : {
376                             xtype: 'Toolbar',
377                             xns: Roo,
378                             items : [
379                                 {
380                                     xtype: 'Button',
381                                     xns: Roo.Toolbar,
382                                     text : "Add",
383                                     cls : 'x-btn-text-icon',
384                                     icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
385                                     listeners : {
386                                         click : function()
387                                         {
388                                             if (!_this.dialog) return;
389                                             _this.dialog.show( { id : 0 } , function() {
390                                                 _this.grid.footer.onClick('first');
391                                            }); 
392                                         }
393                                     }
394                                 },
395                                 {
396                                     xtype: 'Fill',
397                                     xns: Roo.Toolbar
398                                 },
399                                 {
400                                     xtype: 'Button',
401                                     xns: Roo.Toolbar,
402                                     text : "Delete",
403                                     cls : 'x-btn-text-icon',
404                                     icon : rootURL + '/Pman/templates/images/trash.gif',
405                                     listeners : {
406                                         click : function()
407                                         {
408                                              Pman.genericDelete(_this, 'gltrans'); 
409                                         }
410                                     }
411                                 }
412                             ]
413                         },
414                         colModel : [
415                             {
416                                 xtype: 'ColumnModel',
417                                 xns: Roo.grid,
418                                 dataIndex : 'gltrans_id',
419                                 header : 'ID#',
420                                 width : 50,
421                                 renderer : function(v) { return String.format('{0}', v); }
422                             },
423                             {
424                                 xtype: 'ColumnModel',
425                                 xns: Roo.grid,
426                                 dataIndex : 'gltrans_accnt_id',
427                                 header : 'Account',
428                                 width : 75,
429                                 renderer : function(v,x,r) {
430                                 
431                                      return String.format('{0}', r.data.gltrans_accnt_id_accnt_descrip); 
432                                  }
433                             },
434                             {
435                                 xtype: 'ColumnModel',
436                                 xns: Roo.grid,
437                                 align : 'right',
438                                 dataIndex : 'gltrans_amount',
439                                 header : 'Gltrans amount',
440                                 width : 100,
441                                 renderer : function(v) { 
442                                 
443                                     var vv = Roo.util.Format.number(v,2);
444                                     if (v*1 < 0 ) {
445                                         return '<span color="red">' + vv + '</span>';
446                                     }
447                                     return vv; 
448                                 }
449                             }
450                         ]
451                     }
452                 }
453             ],
454             north : {
455                 xtype: 'LayoutRegion',
456                 xns: Roo,
457                 height : 150
458             },
459             center : {
460                 xtype: 'LayoutRegion',
461                 xns: Roo
462             },
463             buttons : [
464                 {
465                     xtype: 'Button',
466                     xns: Roo,
467                     listeners : {
468                         click : function (_self, e)
469                         {
470                             _this.dialog.hide();
471                         }
472                     },
473                     text : "Cancel"
474                 },
475                 {
476                     xtype: 'Button',
477                     xns: Roo,
478                     listeners : {
479                         click : function (_self, e)
480                         {
481                             // do some checks?
482                              
483                             if (_this.data.gltrans_id) {
484                                 return;
485                             }
486                         
487                             _this.form.doAction("submit");
488                         
489                         }
490                     },
491                     text : "Save"
492                 }
493             ]
494         });
495     }
496 };