1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Roo.namespace('Pman.Tab');
7 Pman.Tab.XtupleStock = new Roo.XComponent({
8 part : ["Xtuple", "Stock" ],
9 order : '001-Pman.Tab.XtupleStock',
11 parent : 'Pman.Tab.XtupleManage',
12 name : "Pman.Tab.XtupleStock",
23 xtype : 'LayoutRegion',
29 xtype : 'LayoutRegion',
35 xtype : 'BorderLayout',
42 xtype : 'RowSelectionModel',
45 selectionchange : function (_self)
48 // _this.toppanel.layout.getRegion('east').expand();
55 url : baseURL + '/Roo/location.php',
68 'name': 'location_id',
72 'name': 'location_warehous_id',
76 'name': 'location_name',
80 'name': 'location_descrip',
84 'name': 'location_restrict',
88 'name': 'location_netable',
92 'name': 'location_whsezone_id',
96 'name': 'location_aisle',
100 'name': 'location_rack',
104 'name': 'location_bin',
108 totalProperty : 'total'
113 sortInfo : { field : 'location_name', direction: 'ASC' },
116 beforeload : function (_self, o)
119 o.params._as_of = _this.dateTo.getValue();
121 if (!o.params._as_of.length) {
124 o.params._with_stock_and_value = 1;
126 o.params._viewType = _this.viewType.getValue();
128 load : function (_self, records, options)
132 var dt = Date.parseDate(_this.dateTo.getValue(), 'Y-m-d');
133 var maxd = Date.parseDate('2012-11-01', 'Y-m-d');
135 if (!records.length) {
141 Roo.each(records, function(r) {
142 map[r.data.location_id] = r;
143 r.set('location_qty',undefined);
144 r.set('location_qty_neg', undefined);
145 r.set('location_value', undefined);
151 var overlaydata = function (type, data) {
152 Roo.each(data, function(r) {
153 var rec= map[r.location_id];
157 rec.set('location_netsuite_stock', r.location_netsuite_stock);
158 rec.set('location_netsuite_stock_neg', r.location_netsuite_stock_neg);
161 rec.set('location_qty', r.location_qty);
162 pqty += r.location_qty *1;
163 rec.set('location_qty_neg', r.location_qty_neg);
164 nqty += r.location_qty_neg *1;
165 rec.set('location_value', r.location_value);
166 tval += r.location_value * 1.0;
179 var loadoverlay = function(type) {
184 //mask : 'Loading ' + type + ' stock levels (takes around 30s)',
186 url : baseURL + '/Roo/Location',
188 _as_of : _this.dateTo.getValue(),
189 _with_stock_and_value : 'both',
190 location_id : records[i++].data.location_id
192 success : function( res ) {
194 overlaydata(type, res.data);
196 if (i >= records.length) {
197 _this.grid.footer.displayEl.update(String.format("Total: pos={0} neg={1} eq={2} val={3}",
198 Roo.util.Format.number(pqty,0),
199 Roo.util.Format.number(nqty,0),
200 Roo.util.Format.number(pqty+nqty,0),
201 Roo.util.Format.number(tval,0)
206 //if (type == 'dragon' && dt < maxd ) {
207 // loadoverlay('netsuite');
214 failure : function( ) {
215 Roo.MessageBox.alert('Error' , 'Loading data failed, try again');
221 loadoverlay('dragon');
234 xtype : 'PagingToolbar',
235 emptyMsg : "No location found",
237 displayMsg : "Displaying location{0} - {1} of {2}",
241 '|xns' : 'Roo.Toolbar',
242 text : "Sync Stock Balances",
247 click : function (_self, e)
249 Roo.MessageBox.progress ("Syncing Balances", "Sending");
256 url : baseURL+'/Roo/Locbal',
262 success : function(res) {
264 if (!res.data.total) {
265 Roo.MessageBox.hide();
268 offset += res.data.limit;
269 Roo.MessageBox.updateProgress ( offset / res.data.total, "Done " + offset + '/' + res.data.total);
287 text : "Transfer to Fix +ve number",
291 click : function (_self, e)
293 var l = _this.grid.selModel ? _this.grid.selModel.getSelected() : false;
295 Roo.MessageBox.alert("Error", "Select location");
299 Pman.Dialog.XtupleTransfer.show({
302 invhist_transfer_to : l.data.location_id,
303 invhist_transfer_to_location_descrip : l.data.location_descrip,
305 invhist_transfer_transdate : _this.dateTo.getValue(),
306 invhist_transfer_arrivaldate : _this.dateTo.getValue()
309 }, function() { _this.grid.ds.load({}); }
318 text : "Transfer to Fix -ve number",
322 click : function (_self, e)
324 var l = _this.grid.selModel ? _this.grid.selModel.getSelected() : false;
326 Roo.MessageBox.alert("Error", "Select location");
330 Pman.Dialog.XtupleTransfer.show({
333 invhist_transfer_from : l.data.location_id,
334 invhist_transfer_from_location_descrip : l.data.location_descrip,
336 invhist_transfer_transdate : _this.dateTo.getValue(),
337 invhist_transfer_arrivaldate : _this.dateTo.getValue()
340 }, function() { _this.grid.ds.load({}); }
350 '|xns' : 'Roo.Toolbar',
351 text : "Upload new products and costs",
356 click : function (_self, e)
358 Pman.Dialog.Image.show(
360 _url : baseURL+'/Xtuple/Import/Products'
367 msg.push("Updated " + data.updated + " Products(s)");
370 msg.push("Added " + data.inserted + " Products(s)");
373 msg.push("Skipped " + data.skipped);
377 msg.push("No data changed");
379 Roo.MessageBox.alert("Notice", msg.join("\n"));
399 '|xns' : 'Roo.Toolbar',
412 render : function (_self)
414 _this.dateTo = _self;
416 select : function (combo, date)
418 _this.grid.footer.onClick('first');
425 xtype : 'SimpleStore',
426 data : [ ['local', "Local"],[ 'remote' , "Remote"],[ 'disabled', "Disabled"] ],
427 fields : [ 'ftype', 'fname'],
432 triggerAction : 'all',
433 fieldLabel : 'Status',
434 displayField : 'fname',
435 hiddenName : 'loctype',
437 valueField : 'ftype',
444 name : 'loctype_name',
446 render : function (_self)
448 _this.viewType = _self;
450 select : function (combo, record, index)
452 _this.grid.footer.onClick('first');
461 '|xns' : 'Roo.Toolbar',
466 '|xns' : 'Roo.Toolbar',
469 cls : 'x-btn-text-icon',
470 icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
476 Pman.Dialog.XtupleLocation.show( { }, function() {
477 _this.grid.footer.onClick('first');
480 render : function (_self)
482 _this.addItemBtn = _self;
494 text : "Summary of Stock in all Locatoins",
498 click : function (_self, e)
504 Roo.each( _this.grid.colModel.config, function(h) {
506 cols.push(h.dataIndex);
509 _this.grid.ds.each(function(rec) {
511 for(var i =0;i<cols.length;i++) {
512 hr.push(rec.get(cols[i]));
518 url : baseURL + '/Core/JsonToExcel',
521 _json : Roo.encode(ret)
535 text : "All Stock in all locations (active)",
539 click : function (_self, e)
545 url : baseURL + '/Roo/Invdetail',
549 _summary_at_date : _this.dateTo.getValue(),
550 'csvCols[0]' : 'location_name',
551 'csvCols[1]' : 'item_number',
552 'csvCols[2]' : 'item_descrip1',
553 'csvCols[3]' : 'stock_qty',
554 'csvCols[4]' : 'stdcost_value',
555 'csvCols[5]' : 'fifo_value',
556 'csvTitles[0]' :'Location',
557 'csvTitles[1]' : 'Item Number',
558 'csvTitles[2]' : 'Item Description',
559 'csvTitles[3]' : 'Qty',
560 'csvTitles[4]' : 'Std Cost Valued',
561 'csvTitles[5]' : 'FIFO Value',
562 'sort' : 'location_name,item_number',
564 _with_empty_stock : 1,
569 Roo.MessageBox.alert("Notice", "Report will download shortly (around 30s)");
576 text : "Stock at Selected Location (inc. empty)",
580 click : function (_self, e)
583 'csvCols[0]' : 'itemsite_item_id_item_number',
584 'csvCols[1]' : 'item_brand_name',
585 'csvCols[2]' : 'itemsite_item_id_item_descrip1',
586 'csvCols[3]' : 'itemsite_qty_before',
587 'csvCols[4]' : 'itemsite_sold_atdate' ,
588 'csvCols[5]' : 'itemsite_qty',
589 'csvCols[6]' : 'itemsite_sold_after',
590 'csvCols[7]' : 'last_transaction',
591 'csvCols[8]' : 'customer_price_each',
592 'csvCols[9]' : 'customer_total_value',
593 'csvCols[10]' : 'itemsite_value',
594 'csvCols[11]' : 'item_last_purchase_price',
596 'csvTitles[0]' : 'SKU',
597 'csvTitles[1]' : 'Brand' ,
598 'csvTitles[2]' : 'Description',
599 'csvTitles[3]' : 'Qty Before' ,
600 'csvTitles[4]' : 'Total Sold' ,
601 'csvTitles[5]' : 'Qty' ,
602 'csvTitles[6]' : 'Sold After' ,
603 'csvTitles[7]' : 'Last Transaction' ,
604 'csvTitles[8]' : 'Customer unit price' ,
605 'csvTitles[9]' : 'Customer Total Value' ,
606 'csvTitles[10]' : 'FIFO value' ,
607 'csvTitles[11]' : 'Last Purchase Price' ,
612 'sort' : 'itemsite_item_id_item_number',
616 var l = _this.grid.selModel ? _this.grid.selModel.getSelected() : false;
618 Roo.MessageBox.alert("Error", "Select location");
621 p.location_id = l.data.location_id;
622 p._as_of = _this.dateTo.getValue();
623 p._with_stock_and_value = 1;
626 p._with_last_purchase_price = 1;
627 p._with_qty_detail = 1;
630 url : baseURL + '/Roo/itemsite',
638 Roo.MessageBox.alert("Notice", "Report will download shortly");
649 text : "Stock at Selected Location (inc. empty) with Adjustment details",
653 click : function (_self, e)
658 _name : 'stockatlocation',
662 var l = _this.grid.selModel ? _this.grid.selModel.getSelected() : false;
664 Roo.MessageBox.alert("Error", "Select location");
667 p['location_id:number'] = l.data.location_id;
668 p['as_of:text'] = _this.dateTo.getValue();
671 url : baseURL + '/Roo/Metasql',
680 Roo.MessageBox.alert("Notice", "Report will download shortly");
687 '|xns' : 'Roo.Toolbar',
688 text : "Download Reports",
700 autoExpandColumn : 'location_name',
707 xtype : 'ColumnModel',
710 renderer : function(v) {
711 var state = v * 1 > 0 ? '' : '-checked' ;
713 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
717 dataIndex : 'location_restrict'
721 xtype : 'ColumnModel',
724 renderer : function(v) { return String.format('{0}', v); },
726 dataIndex : 'location_name'
730 xtype : 'ColumnModel',
731 header : 'Description',
733 renderer : function(v) { return String.format('{0}', v); },
735 dataIndex : 'location_descrip'
739 xtype : 'ColumnModel',
742 renderer : function(v,x,r) {
744 if (!r.data.location_cust_id_char_internalcompany.length) {
745 return String.format('{0}', v);
747 return String.format('<span style="color:red">[Internal Company : {0}] {1} </span>',
748 r.data.location_cust_id_char_internalcompany, v);
752 dataIndex : 'location_cust_id_cust_name'
757 xtype : 'ColumnModel',
760 renderer : function(v,x,r) { return typeof(v) == 'undefined' ? '...' : String.format('{0} ', (v*1).toFixed(0) ); },
762 dataIndex : 'location_qty'
767 xtype : 'ColumnModel',
768 header : 'Missing TX',
770 renderer : function(v,x,r) {
771 if ( typeof(v) == 'undefined') {
778 return String.format('<span style="color:red;">{0}</span>', (v*1).toFixed(0) );
781 dataIndex : 'location_qty_neg'
786 xtype : 'ColumnModel',
787 header : 'Est. Net Qty',
789 renderer : function(v,x,r) {
791 return typeof(v) == 'undefined' ? '...' :
792 String.format('{0}', ((v*1) + (r.data.location_qty_neg*1)).toFixed(0) );
795 dataIndex : 'location_qty'
801 xtype : 'ColumnModel',
804 renderer : function(v,x,r) {
806 if ((r.data.location_qty) *1 != (v*1)) {
807 f = '<span style="color:red;font-weight:bold">{0}</span>';
809 return typeof(v) == 'undefined' ? '...' : String.format(f, (v*1).toFixed(0) );
813 dataIndex : 'location_netsuite_stock'
819 xtype : 'ColumnModel',
820 header : 'NS -ve Qty',
822 renderer : function(v,x,r) {
824 if ((r.data.location_qty_neg) *1 != (v*1)) {
825 f = '<span style="color:red;font-weight:bold">{0}</span>';
827 return typeof(v) == 'undefined' ? '...' : String.format(f, (v*1).toFixed(0) );
830 dataIndex : 'location_netsuite_stock_neg'
835 xtype : 'ColumnModel',
838 renderer : function(v) { return typeof(v) == 'undefined' ? '...' : Roo.util.Format.usMoney( v); },
840 dataIndex : 'location_value'
844 rowdblclick : function (_self, rowIndex, e)
847 Pman.Dialog.XtupleLocation.show( this.getDataSource().getAt(rowIndex).data, function() {
848 _this.grid.footer.onClick('first');
851 cellclick : function (_self, rowIndex, col, e)
854 var ix = this.colModel.getDataIndex(col);
855 var rec = _this.grid.ds.getAt(rowIndex);
859 if (ix == 'location_restrict') {
861 var nv = rec.data.location_restrict ? 0 : 1;
864 url : baseURL + '/Roo/Location',
866 location_id : rec.data.location_id,
867 location_restrict : nv
869 success : function() {
870 rec.set('location_restrict', nv);
881 _this.itemgrid.viewtype = 1;
884 if ('location_qty_neg' == ix || 'location_netsuite_stock_neg' == ix ) {
885 _this.itemgrid.viewtype = -1;
887 if ('location_netsuite_stock' == ix || 'location_netsuite_stock_neg' == ix ) {
888 _this.itemgrid.viewtype *= 2;
891 (function() { _this.itemgrid.footer.onClick('first'); }).defer(100);
912 //_this.dialog = Pman.Dialog.FILL_IN
913 if (_this.panel.active) {
914 this.footer.onClick('first');
931 tableName : 'location',
933 activate : function() {
936 _this.grid.footer.onClick('first');
950 url : baseURL + '/Roo/itemsite.php',
960 xtype : 'JsonReader',
964 'name': 'itemloc_id',
968 'name': 'itemloc_itemsite_id',
972 'name': 'itemloc_location_id',
976 'name': 'itemloc_qty',
980 'name': 'itemloc_expiration',
982 'dateFormat': 'Y-m-d'
985 'name': 'itemloc_consolflag',
989 'name': 'itemloc_ls_id',
993 'name': 'itemloc_warrpurc',
995 'dateFormat': 'Y-m-d'
998 totalProperty : 'total'
1000 '|xns' : 'Roo.data',
1003 sortInfo : { field : 'itemsite_item_id_item_number', direction: 'ASC' },
1006 beforeload : function (_self, o)
1008 var l = _this.grid.selModel ? _this.grid.selModel.getSelected() : false;
1012 o.params.location_id = l.data.location_id;
1013 o.params._as_of = _this.dateTo.getValue();
1014 o.params._with_stock_and_value = 1;
1015 o.params._viewtype = _this.itemgrid.viewtype;
1026 xtype : 'PagingToolbar',
1027 emptyMsg : "No itemloc found",
1029 displayMsg : "{0} - {1} of {2}",
1032 '|xns' : 'Roo.grid',
1033 autoExpandColumn : 'itemsite_item_id_item_number',
1039 '|xns' : 'Roo.grid',
1040 xtype : 'ColumnModel',
1043 renderer : function(v) { return String.format('{0}', v); },
1045 dataIndex : 'itemsite_item_id_item_number'
1048 '|xns' : 'Roo.grid',
1050 xtype : 'ColumnModel',
1053 renderer : function(v) { return String.format('{0}', (v*1).toFixed(0)); },
1055 dataIndex : 'itemsite_qty'
1058 '|xns' : 'Roo.grid',
1061 xtype : 'ColumnModel',
1064 renderer : function(v,x,r) {
1065 var f= '<span style="color:blue;text-decoration:underline;cursor:pointer;">{0}</span>';
1066 if ((r.data.itemsite_qty) *1 != (v*1)) {
1067 f = '<span style="color:red;font-weight:bold;text-decoration:underline;cursor:pointer;">{0}</span>';
1069 return String.format(f, (v*1).toFixed(0) );
1072 dataIndex : 'netsuite_qty'
1075 '|xns' : 'Roo.grid',
1077 xtype : 'ColumnModel',
1080 renderer : function(v) { return Roo.util.Format.usMoney(v); },
1082 dataIndex : 'itemsite_value'
1086 rowdblclick : function (_self, rowIndex, e)
1088 var rec =this.getDataSource().getAt(rowIndex);
1090 var loc = _this.grid.selModel.getSelected();
1092 var dt = _this.dateTo.getValue();
1094 Pman.Dialog.XtupleInvHistory.show({
1095 itemsite_item_id_item_number : rec.data.itemsite_item_id_item_number,
1097 location_name : loc.data.location_name,
1098 location_descrip : loc.data.location_descrip,
1100 invhist_transdate : typeof(dt) == 'string' ? dt : dt.format('Y-m-d')
1106 cellclick : function (_self, row, col, e)
1109 if ('netsuite_qty' == this.colModel.getDataIndex(col)) {
1110 var d = this.ds.getAt(row);
1111 var loc = _this.grid.selModel.getSelected();
1114 url: baseURL + '/Xtuple/NetsuiteFix/StockCheck',
1116 item_id : d.data.itemsite_item_id,
1117 location_id : loc.data.location_id
1126 _this.itemgrid = this;
1127 //_this.dialog = Pman.Dialog.FILL_IN
1128 if (_this.itempanel.active) {
1129 // this.footer.onClick('first');
1143 xtype : 'GridPanel',
1144 fitContainer : true,
1146 tableName : 'itemloc',
1148 activate : function() {
1149 _this.itempanel = this;
1150 if (_this.itemgrid) {
1151 // _this.itemgrid.footer.onClick('first');
1166 title : "Locations /Stock ",
1167 xtype : 'NestedLayoutPanel',
1170 render : function (_self)
1172 _this.toppanel = _self;