Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Dialog.XtupleInvHistoryOld.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.XtupleInvHistoryOld = {
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 : 500,
36             modal : true,
37             resizable : false,
38             title : "View inventory history - Hong Kong",
39             width : 1000,
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                                        _this.grid.footer.onClick('first');
56                                        return;
57                                     }
58                                     if (action.type == 'load') {
59                                         _this.dialog.el.unmask();
60                                         return;
61                                     }
62                                     if (action.type =='submit') {
63                                     
64                                         _this.dialog.el.unmask();
65                                         _this.dialog.hide();
66                                     
67                                          if (_this.callback) {
68                                             _this.callback.call(_this, _this.form.getValues());
69                                          }
70                                          _this.form.reset();
71                                          return;
72                                     }
73                                 },
74                                 rendered : function (form)
75                                 {
76                                     _this.form= form;
77                                 }
78                             },
79                             method : 'POST',
80                             style : 'margin:10px;',
81                             url : baseURL + '/Roo/invhist.php',
82                             items : [
83                                 {
84                                     xtype: 'Row',
85                                     xns: Roo.form,
86                                     width : 1000,
87                                     items : [
88                                         {
89                                             xtype: 'ComboBox',
90                                             xns: Roo.form,
91                                             listeners : {
92                                                 select : function (combo, record, index)
93                                                 {
94                                                   
95                                                  
96                                                    (function() { 
97                                                      if (_this.grid) {
98                                                         _this.grid.footer.onClick('first'); 
99                                                     }
100                                                      }).defer(100);
101                                                 }
102                                             },
103                                             allowBlank : true,
104                                             displayField : 'itemsite_item_id_item_number',
105                                             editable : true,
106                                             emptyText : "Select itemsite",
107                                             fieldLabel : 'Item',
108                                             forceSelection : true,
109                                             listWidth : 400,
110                                             loadingText : "Searching...",
111                                             minChars : 2,
112                                             name : 'itemsite_item_id_item_number',
113                                             pageSize : 20,
114                                             qtip : "Select itemsite",
115                                             queryParam : 'query[number]',
116                                             selectOnFocus : true,
117                                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{itemsite_item_id_item_number}</b> {itemsite_item_id_item_descrip1}</div>',
118                                             triggerAction : 'all',
119                                             typeAhead : true,
120                                             valueField : 'itemsite_item_id_item_number',
121                                             width : 200,
122                                             store : {
123                                                 xtype: 'Store',
124                                                 xns: Roo.data,
125                                                 listeners : {
126                                                     beforeload : function (_self, o){
127                                                         o.params = o.params || {};
128                                                         // set more here
129                                                     }
130                                                 },
131                                                 remoteSort : true,
132                                                 sortInfo : { direction : 'ASC', field: 'id' },
133                                                 proxy : {
134                                                     xtype: 'HttpProxy',
135                                                     xns: Roo.data,
136                                                     method : 'GET',
137                                                     url : baseURL + '/Xtuple/Roo/itemsite.php'
138                                                 },
139                                                 reader : {
140                                                     xtype: 'JsonReader',
141                                                     xns: Roo.data,
142                                                     id : 'id',
143                                                     root : 'data',
144                                                     totalProperty : 'total',
145                                                     fields : [{"name":"id","type":"int"},{"name":"itemsite_abcclass","type":"string"}]
146                                                 }
147                                             }
148                                         },
149                                         {
150                                             xtype: 'ComboBox',
151                                             xns: Roo.form,
152                                             listeners : {
153                                                 select : function (combo, record, index)
154                                                 {
155                                                   
156                                                  
157                                                    (function() { 
158                                                      if (_this.grid) {
159                                                         _this.grid.footer.onClick('first'); 
160                                                     }
161                                                      }).defer(100);
162                                                 }
163                                             },
164                                             allowBlank : true,
165                                             displayField : 'location_descrip',
166                                             editable : true,
167                                             emptyText : "Select location",
168                                             fieldLabel : 'location',
169                                             forceSelection : true,
170                                             hiddenName : 'location_name',
171                                             listWidth : 400,
172                                             loadingText : "Searching...",
173                                             minChars : 2,
174                                             name : 'location_descrip',
175                                             pageSize : 40,
176                                             qtip : "Select location",
177                                             queryParam : 'query[location_name]',
178                                             selectOnFocus : true,
179                                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{location_descrip}</b> </div>',
180                                             triggerAction : 'all',
181                                             typeAhead : true,
182                                             valueField : 'location_name',
183                                             width : 200,
184                                             store : {
185                                                 xtype: 'Store',
186                                                 xns: Roo.data,
187                                                 listeners : {
188                                                     beforeload : function (_self, o){
189                                                         o.params = o.params || {};
190                                                         // set more here
191                                                     }
192                                                 },
193                                                 remoteSort : true,
194                                                 sortInfo : { direction : 'ASC', field: 'location_name' },
195                                                 proxy : {
196                                                     xtype: 'HttpProxy',
197                                                     xns: Roo.data,
198                                                     method : 'GET',
199                                                     url : baseURL + '/Xtuple/Roo/location.php'
200                                                 },
201                                                 reader : {
202                                                     xtype: 'JsonReader',
203                                                     xns: Roo.data,
204                                                     id : 'id',
205                                                     root : 'data',
206                                                     totalProperty : 'total',
207                                                     fields : [{"name":"id","type":"int"},{"name":"location_name","type":"string"}]
208                                                 }
209                                             }
210                                         }
211                                     ]
212                                 }
213                             ]
214                         }
215                     ]
216                 },
217                 {
218                     xtype: 'GridPanel',
219                     xns: Roo,
220                     listeners : {
221                         activate : function() {
222                             _this.panel = this;
223                             if (_this.grid) {
224                                 _this.grid.footer.onClick('first');
225                             }
226                         }
227                     },
228                     background : false,
229                     fitContainer : true,
230                     fitToframe : true,
231                     region : 'center',
232                     tableName : 'invhist',
233                     title : "invhist",
234                     grid : {
235                         xtype: 'Grid',
236                         xns: Roo.grid,
237                         listeners : {
238                             render : function() 
239                             {
240                                 _this.grid = this; 
241                                 //_this.dialog = Pman.Dialog.FILL_IN
242                                 if (_this.panel.active) {
243                                    this.footer.onClick('first');
244                                 }
245                             },
246                             rowdblclick : function (_self, rowIndex, e)
247                             {
248                                 if (!_this.dialog) return;
249                                 _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {
250                                     _this.grid.footer.onClick('first');
251                                 }); 
252                             }
253                         },
254                         autoExpandColumn : 'invhist_comments',
255                         loadMask : true,
256                         dataSource : {
257                             xtype: 'Store',
258                             xns: Roo.data,
259                             listeners : {
260                                 beforeload : function (_self, o)
261                                 {
262                                     if (!_this.form.findField('itemsite_item_id_item_number').getValue().length 
263                                              && !_this.form.findField('location_name').getValue().length) {
264                                         _this.grid.ds.removeAll();
265                                         return false;
266                                     }
267                                     o.params['query[item_number]'] = _this.form.findField('itemsite_item_id_item_number').getValue();
268                                     o.params['query[location_name]']   = _this.form.findField('location_name').getValue();
269                                     o.params._with_item =1;
270                                         o.params._hide_void =1;
271                                 }
272                             },
273                             remoteSort : true,
274                             sortInfo : { field : 'invhist_transdate,invdetail_id', direction: 'DESC' },
275                             proxy : {
276                                 xtype: 'HttpProxy',
277                                 xns: Roo.data,
278                                 method : 'GET',
279                                 url : baseURL + '/Xtuple/Roo/invdetail.php'
280                             },
281                             reader : {
282                                 xtype: 'JsonReader',
283                                 xns: Roo.data,
284                                 totalProperty : 'total',
285                                 root : 'data',
286                                 id : 'id',
287                                 fields : [
288                                     {
289                                         'name': 'invhist_id',
290                                         'type': 'int'
291                                     },
292                                     {
293                                         'name': 'invhist_itemsite_id',
294                                         'type': 'int'
295                                     },
296                                     {
297                                         'name': 'invhist_transdate',
298                                         'type': 'date',
299                                         'dateFormat': 'Y-m-d'
300                                     },
301                                     {
302                                         'name': 'invhist_transtype',
303                                         'type': 'string'
304                                     },
305                                     {
306                                         'name': 'invhist_invqty',
307                                         'type': 'float'
308                                     },
309                                     {
310                                         'name': 'invhist_invuom',
311                                         'type': 'string'
312                                     },
313                                     {
314                                         'name': 'invhist_ordnumber',
315                                         'type': 'string'
316                                     },
317                                     {
318                                         'name': 'invhist_docnumber',
319                                         'type': 'string'
320                                     },
321                                     {
322                                         'name': 'invhist_qoh_before',
323                                         'type': 'float'
324                                     },
325                                     {
326                                         'name': 'invhist_qoh_after',
327                                         'type': 'float'
328                                     },
329                                     {
330                                         'name': 'invhist_unitcost',
331                                         'type': 'float'
332                                     },
333                                     {
334                                         'name': 'invhist_acct_id',
335                                         'type': 'int'
336                                     },
337                                     {
338                                         'name': 'invhist_xfer_warehous_id',
339                                         'type': 'int'
340                                     },
341                                     {
342                                         'name': 'invhist_comments',
343                                         'type': 'string'
344                                     },
345                                     {
346                                         'name': 'invhist_posted',
347                                         'type': 'int'
348                                     },
349                                     {
350                                         'name': 'invhist_imported',
351                                         'type': 'int'
352                                     },
353                                     {
354                                         'name': 'invhist_hasdetail',
355                                         'type': 'int'
356                                     },
357                                     {
358                                         'name': 'invhist_ordtype',
359                                         'type': 'string'
360                                     },
361                                     {
362                                         'name': 'invhist_analyze',
363                                         'type': 'int'
364                                     },
365                                     {
366                                         'name': 'invhist_user',
367                                         'type': 'string'
368                                     },
369                                     {
370                                         'name': 'invhist_created',
371                                         'type': 'date',
372                                         'dateFormat': 'Y-m-d'
373                                     },
374                                     {
375                                         'name': 'invhist_costmethod',
376                                         'type': 'string'
377                                     },
378                                     {
379                                         'name': 'invhist_value_before',
380                                         'type': 'float'
381                                     },
382                                     {
383                                         'name': 'invhist_value_after',
384                                         'type': 'float'
385                                     },
386                                     {
387                                         'name': 'invhist_series',
388                                         'type': 'int'
389                                     }
390                                 ]
391                             }
392                         },
393                         footer : {
394                             xtype: 'PagingToolbar',
395                             xns: Roo,
396                             pageSize : 25,
397                             displayInfo : true,
398                             displayMsg : "Displaying invhist{0} - {1} of {2}",
399                             emptyMsg : "No invhist found"
400                         },
401                         colModel : [
402                             {
403                                 xtype: 'ColumnModel',
404                                 xns: Roo.grid,
405                                 dataIndex : 'invhist_transdate',
406                                 header : 'Invhist transdate',
407                                 width : 75,
408                                 renderer : function(v) { 
409                                     var vv = Date.parseDate(v.split(' ')[0],'Y-m-d' );
410                                     return String.format('{0}', vv ? vv.format('d/M/Y') : '');
411                                  }
412                             },
413                             {
414                                 xtype: 'ColumnModel',
415                                 xns: Roo.grid,
416                                 dataIndex : 'invhist_ordnumber',
417                                 header : 'Order#',
418                                 width : 100,
419                                 renderer : function(v) { return String.format('{0}', v); }
420                             },
421                             {
422                                 xtype: 'ColumnModel',
423                                 xns: Roo.grid,
424                                 dataIndex : 'invhist_docnumber',
425                                 header : 'doc#',
426                                 width : 100,
427                                 renderer : function(v) { return String.format('{0}', v); }
428                             },
429                             {
430                                 xtype: 'ColumnModel',
431                                 xns: Roo.grid,
432                                 dataIndex : 'invhist_transtype',
433                                 header : 'Type',
434                                 width : 50,
435                                 renderer : function(v,x,r) { return String.format('{0}/{1}', v,r.data.invhist_ordtype); }
436                             },
437                             {
438                                 xtype: 'ColumnModel',
439                                 xns: Roo.grid,
440                                 align : 'right',
441                                 dataIndex : 'invhist_unitcost',
442                                 header : 'unitcost',
443                                 width : 50,
444                                 renderer : function(v) { return String.format('{0}', v); }
445                             },
446                             {
447                                 xtype: 'ColumnModel',
448                                 xns: Roo.grid,
449                                 align : 'right',
450                                 dataIndex : 'invfifo_unitcost',
451                                 header : 'fifocost',
452                                 width : 50,
453                                 renderer : function(v) { return String.format('{0}', v); }
454                             },
455                             {
456                                 xtype: 'ColumnModel',
457                                 xns: Roo.grid,
458                                 dataIndex : 'location_name',
459                                 header : 'Location',
460                                 width : 100,
461                                 renderer : function(v) { return String.format('<B>{0}</B>', v); }
462                             },
463                             {
464                                 xtype: 'ColumnModel',
465                                 xns: Roo.grid,
466                                 align : 'right',
467                                 dataIndex : 'invdetail_qty',
468                                 header : 'Change',
469                                 width : 50,
470                                 renderer : function(v) { return String.format('{0}', parseInt( v)); }
471                             },
472                             {
473                                 xtype: 'ColumnModel',
474                                 xns: Roo.grid,
475                                 align : 'right',
476                                 dataIndex : 'invdetail_bydate_qty',
477                                 header : 'Qty Before',
478                                 width : 75,
479                                 renderer : function(v,x,r) { return String.format('<B>{0}</B>', parseInt(v)- parseInt(r.data.invdetail_qty)); }
480                             },
481                             {
482                                 xtype: 'ColumnModel',
483                                 xns: Roo.grid,
484                                 align : 'right',
485                                 dataIndex : 'invdetail_bydate_qty',
486                                 header : 'Qty after',
487                                 width : 75,
488                                 renderer : function(v) { return String.format('<B>{0}</B>', parseInt( v)); }
489                             },
490                             {
491                                 xtype: 'ColumnModel',
492                                 xns: Roo.grid,
493                                 header : 'Invhist comments',
494                                 width : 200,
495                                 dataIndex : 'invhist_comments',
496                                 renderer : function(v) { return String.format('{0}', v); }
497                             }
498                         ]
499                     }
500                 }
501             ],
502             north : {
503                 xtype: 'LayoutRegion',
504                 xns: Roo,
505                 height : 50
506             },
507             center : {
508                 xtype: 'LayoutRegion',
509                 xns: Roo
510             },
511             buttons : [
512                 {
513                     xtype: 'Button',
514                     xns: Roo,
515                     listeners : {
516                         click : function (_self, e)
517                         {
518                             new Pman.Download({
519                                 grid : _this.grid
520                             });
521                         }
522                     },
523                     text : "Download"
524                 },
525                 {
526                     xtype: 'Button',
527                     xns: Roo,
528                     listeners : {
529                         click : function (_self, e)
530                         {
531                             _this.dialog.hide();
532                         }
533                     },
534                     text : "Close"
535                 }
536             ]
537         });
538     }
539 };