1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Pman.Tab.XtupleStock = new Roo.XComponent({
6 part : ["Xtuple","Stock"],
7 order : '001-Pman.Tab.XtupleStock',
9 parent : 'Pman.Tab.XtupleManage',
10 name : "Pman.Tab.XtupleStock",
18 xtype: 'NestedLayoutPanel',
21 render : function (_self)
23 _this.toppanel = _self;
28 title : "Locations /Stock ",
30 xtype: 'BorderLayout',
37 activate : function() {
40 _this.grid.footer.onClick('first');
48 tableName : 'location',
57 //_this.dialog = Pman.Dialog.FILL_IN
58 if (_this.panel.active) {
59 this.footer.onClick('first');
62 rowdblclick : function (_self, rowIndex, e)
65 Pman.Dialog.XtupleLocation.show( this.getDataSource().getAt(rowIndex).data, function() {
66 _this.grid.footer.onClick('first');
69 cellclick : function (_self, rowIndex, col, e)
72 var ix = this.colModel.getDataIndex(col);
73 var rec = _this.grid.ds.getAt(rowIndex);
77 if (ix == 'location_restrict') {
79 var nv = rec.data.location_restrict ? 0 : 1;
82 url : baseURL + '/Roo/Location',
84 location_id : rec.data.location_id,
85 location_restrict : nv
87 success : function() {
88 rec.set('location_restrict', nv);
99 _this.itemgrid.viewtype = 1;
102 if ('location_qty_neg' == ix || 'location_netsuite_stock_neg' == ix ) {
103 _this.itemgrid.viewtype = -1;
105 if ('location_netsuite_stock' == ix || 'location_netsuite_stock_neg' == ix ) {
106 _this.itemgrid.viewtype *= 2;
109 (function() { _this.itemgrid.footer.onClick('first'); }).defer(100);
128 autoExpandColumn : 'location_name',
131 xtype: 'RowSelectionModel',
134 selectionchange : function (_self)
137 // _this.toppanel.layout.getRegion('east').expand();
145 beforeload : function (_self, o)
148 o.params._as_of = _this.dateTo.getValue();
149 if (!o.params._as_of.length) {
152 o.params._with_stock_and_value = 1;
154 o.params._viewType = _this.viewType.getValue();
156 load : function (_self, records, options)
160 var dt = Date.parseDate(_this.dateTo.getValue(), 'Y-m-d');
161 var maxd = Date.parseDate('2012-11-01', 'Y-m-d');
163 if (!records.length) {
169 Roo.each(records, function(r) {
170 map[r.data.location_id] = r;
171 r.set('location_qty',undefined);
172 r.set('location_qty_neg', undefined);
173 r.set('location_value', undefined);
179 var overlaydata = function (type, data) {
180 Roo.each(data, function(r) {
181 var rec= map[r.location_id];
185 rec.set('location_netsuite_stock', r.location_netsuite_stock);
186 rec.set('location_netsuite_stock_neg', r.location_netsuite_stock_neg);
189 rec.set('location_qty', r.location_qty);
190 pqty += r.location_qty *1;
191 rec.set('location_qty_neg', r.location_qty_neg);
192 nqty += r.location_qty_neg *1;
193 rec.set('location_value', r.location_value);
194 tval += r.location_value * 1.0;
207 var loadoverlay = function(type) {
212 //mask : 'Loading ' + type + ' stock levels (takes around 30s)',
214 url : baseURL + '/Roo/Location',
216 _as_of : _this.dateTo.getValue(),
217 _with_stock_and_value : 'both',
218 location_id : records[i++].data.location_id
220 success : function( res ) {
222 overlaydata(type, res.data);
224 if (i >= records.length) {
225 _this.grid.footer.displayEl.update(String.format("Total: pos={0} neg={1} eq={2} val={3}",
226 Roo.util.Format.number(pqty,0),
227 Roo.util.Format.number(nqty,0),
228 Roo.util.Format.number(pqty+nqty,0),
229 Roo.util.Format.number(tval,0)
234 //if (type == 'dragon' && dt < maxd ) {
235 // loadoverlay('netsuite');
242 failure : function( ) {
243 Roo.MessageBox.alert('Error' , 'Loading data failed, try again');
249 loadoverlay('dragon');
255 sortInfo : { field : 'location_name', direction: 'ASC' },
260 url : baseURL + '/Roo/location.php'
265 totalProperty : 'total',
270 'name': 'location_id',
274 'name': 'location_warehous_id',
278 'name': 'location_name',
282 'name': 'location_descrip',
286 'name': 'location_restrict',
290 'name': 'location_netable',
294 'name': 'location_whsezone_id',
298 'name': 'location_aisle',
302 'name': 'location_rack',
306 'name': 'location_bin',
313 xtype: 'PagingToolbar',
316 displayMsg : "Displaying location{0} - {1} of {2}",
317 emptyMsg : "No location found",
324 click : function (_self, e)
326 Roo.MessageBox.progress ("Syncing Balances", "Sending");
333 url : baseURL+'/Roo/Locbal',
339 success : function(res) {
341 if (!res.data.total) {
342 Roo.MessageBox.hide();
345 offset += res.data.limit;
346 Roo.MessageBox.updateProgress ( offset / res.data.total, "Done " + offset + '/' + res.data.total);
356 text : "Sync Stock Balances"
362 click : function (_self, e)
364 Pman.Dialog.Image.show(
366 _url : baseURL+'/Xtuple/Import/Products'
373 msg.push("Updated " + data.updated + " Products(s)");
376 msg.push("Added " + data.inserted + " Products(s)");
379 msg.push("Skipped " + data.skipped);
383 msg.push("No data changed");
385 Roo.MessageBox.alert("Notice", msg.join("\n"));
392 text : "Upload new products and costs",
401 click : function (_self, e)
403 var l = _this.grid.selModel ? _this.grid.selModel.getSelected() : false;
405 Roo.MessageBox.alert("Error", "Select location");
409 Pman.Dialog.XtupleTransfer.show({
412 invhist_transfer_to : l.data.location_id,
413 invhist_transfer_to_location_descrip : l.data.location_descrip,
415 invhist_transfer_transdate : _this.dateTo.getValue(),
416 invhist_transfer_arrivaldate : _this.dateTo.getValue()
419 }, function() { _this.grid.ds.load({}); }
425 text : "Transfer to Fix +ve number"
431 click : function (_self, e)
433 var l = _this.grid.selModel ? _this.grid.selModel.getSelected() : false;
435 Roo.MessageBox.alert("Error", "Select location");
439 Pman.Dialog.XtupleTransfer.show({
442 invhist_transfer_from : l.data.location_id,
443 invhist_transfer_from_location_descrip : l.data.location_descrip,
445 invhist_transfer_transdate : _this.dateTo.getValue(),
446 invhist_transfer_arrivaldate : _this.dateTo.getValue()
449 }, function() { _this.grid.ds.load({}); }
455 text : "Transfer to Fix -ve number"
475 render : function (_self)
477 _this.dateTo = _self;
479 select : function (combo, date)
481 _this.grid.footer.onClick('first');
492 render : function (_self)
494 _this.viewType = _self;
496 select : function (combo, record, index)
498 _this.grid.footer.onClick('first');
502 displayField : 'fname',
504 fieldLabel : 'Status',
505 hiddenName : 'loctype',
508 name : 'loctype_name',
509 triggerAction : 'all',
511 valueField : 'ftype',
514 xtype: 'SimpleStore',
516 data : [ ['local', "Local"],[ 'remote' , "Remote"],[ 'disabled', "Disabled"] ],
517 fields : [ 'ftype', 'fname']
531 Pman.Dialog.XtupleLocation.show( { }, function() {
532 _this.grid.footer.onClick('first');
535 render : function (_self)
537 _this.addItemBtn = _self;
540 cls : 'x-btn-text-icon',
542 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
547 text : "Download Reports",
556 click : function (_self, e)
562 Roo.each( _this.grid.colModel.config, function(h) {
564 cols.push(h.dataIndex);
567 _this.grid.ds.each(function(rec) {
569 for(var i =0;i<cols.length;i++) {
570 hr.push(rec.get(cols[i]));
576 url : baseURL + '/Core/JsonToExcel',
579 _json : Roo.encode(ret)
585 text : "Summary of Stock in all Locatoins"
595 click : function (_self, e)
601 url : baseURL + '/Roo/Invdetail',
605 _summary_at_date : _this.dateTo.getValue(),
606 'csvCols[0]' : 'location_name',
607 'csvCols[1]' : 'item_number',
608 'csvCols[2]' : 'item_descrip1',
609 'csvCols[3]' : 'stock_qty',
610 'csvCols[4]' : 'stdcost_value',
611 'csvCols[5]' : 'fifo_value',
612 'csvTitles[0]' :'Location',
613 'csvTitles[1]' : 'Item Number',
614 'csvTitles[2]' : 'Item Description',
615 'csvTitles[3]' : 'Qty',
616 'csvTitles[4]' : 'Std Cost Valued',
617 'csvTitles[5]' : 'FIFO Value',
618 'sort' : 'location_name,item_number',
620 _with_empty_stock : 1,
625 Roo.MessageBox.alert("Notice", "Report will download shortly (around 30s)");
629 text : "All Stock in all locations (active)"
635 click : function (_self, e)
638 'csvCols[0]' : 'itemsite_item_id_item_number',
639 'csvCols[1]' : 'item_brand_name',
640 'csvCols[2]' : 'itemsite_item_id_item_descrip1',
641 'csvCols[3]' : 'itemsite_qty_before',
642 'csvCols[4]' : 'itemsite_sold_atdate' ,
643 'csvCols[5]' : 'itemsite_qty',
644 'csvCols[6]' : 'itemsite_sold_after',
645 'csvCols[7]' : 'last_transaction',
646 'csvCols[8]' : 'customer_price_each',
647 'csvCols[9]' : 'customer_total_value',
648 'csvCols[10]' : 'itemsite_value',
649 'csvCols[11]' : 'item_last_purchase_price',
651 'csvTitles[0]' : 'SKU',
652 'csvTitles[1]' : 'Brand' ,
653 'csvTitles[2]' : 'Description',
654 'csvTitles[3]' : 'Qty Before' ,
655 'csvTitles[4]' : 'Total Sold' ,
656 'csvTitles[5]' : 'Qty' ,
657 'csvTitles[6]' : 'Sold After' ,
658 'csvTitles[7]' : 'Last Transaction' ,
659 'csvTitles[8]' : 'Customer unit price' ,
660 'csvTitles[9]' : 'Customer Total Value' ,
661 'csvTitles[10]' : 'FIFO value' ,
662 'csvTitles[11]' : 'Last Purchase Price' ,
667 'sort' : 'itemsite_item_id_item_number',
671 var l = _this.grid.selModel ? _this.grid.selModel.getSelected() : false;
673 Roo.MessageBox.alert("Error", "Select location");
676 p.location_id = l.data.location_id;
677 p._as_of = _this.dateTo.getValue();
678 p._with_stock_and_value = 1;
681 p._with_last_purchase_price = 1;
682 p._with_qty_detail = 1;
685 url : baseURL + '/Roo/itemsite',
693 Roo.MessageBox.alert("Notice", "Report will download shortly");
696 text : "Stock at Selected Location (inc. empty)"
706 click : function (_self, e)
711 _name : 'stockatlocation',
715 var l = _this.grid.selModel ? _this.grid.selModel.getSelected() : false;
717 Roo.MessageBox.alert("Error", "Select location");
720 p['location_id:number'] = l.data.location_id;
721 p['as_of:text'] = _this.dateTo.getValue();
724 url : baseURL + '/Roo/Metasql',
733 Roo.MessageBox.alert("Notice", "Report will download shortly");
736 text : "Stock at Selected Location (inc. empty) with Adjustment details"
745 xtype: 'ColumnModel',
747 dataIndex : 'location_restrict',
750 renderer : function(v) {
751 var state = v * 1 > 0 ? '' : '-checked' ;
753 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
758 xtype: 'ColumnModel',
760 dataIndex : 'location_name',
763 renderer : function(v) { return String.format('{0}', v); }
766 xtype: 'ColumnModel',
768 dataIndex : 'location_descrip',
769 header : 'Description',
771 renderer : function(v) { return String.format('{0}', v); }
774 xtype: 'ColumnModel',
776 dataIndex : 'location_cust_id_cust_name',
779 renderer : function(v,x,r) {
781 if (!r.data.location_cust_id_char_internalcompany.length) {
782 return String.format('{0}', v);
784 return String.format('<span style="color:red">[Internal Company : {0}] {1} </span>',
785 r.data.location_cust_id_char_internalcompany, v);
790 xtype: 'ColumnModel',
793 dataIndex : 'location_qty',
796 renderer : function(v,x,r) { return typeof(v) == 'undefined' ? '...' : String.format('{0} ', (v*1).toFixed(0) ); }
799 xtype: 'ColumnModel',
802 dataIndex : 'location_qty_neg',
803 header : 'Missing TX',
805 renderer : function(v,x,r) {
806 if ( typeof(v) == 'undefined') {
813 return String.format('<span style="color:red;">{0}</span>', (v*1).toFixed(0) );
817 xtype: 'ColumnModel',
820 dataIndex : 'location_qty',
821 header : 'Est. Net Qty',
823 renderer : function(v,x,r) {
825 return typeof(v) == 'undefined' ? '...' :
826 String.format('{0}', ((v*1) + (r.data.location_qty_neg*1)).toFixed(0) );
830 xtype: 'ColumnModel',
833 dataIndex : 'location_netsuite_stock',
837 renderer : function(v,x,r) {
839 if ((r.data.location_qty) *1 != (v*1)) {
840 f = '<span style="color:red;font-weight:bold">{0}</span>';
842 return typeof(v) == 'undefined' ? '...' : String.format(f, (v*1).toFixed(0) );
847 xtype: 'ColumnModel',
850 dataIndex : 'location_netsuite_stock_neg',
851 header : 'NS -ve Qty',
854 renderer : function(v,x,r) {
856 if ((r.data.location_qty_neg) *1 != (v*1)) {
857 f = '<span style="color:red;font-weight:bold">{0}</span>';
859 return typeof(v) == 'undefined' ? '...' : String.format(f, (v*1).toFixed(0) );
863 xtype: 'ColumnModel',
866 dataIndex : 'location_value',
869 renderer : function(v) { return typeof(v) == 'undefined' ? '...' : Roo.util.Format.usMoney( v); }
878 activate : function() {
879 _this.itempanel = this;
880 if (_this.itemgrid) {
881 // _this.itemgrid.footer.onClick('first');
889 tableName : 'itemloc',
897 _this.itemgrid = this;
898 //_this.dialog = Pman.Dialog.FILL_IN
899 if (_this.itempanel.active) {
900 // this.footer.onClick('first');
903 rowdblclick : function (_self, rowIndex, e)
905 var rec =this.getDataSource().getAt(rowIndex);
907 var loc = _this.grid.selModel.getSelected();
909 var dt = _this.dateTo.getValue();
911 Pman.Dialog.XtupleInvHistory.show({
912 itemsite_item_id_item_number : rec.data.itemsite_item_id_item_number,
914 location_name : loc.data.location_name,
915 location_descrip : loc.data.location_descrip,
917 invhist_transdate : typeof(dt) == 'string' ? dt : dt.format('Y-m-d')
923 cellclick : function (_self, row, col, e)
926 if ('netsuite_qty' == this.colModel.getDataIndex(col)) {
927 var d = this.ds.getAt(row);
928 var loc = _this.grid.selModel.getSelected();
931 url: baseURL + '/Xtuple/NetsuiteFix/StockCheck',
933 item_id : d.data.itemsite_item_id,
934 location_id : loc.data.location_id
942 autoExpandColumn : 'itemsite_item_id_item_number',
948 beforeload : function (_self, o)
950 var l = _this.grid.selModel ? _this.grid.selModel.getSelected() : false;
954 o.params.location_id = l.data.location_id;
955 o.params._as_of = _this.dateTo.getValue();
956 o.params._with_stock_and_value = 1;
957 o.params._viewtype = _this.itemgrid.viewtype;
961 sortInfo : { field : 'itemsite_item_id_item_number', direction: 'ASC' },
967 url : baseURL + '/Roo/itemsite.php'
972 totalProperty : 'total',
977 'name': 'itemloc_id',
981 'name': 'itemloc_itemsite_id',
985 'name': 'itemloc_location_id',
989 'name': 'itemloc_qty',
993 'name': 'itemloc_expiration',
995 'dateFormat': 'Y-m-d'
998 'name': 'itemloc_consolflag',
1002 'name': 'itemloc_ls_id',
1006 'name': 'itemloc_warrpurc',
1008 'dateFormat': 'Y-m-d'
1014 xtype: 'PagingToolbar',
1017 displayMsg : "{0} - {1} of {2}",
1018 emptyMsg : "No itemloc found",
1023 xtype: 'ColumnModel',
1025 dataIndex : 'itemsite_item_id_item_number',
1028 renderer : function(v) { return String.format('{0}', v); }
1031 xtype: 'ColumnModel',
1034 dataIndex : 'itemsite_qty',
1037 renderer : function(v) { return String.format('{0}', (v*1).toFixed(0)); }
1040 xtype: 'ColumnModel',
1043 dataIndex : 'netsuite_qty',
1047 renderer : function(v,x,r) {
1048 var f= '<span style="color:blue;text-decoration:underline;cursor:pointer;">{0}</span>';
1049 if ((r.data.itemsite_qty) *1 != (v*1)) {
1050 f = '<span style="color:red;font-weight:bold;text-decoration:underline;cursor:pointer;">{0}</span>';
1052 return String.format(f, (v*1).toFixed(0) );
1056 xtype: 'ColumnModel',
1059 dataIndex : 'itemsite_value',
1062 renderer : function(v) { return Roo.util.Format.usMoney(v); }
1069 xtype: 'LayoutRegion',
1073 xtype: 'LayoutRegion',