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