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