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