1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Pman.Tab.XtupleStockHistory = new Roo.XComponent({
6 part : ["Xtuple","StockHistory"],
7 order : '005-Pman.Tab.XtupleStockHistory',
9 parent : 'Pman.Tab.XtupleManage',
10 name : "Pman.Tab.XtupleStockHistory",
21 activate : function() {
24 _this.grid.footer.onClick('first');
32 tableName : 'invhist',
33 title : "Inventory History",
41 //_this.dialog = Pman.Dialog.FILL_IN
42 if (_this.panel.active) {
43 this.footer.onClick('first');
46 celldblclick : function (_self, rowIndex, colIndex, e)
48 var col = _this.grid.colModel.config[colIndex].dataIndex;
50 if (col !='item_number') {
53 var r = _this.grid.ds.getAt(rowIndex).data;
55 _this.itemsiteCombo.setValue(r.item_number);
56 _this.grid.footer.onClick('first');
61 autoExpandColumn : 'invhist_comments',
71 select : function (combo, record, index)
77 _this.grid.footer.onClick('first');
81 render : function (_self)
83 _this.itemsiteCombo = _self;
87 displayField : 'itemsite_item_id_item_number',
89 emptyText : "Select itemsite",
91 forceSelection : true,
93 loadingText : "Searching...",
95 name : 'itemsite_item_id_item_number',
97 qtip : "Select itemsite",
98 queryParam : 'query[number]',
100 tpl : '<div class="x-grid-cell-text x-btn button"><b>{itemsite_item_id_item_number}</b> {itemsite_item_id_item_descrip1}</div>',
101 triggerAction : 'all',
103 valueField : 'itemsite_item_id_item_number',
109 beforeload : function (_self, o){
110 o.params = o.params || {};
111 var l = _this.locationCombo.getValue();
113 o.params._has_invdetail_location_id = l;
119 sortInfo : { direction : 'ASC', field: 'id' },
124 url : baseURL + '/Roo/itemsite.php'
131 totalProperty : 'total',
132 fields : [{"name":"id","type":"int"},{"name":"itemsite_abcclass","type":"string"}]
140 select : function (combo, record, index)
146 _this.grid.footer.onClick('first');
150 render : function (_self)
152 _this.locationCombo = _self;
156 displayField : 'location_descrip',
158 emptyText : "Select location",
159 fieldLabel : 'location',
160 forceSelection : true,
161 hiddenName : 'location_id',
163 loadingText : "Searching...",
165 name : 'location_descrip',
167 qtip : "Select location",
168 queryParam : 'query[location_name]',
169 selectOnFocus : true,
170 tpl : '<div class="x-grid-cell-text x-btn button"><b>{location_descrip}</b> </div>',
171 triggerAction : 'all',
173 valueField : 'location_id',
179 beforeload : function (_self, o){
180 o.params = o.params || {};
181 o.params._has_invdetail = 1;
183 var item_num = _this.itemsiteCombo.getValue();
184 if (item_num.length) {
185 o.params._has_invdetail_item = item_num;
191 sortInfo : { direction : 'ASC', field: 'location_name' },
196 url : baseURL + '/Roo/location.php'
203 totalProperty : 'total',
204 fields : [{"name":"id","type":"int"},{"name":"location_name","type":"string"}]
212 render : function (_self)
214 _this.viewtype = _self;
216 select : function (combo, record, index)
219 _this.grid.footer.onClick('first');
223 displayField : 'fname',
225 hiddenName : 'status',
228 name : 'status_name',
229 triggerAction : 'all',
231 valueField : 'ftype',
234 xtype: 'SimpleStore',
237 [ 'BOTH', "All Transactions"],
238 [ 'IN' , "Incomming"],
239 [ 'OUT', "Outgoing"] ,
240 [ 'BOTHALL', "All Transactions (with voided)"]
243 fields : [ 'ftype', 'fname']
259 render : function (_self)
261 _this.dateSel = _self;
263 select : function (combo, date)
265 _this.grid.footer.onClick('first');
287 render : function (_self)
289 _this.endDateSel = _self;
291 select : function (combo, date)
293 _this.grid.footer.onClick('first');
309 text : "Download Reports",
310 icon : rootURL + '/Pman/templates/images/spreadsheet.gif',
319 click : function (_self, e)
321 if (!_this.itemsiteCombo.getValue().length &&
322 !_this.locationCombo.getValue() &&
323 !_this.dateSel.getValue() &&
324 !_this.endDateSel.getValue()) {
325 _this.grid.ds.removeAll();
326 Roo.MessageBox.alert("Error", "Nothing to download!");
331 //params : {_asExcel : 1, limit : 99999},
336 Roo.MessageBox.alert("Notice", "Report will download shortly");
345 click : function (_self, e)
348 var dt = _this.dateSel.getValue();
349 var end_dt = _this.endDateSel.getValue();
353 Roo.Msg.alert('Error', 'Please select a FROM date to download');
357 Roo.Msg.alert('Error', 'Please select a TO date to download');
365 'to_dt:text' : end_dt,
372 if ( _this.locationCombo.getValue() * 1) {
373 params['invdetail_location_id:number'] = _this.locationCombo.getValue() ;
378 url : baseURL + '/Roo/Metasql',
383 Roo.MessageBox.alert("Notice", "Report will download shortly");
386 text : "Summary of Orders/Transfers"
396 click : function (_self, e)
400 url : baseURL + '/Roo/Metasql',
403 _group : 'inventory',
412 Roo.MessageBox.alert("Notice", "Report will download shortly");
415 text : "Day by Day - GL to stock comparison"
421 click : function (_self, e)
423 var dt = _this.dateSel.getValue();
426 Roo.Msg.alert('Error', 'Please select a FROM date to download');
431 url : baseURL + '/Roo/Metasql',
434 _group : 'inventory',
436 '_as_of:text' : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
444 Roo.MessageBox.alert("Notice", "Report will download shortly");
447 text : "Inventory Transactions on From date"
453 click : function (_self, e)
455 var dt = _this.dateSel.getValue();
458 Roo.Msg.alert('Error', 'Please select a FROM date to download');
463 url : baseURL + '/Roo/Metasql',
468 '_as_of:text' : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
476 Roo.MessageBox.alert("Notice", "Report will download shortly");
479 text : "GL Stock Transactions on From date"
489 click : function (_self, e)
491 var dt = _this.dateSel.getValue();
492 var end_dt = _this.endDateSel.getValue();
493 var location_id = _this.locationCombo.getValue() *1;
496 Roo.Msg.alert('Error', 'Please select a FROM date to download');
500 Roo.Msg.alert('Error', 'Please select a TO date to download');
504 Roo.Msg.alert('Error', 'Please select a Location to download');
508 url : baseURL + '/Roo/Metasql',
512 _group : 'invdetail',
513 '_name[0]' : 'opening',
514 '_name[1]' : 'closing',
515 '_name[2]' : 'byitem',
516 '_name[3]' : 'bydate',
517 'location_id:number' : location_id,
518 'from_dt:text' : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
519 'to_dt:text' : typeof(end_dt) == 'string' ? end_dt : end_dt.format('Y-m-d'),
525 Roo.MessageBox.alert("Notice", "Report will download shortly");
528 text : "Consignment Detail Report"
539 beforeload : function (_self, o)
541 if (!_this.itemsiteCombo.getValue().length &&
542 !_this.locationCombo.getValue() &&
543 !_this.dateSel.getValue() &&
544 !_this.endDateSel.getValue()) {
545 _this.grid.ds.removeAll();
548 o.params['query[item_number]'] = _this.itemsiteCombo.getValue();
549 o.params.invdetail_location_id = _this.locationCombo.getValue();
550 o.params['query[viewtype]'] = _this.viewtype.getValue();
551 o.params._with_item =1;
553 var start = _this.dateSel.getValue();
554 var end = _this.endDateSel.getValue();
556 o.params['query[dateSel]'] = typeof(start) == 'string' ? start : start.format('Y-m-d');
557 o.params['query[endDateSel]'] = typeof(end) == 'string' ? end : end.format('Y-m-d');
559 o.params._with_balance = 1;
565 sortInfo : { field : 'invhist_transdate,invdetail_id', direction: 'DESC' },
570 url : baseURL + '/Roo/invdetail.php'
575 totalProperty : 'total',
580 'name': 'invhist_id',
584 'name': 'invhist_itemsite_id',
588 'name': 'invhist_transdate',
590 'dateFormat': 'Y-m-d'
593 'name': 'invhist_transtype',
597 'name': 'invhist_invqty',
601 'name': 'invhist_invuom',
605 'name': 'invhist_ordnumber',
609 'name': 'invhist_docnumber',
613 'name': 'invhist_qoh_before',
617 'name': 'invhist_qoh_after',
621 'name': 'invhist_unitcost',
625 'name': 'invhist_acct_id',
629 'name': 'invhist_xfer_warehous_id',
633 'name': 'invhist_comments',
637 'name': 'invhist_posted',
641 'name': 'invhist_imported',
645 'name': 'invhist_hasdetail',
649 'name': 'invhist_ordtype',
653 'name': 'invhist_analyze',
657 'name': 'invhist_user',
661 'name': 'invhist_created',
663 'dateFormat': 'Y-m-d'
666 'name': 'invhist_costmethod',
670 'name': 'invhist_value_before',
674 'name': 'invhist_value_after',
678 'name': 'invhist_series',
685 xtype: 'PagingToolbar',
688 displayMsg : "Displaying invhist{0} - {1} of {2}",
689 emptyMsg : "No invhist found",
696 click : function (_self, e)
698 Roo.MessageBox.progress ("Syncing Fifo fill", "Sending");
703 // for a single location.
707 var runSync= function() {
713 url : baseURL+'/Roo/Invdetail',
719 location_id : _this.locationCombo.getValue(),
720 item_number : _this.itemsiteCombo.getValue()
722 success : function(res) {
724 if (!res.data.total) {
725 Roo.MessageBox.hide();
730 var elapsed = el - st;
732 var total_time = (elapsed / offset) * res.data.total ;
733 var remaining = (total_time - elapsed) / (1000 * 60);
736 offset = res.data.offset + res.data.limit;
737 Roo.MessageBox.updateProgress ( offset / res.data.total, "Done " + offset + '/' + res.data.total +
738 " Est. complete in " + remaining.toFixed(1) + "mins");
741 failure : function() {
742 Roo.MessageBox.alert("Error", "Sending failed - probably a timeout");
757 click : function (_self, e)
759 Roo.MessageBox.progress ("Syncing Fifo fill values", "Sending");
764 // for a single location.
768 var runSync= function() {
774 url : baseURL+'/Roo/Invdetail',
780 location_id : _this.locationCombo.getValue(),
781 item_number : _this.itemsiteCombo.getValue()
783 success : function(res) {
785 if (!res.data.total) {
786 Roo.MessageBox.hide();
791 var elapsed = el - st;
793 var total_time = (elapsed / offset) * res.data.total ;
794 var remaining = (total_time - elapsed) / (1000 * 60);
797 offset = res.data.offset + res.data.limit;
798 Roo.MessageBox.updateProgress ( offset / res.data.total, "Done " + offset + '/' + res.data.total +
799 " Est. complete in " + remaining.toFixed(1) + "mins");
802 failure : function() {
803 Roo.MessageBox.alert("Error", "Sending failed - probably a timeout");
812 text : "Fifo Fill Values"
818 click : function (_self, e)
820 Roo.MessageBox.progress ("Syncing shipvoid fill", "Sending");
825 // for a single location.
829 var runSync= function() {
833 url : baseURL+'/Roo/cohead',
840 success : function(res) {
842 if (!res.data.total) {
843 Roo.MessageBox.hide();
848 var elapsed = el - st;
850 var total_time = (elapsed / offset) * res.data.total ;
851 var remaining = (total_time - elapsed) / (1000 * 60);
854 offset = res.data.offset + res.data.limit;
855 Roo.MessageBox.updateProgress ( offset / res.data.total, "Done " + offset + '/' + res.data.total +
856 " Est. complete in " + remaining.toFixed(1) + "mins");
859 failure : function() {
860 Roo.MessageBox.alert("Error", "Sending failed - probably a timeout");
869 text : "Shipvoid Fill"
875 xtype: 'ColumnModel',
878 dataIndex : 'invdetail_id',
879 header : 'Invdetail#',
881 renderer : function(v,x,r) {
882 if (r.data.invfifo_void > 0) {
883 return '<s>' + v + '</s>';
889 xtype: 'ColumnModel',
891 dataIndex : 'invhist_transdate',
895 renderer : function(v,x,r) {
897 var vv = Date.parseDate(v.split(' ')[0],'Y-m-d' );
899 if (r.data.invfifo_void > 0) {
900 return String.format('<s>{0}</s>', vv ? vv.format('d/M/Y') : '');
903 return String.format('{0}', vv ? vv.format('d/M/Y') : '');
907 xtype: 'ColumnModel',
909 dataIndex : 'invhist_created',
914 renderer : function(v) {
915 var vv = Date.parseDate(v.split(' ')[0],'Y-m-d' );
916 return String.format('{0}', vv ? vv.format('d/M/Y') : '');
920 xtype: 'ColumnModel',
922 dataIndex : 'item_number',
925 renderer : function(v) {
927 return String.format('<b>{0}</b>', v );
931 xtype: 'ColumnModel',
933 dataIndex : 'invhist_ordnumber',
936 renderer : function(v,x,r) {
939 return String.format('{0}', v); }
942 xtype: 'ColumnModel',
944 dataIndex : 'invhist_docnumber',
947 renderer : function(v) { return String.format('{0}', v); }
950 xtype: 'ColumnModel',
952 dataIndex : 'invhist_transtype',
955 renderer : function(v,x,r) { return String.format('{0}/{1}', v,r.data.invhist_ordtype); }
958 xtype: 'ColumnModel',
961 dataIndex : 'invhist_unitcost',
962 header : ' unitcost',
964 renderer : function(v) { return String.format('{0}', v); }
967 xtype: 'ColumnModel',
969 dataIndex : 'location_name',
972 renderer : function(v) { return String.format('<B>{0}</B>', v); }
975 xtype: 'ColumnModel',
978 dataIndex : 'invdetail_qty',
981 renderer : function(v,x,r)
983 if (r.data.invfifo_void > 0) {
984 return String.format('<s>{0}</s>', parseInt( v));
986 return String.format('{0}', parseInt( v));
990 xtype: 'ColumnModel',
993 dataIndex : 'invdetail_balance_qty',
996 renderer : function(v,x,r)
998 if (r.data.invfifo_void > 0) {
999 return String.format('<s>{0}</s>', parseInt( v));
1001 return String.format('{0}', parseInt( v));
1005 xtype: 'ColumnModel',
1007 header : 'Invhist comments',
1009 dataIndex : 'invhist_comments',
1010 renderer : function(v) { return String.format('{0}', v); }
1013 xtype: 'ColumnModel',
1016 dataIndex : 'invfifo_qty_after',
1017 header : 'Fifo After',
1019 renderer : function(v,x,r) {
1020 if ( r.data.invdetail_qty < 0 ) {
1023 return (v*1).toFixed(0) ;
1027 xtype: 'ColumnModel',
1030 dataIndex : 'invfifo_qty_after',
1031 header : 'Fifo After',
1033 renderer : function(v,x,r) {
1034 if ( r.data.invdetail_qty > 0 ) {
1037 return (v*1).toFixed(0) ;
1041 xtype: 'ColumnModel',
1044 dataIndex : 'invfifo_cost_before',
1045 header : 'Fifo Cost Before',
1047 renderer : function(v,x,r) {
1048 if ( r.data.invdetail_qty < 0 ) {
1051 return (v*1).toFixed(2) ;
1055 xtype: 'ColumnModel',
1058 dataIndex : 'invfifo_cost_after',
1059 header : 'Fifo Cost After',
1061 renderer : function(v,x,r) {
1062 if ( r.data.invdetail_qty < 0 ) {
1065 return (v*1).toFixed(2) ;
1069 xtype: 'ColumnModel',
1072 dataIndex : 'invfifo_cost_before',
1073 header : 'Fifo Cost Before',
1075 renderer : function(v,x,r) {
1076 if ( r.data.invdetail_qty > 0 ) {
1079 return (v*1).toFixed(2) ;
1083 xtype: 'ColumnModel',
1086 dataIndex : 'invfifo_cost_after',
1087 header : 'Fifo Cost After',
1089 renderer : function(v,x,r) {
1090 if ( r.data.invdetail_qty > 0 ) {
1093 return (v*1).toFixed(2) ;
1097 xtype: 'ColumnModel',
1100 dataIndex : 'invfifo_unitcost',
1101 header : 'Fifo Unitcost',
1103 renderer : function(v,x,r)
1105 if (r.data.invfifo_void > 0) {
1106 return '<s>' + (v*1).toFixed(2) + '</s>';
1108 return (v*1).toFixed(2) ;
1112 xtype: 'ColumnModel',
1115 dataIndex : 'invfifo_landedunitcost',
1116 header : 'Fifo Landed Unitcost',
1118 renderer : function(v,x,r) {
1120 var cu = ((r.data.invfifo_cost_after*1 - r.data.invfifo_cost_before*1) / Math.abs(r.data.invdetail_qty)).toFixed(2);
1121 var lu = (v*1).toFixed(2) ;
1124 if (r.data.invfifo_void > 0) {
1125 return '<s><span style="color:red">' + + lu +'/' +cu + '</span></s>';
1128 return '<span style="color:red">' + lu +'/' +cu + '</span>';
1130 if (r.data.invfifo_void > 0) {
1131 return '<s>' + lu + '</s>';