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