1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Pman.Tab.XtupleTransfer = new Roo.XComponent({
6 part : ["Xtuple","Transfer"],
7 order : '700-Pman.Tab.XtupleTransfer',
9 parent : 'Pman.Tab.XtupleSales',
10 name : "unnamed module",
21 activate : function() {
24 _this.grid.footer.onClick('first');
32 tableName : 'invhist_transfer',
41 _this.dialog =Pman.Dialog.XtupleTransfer;
42 if (_this.panel.active) {
43 this.footer.onClick('first');
46 rowdblclick : function (_self, rowIndex, e)
48 var sel = _this.postedCombo.getValue();
50 var tdb = baseURL.split('/').pop().split('.').shift();
53 if (sel.match(/^office-/)) {
54 tdb = sel.split('-').pop();
59 if (!_this.dialog) return;
61 var data = this.getDataSource().getAt(rowIndex).data;
65 invhist_transfer_id : data.invhist_transfer_id,
68 _this.grid.footer.onClick('first');
71 rowclass : function (gridview, rowcfg)
73 if(rowcfg.record.data.invhist_transfer_void){
74 rowcfg.rowClass = 'strikethrough';
78 autoExpandColumn : 'invhist_transfer_descrip',
84 beforeload : function (_self, o)
86 var tdb = baseURL.split('/').pop().split('.').shift();
87 o.params._roo_office = tdb;
88 o.params['query[location_id]'] = _this.locCombo.getValue();
89 o.params['query[invhist_transfer_number]'] = _this.searchBox.getValue();
90 var sel = _this.postedCombo.getValue();
93 o.params.invhist_transfer_void = 1;
96 o.params.invhist_transfer_posted = 1;
99 o.params.invhist_transfer_posted = 0;
100 o.params.invhist_transfer_void = 0;
105 if (!sel.match(/^office-/)) {
108 delete o.params['query[location_id]'];
110 o.params._roo_office= sel.replace(/^office-/,'');
111 o.params.cust_to_internalcompany = tdb;
114 var dt = _this.dateSel.getValue();
116 o.params['query[dateSel]'] = typeof(dt) == 'string' ? dt : dt.format('Y-m-d');
124 sortInfo : { field : 'invhist_transfer_transdate', direction: 'DESC' },
129 url : baseURL + '/Xtuple/Roo/invhist_transfer.php'
134 totalProperty : 'total',
139 'name': 'invhist_transfer_id',
143 'name': 'invhist_transfer_transdate',
145 'dateFormat': 'Y-m-d'
148 'name': 'invhist_transfer_number',
152 'name': 'invhist_transfer_from',
156 'name': 'invhist_transfer_to',
160 'name': 'invhist_transfer_descrip',
167 xtype: 'PagingToolbar',
171 displayMsg : "Displaying invhist_transfer{0} - {1} of {2}",
172 emptyMsg : "No invhist_transfer found",
178 click : function (_self, e)
183 Roo.MessageBox.alert("Downloading", "Report is downloading");
198 render : function (_self)
200 _this.searchBox = _self;
202 specialkey : function (_self, e)
204 _this.grid.footer.onClick('first');
212 select : function (combo, record, index)
214 _this.grid.footer.onClick('first');
216 render : function (_self)
218 _this.locCombo = _self;
222 displayField : 'location_name',
224 emptyText : "Select location",
225 fieldLabel : 'location',
226 forceSelection : true,
227 hiddenName : 'location_id',
229 loadingText : "Searching...",
231 name : 'location_id',
233 qtip : "Select location",
234 queryParam : 'query[location_name]',
235 selectOnFocus : true,
236 tpl : '<div class="x-grid-cell-text x-btn button"><b>{location_name}</b> - <b style="color:red">{location_cust_id_char_internalcompany} </b> {location_descrip} </div>',
237 triggerAction : 'all',
239 valueField : 'location_id',
245 beforeload : function (_self, o){
246 o.params = o.params || {};
248 o.params.location_restrict = 0;
253 sortInfo : { direction : 'ASC', field: 'location_name' },
258 url : baseURL + '/Roo/location.php'
265 totalProperty : 'total',
266 fields : [{"name":"id","type":"int"},{"name":"location_name","type":"string"}]
274 select : function (combo, record, index)
276 _this.grid.footer.onClick('first');
278 render : function (_self)
280 _this.postedCombo = _self;
284 displayField : 'title',
286 emptyText : "Select Action",
287 forceSelection : true,
289 loadingText : "Searching...",
293 qtip : "Select Action",
294 selectOnFocus : true,
295 tpl : '<div class="x-grid-cell-text x-btn button"><b>{title}</b> </div>',
296 triggerAction : 'all',
302 xtype: 'SimpleStore',
307 [ 'ALL', 'All Transactions' ],
308 [ 'UNPOSTED', 'Unposted' ],
309 [ 'POSTED', 'Posted' ],
310 [ 'VOIDED', 'Voided' ],
311 [ '--', '-----------------' ]
313 var c = baseURL.split('/').pop().split('.').shift();
314 Roo.each(uiConfig.xtuple_offices, function(o) {
318 ret.push( [ 'office-' + o, "Transfers from " + Pman.Xtuple.offices[o] ] );
326 fields : [ 'code', 'title' ]
333 render : function (_self)
335 _this.dateSel = _self;
337 select : function (combo, date)
339 _this.grid.footer.onClick('first');
351 click : function (_self, e)
353 _this.grid.footer.onClick('first');
357 icon : rootURL + '/Pman/templates/images/search.gif'
363 click : function (_self, e)
365 _this.searchBox.setValue('');
367 _this.locCombo.setValue('');
370 _this.grid.footer.onClick('first');
374 icon : rootURL + '/Pman/templates/images/edit-clear.gif'
387 var sel = _this.postedCombo.getValue();
388 if (sel.match(/^office-/)) {
389 Roo.Msg.alert('Error', "You can create transfers for another office");
393 var s = _this.grid.selModel.getSelected();
395 Roo.MessageBox.alert("Error", "Select a row to copy");
400 url : baseURL + '/Roo/invhist_transfer',
403 timeout : 1200000, //20 minutes...! - big xfer should be 10mins.
405 invhist_transfer_id : s.data.invhist_transfer_id,
408 success : function ()
410 _this.grid.footer.onClick('refresh');
416 cls : 'x-btn-text-icon',
417 text : "Copy Transfer",
418 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
431 var sel = _this.postedCombo.getValue();
432 if (sel.match(/^office-/)) {
433 Roo.Msg.alert('Error', "You can create transfers for another office");
437 if (!_this.dialog) return;
438 _this.dialog.show( { id : 0, _roo_office : baseURL.split('/').pop().split('.').shift() } , function() {
439 _this.grid.footer.onClick('first');
443 cls : 'x-btn-text-icon',
445 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
458 var sel = _this.postedCombo.getValue();
459 if (sel.match(/^office-/)) {
460 Roo.Msg.alert('Error', 'You can not create reversals of transfer from another office');
465 var s = _this.grid.getSelectionModel().getSelected();
467 Roo.Msg.alert('Error', 'Please select a row!');
471 if(s.data.cust_to_internalcompany.length > 0){
472 Roo.Msg.confirm("Comfirm", "Are you sure? <br/>" +
473 "This will create a transfer in the other company dragon, you will need to log to that company and post for it to happen.<br/>" +
474 "Otherwise, it just creates a transfer, and then opens the dialog to edit it.",
480 Roo.Msg.alert('Warnning', 'Sorry, it is comming soon !!');
488 Roo.Msg.confirm("Comfirm", "Are you sure? <br/>" +
489 "You can void a transfer, however if you need to reverse a transfer at a different date press 'yes', and a new transfer will be created.",
495 invhist_transfer_transdate : new Date(),
496 invhist_transfer_arrivaldate : new Date(),
497 invhist_transfer_to : s.data.invhist_transfer_from_location_id,
498 invhist_transfer_to_location_descrip : s.data.invhist_transfer_from_location_descrip,
499 invhist_transfer_from : s.data.invhist_transfer_to_location_id,
500 invhist_transfer_from_location_descrip : s.data.invhist_transfer_to_location_descrip,
501 invhist_transfer_price : s.data.invhist_transfer_price,
502 invhist_transfer_descrip : s.data.invhist_transfer_descrip,
503 _createReverse : s.data.invhist_transfer_id
506 _this.dialog.show( data, function() {
507 _this.grid.footer.onClick('first');
516 cls : 'x-btn-text-icon',
517 text : "Create Reverse Transfer",
518 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
530 var sel = _this.postedCombo.getValue();
531 if (sel.match(/^office-/)) {
532 Roo.Msg.alert('Error', "You can not Post transfer from another office");
535 var s = _this.grid.selModel.getSelected();
537 Roo.MessageBox.alert("Error", "Select a row to post");
541 if(s.data.invhist_transfer_void){
542 Roo.MessageBox.alert("Error", "You can not post a voided transfer");
548 if (s.data.cust_from_internalcompany.length || s.data.cust_to_internalcompany.length) {
549 msg += " Cross company transfer - large orders may take some time, so do not cancel or reload";
554 url : baseURL + '/Roo/invhist_transfer',
557 timeout : 1200000, //20 minutes...! - big xfer should be 10mins.
559 invhist_transfer_id : s.data.invhist_transfer_id,
562 success : function ()
564 _this.grid.footer.onClick('refresh');
570 cls : 'x-btn-text-icon',
572 icon : rootURL + '/Pman/templates/images/mail-close.gif'
584 var sel = _this.postedCombo.getValue();
585 if (sel.match(/^office-/)) {
586 Roo.Msg.alert('Error', "You can not Post transfer from coid office");
590 var s = _this.grid.selModel.getSelected();
592 Roo.MessageBox.alert("Error", "Select a row to void");
596 var voidposted = function(){
598 url : baseURL + '/Roo/invhist_transfer',
603 invhist_transfer_id : s.data.invhist_transfer_id,
606 success : function ()
608 _this.grid.footer.onClick('refresh');
613 var voidunposted = function(){
615 url : baseURL + '/Roo/invhist_transfer',
619 invhist_transfer_id : s.data.invhist_transfer_id,
620 invhist_transfer_void : 1
622 success : function ()
624 _this.grid.footer.onClick('refresh');
630 var posted = s.data.invhist_transfer_posted;
632 Roo.MessageBox.confirm("Confirm", "Are you sure you want to void that",
647 cls : 'x-btn-text-icon',
649 icon : rootURL + '/Pman/templates/images/trash.gif'
655 xtype: 'ColumnModel',
657 dataIndex : 'invhist_transfer_posted',
660 renderer : function(v) {
661 var state = v * 1 > 0 ? '-checked' : '';
663 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
668 xtype: 'ColumnModel',
670 dataIndex : 'invhist_transfer_transdate',
674 renderer : function(v) {
676 return String.format('{0}', v ? Date.parseDate(v.split(' ').shift(),'Y-m-d').format('d/M/Y') : '');
680 xtype: 'ColumnModel',
682 dataIndex : 'invhist_transfer_arrivaldate',
686 renderer : function(v) {
688 return String.format('{0}', v ? Date.parseDate(v.split(' ').shift(),'Y-m-d').format('d/M/Y') : '');
692 xtype: 'ColumnModel',
694 dataIndex : 'invhist_transfer_number',
695 header : 'reference#',
698 renderer : function(v,x,r) {
700 var sel = _this.postedCombo.getValue();
701 var p = baseURL.split('/').pop().split('.').shift().toUpperCase();;
702 if (sel.match(/^office-/)) {
703 p = sel.split('-').pop().toUpperCase();
706 return String.format(r.data.invhist_transfer_void ? '<s>{0}</s>' : '{0}', p+':'+v);
711 xtype: 'ColumnModel',
713 dataIndex : 'invhist_transfer_from_location_name',
717 renderer : function(v,x,r) {
719 var lv = _this.locCombo.getValue();
720 var fmt = lv == r.data.invhist_transfer_from ? '<B>{0}</B>' : '{0}';
721 if (r.data.cust_from_internalcompany.length) {
722 fmt = '<span style="color:red">[Intercompany {1}] ' + fmt + '</span>';
725 return String.format(fmt, v,r.data.cust_from_internalcompany );
729 xtype: 'ColumnModel',
731 dataIndex : 'invhist_transfer_to_location_name',
735 renderer : function(v,x,r) {
737 var lv = _this.locCombo.getValue();
738 var fmt = lv == r.data.invhist_transfer_to ? '<B>{0}</B>' : '{0}';
739 if (r.data.cust_to_internalcompany.length) {
740 fmt = '<span style="color:red">[Intercompany {1}] ' + fmt + '</span>';
743 return String.format(fmt, v, r.data.cust_to_internalcompany);
747 xtype: 'ColumnModel',
750 header : 'Quantity Moved',
752 renderer : function(v,x,r)
755 r.data.cust_to_internalcompany.length
757 (r.data.invhist_transfer_void && r.data.moved_qty == 0)
759 (!r.data.invhist_transfer_void && !r.data.invhist_transfer_posted)
761 return String.format('{0}', v);
764 var diff = v * 1 - r.data.moved_qty * 1;
768 flag = '<span style="color:red"> ({1}) </span>'
771 return String.format('{0}' + flag, v, r.data.moved_qty);
777 xtype: 'ColumnModel',
779 dataIndex : 'invhist_transfer_salesrep_id_salesrep_name',
780 header : 'Sales Rep',
782 renderer : function(v) { return String.format('{0}', v); }
785 xtype: 'ColumnModel',
787 dataIndex : 'invhist_transfer_descrip',
790 renderer : function(v) { return String.format('{0}', v); }