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