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                                             width : 100
98                                         },
99                                         {
100                                             xtype: 'TextField',
101                                             xns: Roo.form,
102                                             fieldLabel : 'Journal No.',
103                                             name : 'gltrans_journalnumber',
104                                             width : 75
105                                         },
106                                         {
107                                             xtype: 'TextField',
108                                             xns: Roo.form,
109                                             fieldLabel : 'Created By',
110                                             name : 'gltrans_username',
111                                             width : 200
112                                         }
113                                     ]
114                                 },
115                                 {
116                                     xtype: 'Row',
117                                     xns: Roo.form,
118                                     labelAlign : 'right',
119                                     items : [
120                                         {
121                                             xtype: 'DateField',
122                                             xns: Roo.form,
123                                             fieldLabel : 'Date',
124                                             format : 'd/M/Y',
125                                             name : 'gltrans_date',
126                                             useIso : true,
127                                             width : 100
128                                         },
129                                         {
130                                             xtype: 'TextField',
131                                             xns: Roo.form,
132                                             fieldLabel : 'Entered',
133                                             name : 'gltrans_created',
134                                             width : 150
135                                         }
136                                     ]
137                                 },
138                                 {
139                                     xtype: 'Row',
140                                     xns: Roo.form,
141                                     items : [
142                                         {
143                                             xtype: 'Checkbox',
144                                             xns: Roo.form,
145                                             boxLabel : 'Posted',
146                                             fieldLabel : 'Status',
147                                             inputValue : 'true',
148                                             name : 'Posted',
149                                             width : 100
150                                         },
151                                         {
152                                             xtype: 'Row',
153                                             xns: Roo.form,
154                                             hideLabels : true,
155                                             items : [
156                                                 {
157                                                     xtype: 'Checkbox',
158                                                     xns: Roo.form,
159                                                     boxLabel : 'Recorded in Bank Reconcile',
160                                                     fieldLabel : '&nbsp;',
161                                                     inputValue : 'true',
162                                                     name : 'gltrans_rec',
163                                                     width : 200
164                                                 },
165                                                 {
166                                                     xtype: 'Checkbox',
167                                                     xns: Roo.form,
168                                                     boxLabel : 'Deleted',
169                                                     fieldLabel : 'Deleted',
170                                                     inputValue : 'true',
171                                                     name : 'gltrans_deleted',
172                                                     width : 75
173                                                 }
174                                             ]
175                                         }
176                                     ]
177                                 },
178                                 {
179                                     xtype: 'Row',
180                                     xns: Roo.form,
181                                     items : [
182                                         {
183                                             xtype: 'TextField',
184                                             xns: Roo.form,
185                                             fieldLabel : 'Source',
186                                             name : 'gltrans_source',
187                                             readOnly : true,
188                                             width : 100
189                                         },
190                                         {
191                                             xtype: 'TextField',
192                                             xns: Roo.form,
193                                             fieldLabel : 'Doc Type',
194                                             name : 'gltrans_doctype',
195                                             readOnly : true,
196                                             width : 100
197                                         },
198                                         {
199                                             xtype: 'TextField',
200                                             xns: Roo.form,
201                                             fieldLabel : 'References',
202                                             name : 'gltrans_misc_id',
203                                             readOnly : true,
204                                             width : 75
205                                         },
206                                         {
207                                             xtype: 'Button',
208                                             xns: Roo,
209                                             text : "Show"
210                                         }
211                                     ]
212                                 },
213                                 {
214                                     xtype: 'TextField',
215                                     xns: Roo.form,
216                                     fieldLabel : 'Doc No.',
217                                     name : 'gltrans_docnumber',
218                                     width : 400
219                                 }
220                             ]
221                         }
222                     ]
223                 },
224                 {
225                     xtype: 'GridPanel',
226                     xns: Roo,
227                     listeners : {
228                         activate : function() {
229                             _this.panel = this;
230                             if (_this.grid) {
231                                 _this.grid.footer.onClick('first');
232                             }
233                         }
234                     },
235                     background : false,
236                     fitContainer : true,
237                     fitToframe : true,
238                     region : 'center',
239                     tableName : 'gltrans',
240                     title : "gltrans",
241                     grid : {
242                         xtype: 'Grid',
243                         xns: Roo.grid,
244                         listeners : {
245                             render : function() 
246                             {
247                                 _this.grid = this; 
248                                 //_this.dialog = Pman.Dialog.FILL_IN
249                                 if (_this.panel.active) {
250                                    this.footer.onClick('first');
251                                 }
252                             },
253                             rowdblclick : function (_self, rowIndex, e)
254                             {
255                                 if (!_this.dialog) return;
256                                 _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
257                                     _this.grid.footer.onClick('first');
258                                 }); 
259                             }
260                         },
261                         autoExpandColumn : 'gltrans_accnt_id',
262                         loadMask : true,
263                         dataSource : {
264                             xtype: 'Store',
265                             xns: Roo.data,
266                             listeners : {
267                                 beforeload : function (_self, options)
268                                 {
269                                     this.removeAll();
270                                     if (!_this.form.findField('gltrans_sequence').getValue()) {
271                                         return false;
272                                     }
273                                     options.params.gltrans_sequence = _this.form.findField('gltrans_sequence').getValue();
274                                 }
275                             },
276                             remoteSort : true,
277                             sortInfo : { field : 'gltrans_source', direction: 'ASC' },
278                             proxy : {
279                                 xtype: 'HttpProxy',
280                                 xns: Roo.data,
281                                 method : 'GET',
282                                 url : baseURL + '/Roo/gltrans.php'
283                             },
284                             reader : {
285                                 xtype: 'JsonReader',
286                                 xns: Roo.data,
287                                 totalProperty : 'total',
288                                 root : 'data',
289                                 id : 'id',
290                                 fields : [
291                                     {
292                                         'name': 'gltrans_id',
293                                         'type': 'int'
294                                     },
295                                     {
296                                         'name': 'gltrans_exported',
297                                         'type': 'int'
298                                     },
299                                     {
300                                         'name': 'gltrans_created',
301                                         'type': 'date',
302                                         'dateFormat': 'Y-m-d'
303                                     },
304                                     {
305                                         'name': 'gltrans_date',
306                                         'type': 'date',
307                                         'dateFormat': 'Y-m-d'
308                                     },
309                                     {
310                                         'name': 'gltrans_sequence',
311                                         'type': 'int'
312                                     },
313                                     {
314                                         'name': 'gltrans_accnt_id',
315                                         'type': 'int'
316                                     },
317                                     {
318                                         'name': 'gltrans_source',
319                                         'type': 'string'
320                                     },
321                                     {
322                                         'name': 'gltrans_docnumber',
323                                         'type': 'string'
324                                     },
325                                     {
326                                         'name': 'gltrans_misc_id',
327                                         'type': 'int'
328                                     },
329                                     {
330                                         'name': 'gltrans_amount',
331                                         'type': 'float'
332                                     },
333                                     {
334                                         'name': 'gltrans_notes',
335                                         'type': 'string'
336                                     },
337                                     {
338                                         'name': 'gltrans_journalnumber',
339                                         'type': 'int'
340                                     },
341                                     {
342                                         'name': 'gltrans_posted',
343                                         'type': 'int'
344                                     },
345                                     {
346                                         'name': 'gltrans_doctype',
347                                         'type': 'string'
348                                     },
349                                     {
350                                         'name': 'gltrans_rec',
351                                         'type': 'int'
352                                     },
353                                     {
354                                         'name': 'gltrans_username',
355                                         'type': 'string'
356                                     },
357                                     {
358                                         'name': 'gltrans_deleted',
359                                         'type': 'int'
360                                     }
361                                 ]
362                             }
363                         },
364                         footer : {
365                             xtype: 'PagingToolbar',
366                             xns: Roo,
367                             pageSize : 25,
368                             displayInfo : true,
369                             displayMsg : "Displaying gltrans{0} - {1} of {2}",
370                             emptyMsg : "No gltrans found"
371                         },
372                         toolbar : {
373                             xtype: 'Toolbar',
374                             xns: Roo,
375                             items : [
376                                 {
377                                     xtype: 'Button',
378                                     xns: Roo.Toolbar,
379                                     text : "Add",
380                                     cls : 'x-btn-text-icon',
381                                     icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
382                                     listeners : {
383                                         click : function()
384                                         {
385                                             if (!_this.dialog) return;
386                                             _this.dialog.show( { id : 0 } , function() {
387                                                 _this.grid.footer.onClick('first');
388                                            }); 
389                                         }
390                                     }
391                                 },
392                                 {
393                                     xtype: 'Fill',
394                                     xns: Roo.Toolbar
395                                 },
396                                 {
397                                     xtype: 'Button',
398                                     xns: Roo.Toolbar,
399                                     text : "Delete",
400                                     cls : 'x-btn-text-icon',
401                                     icon : rootURL + '/Pman/templates/images/trash.gif',
402                                     listeners : {
403                                         click : function()
404                                         {
405                                              Pman.genericDelete(_this, 'gltrans'); 
406                                         }
407                                     }
408                                 }
409                             ]
410                         },
411                         colModel : [
412                             {
413                                 xtype: 'ColumnModel',
414                                 xns: Roo.grid,
415                                 dataIndex : 'gltrans_id',
416                                 header : 'ID#',
417                                 width : 50,
418                                 renderer : function(v) { return String.format('{0}', v); }
419                             },
420                             {
421                                 xtype: 'ColumnModel',
422                                 xns: Roo.grid,
423                                 dataIndex : 'gltrans_accnt_id',
424                                 header : 'Account',
425                                 width : 75,
426                                 renderer : function(v,x,r) {
427                                 
428                                      return String.format('{0}', r.data.gltrans_accnt_id_accnt_descrip); 
429                                  }
430                             },
431                             {
432                                 xtype: 'ColumnModel',
433                                 xns: Roo.grid,
434                                 align : 'right',
435                                 dataIndex : 'gltrans_amount',
436                                 header : 'Gltrans amount',
437                                 width : 100,
438                                 renderer : function(v) { 
439                                 
440                                     var vv = Roo.util.Format.number(v,2);
441                                     if (v*1 < 0 ) {
442                                         return '<span color="red">' + vv + '</span>';
443                                     }
444                                     return vv; 
445                                 }
446                             }
447                         ]
448                     }
449                 }
450             ],
451             north : {
452                 xtype: 'LayoutRegion',
453                 xns: Roo,
454                 height : 150
455             },
456             center : {
457                 xtype: 'LayoutRegion',
458                 xns: Roo
459             },
460             buttons : [
461                 {
462                     xtype: 'Button',
463                     xns: Roo,
464                     listeners : {
465                         click : function (_self, e)
466                         {
467                             _this.dialog.hide();
468                         }
469                     },
470                     text : "Cancel"
471                 },
472                 {
473                     xtype: 'Button',
474                     xns: Roo,
475                     listeners : {
476                         click : function (_self, e)
477                         {
478                             // do some checks?
479                              
480                             if (_this.data.gltrans_id) {
481                                 return;
482                             }
483                         
484                             _this.form.doAction("submit");
485                         
486                         }
487                     },
488                     text : "Save"
489                 }
490             ]
491         });
492     }
493 };