Made th evendor payouts manager more intuitive and easy to use.

This commit is contained in:
Martin Kamerbeek 2009-10-23 15:11:07 +00:00
parent 22d2ab34cc
commit c078998fa2
3 changed files with 76 additions and 24 deletions

View file

@ -588,16 +588,26 @@ Returns the status to which the item(s) are set.
=cut
sub www_setPayoutStatus {
my $class = shift;
my $session = shift;
my $class = shift;
my $session = shift;
my ( $form, $db ) = $session->quick( qw{ form db } );
my $admin = WebGUI::Shop::Admin->new($session);
return $session->privilege->adminOnly() unless ($admin->canManage);
my @itemIds = $session->form->process('itemId');
my $status = $session->form->process('status');
my $status = $form->process('status');
return "error: wrong status [$status]" unless isIn( $status, qw{ NotPaid Scheduled } );
my @itemIds;
if ( $form->process( 'all' ) ) {
@itemIds = $session->db->buildArray( 'select itemId from transactionItem where vendorPayoutStatus = ?' , [
( $status eq 'NotPaid' ) ? 'Scheduled' : 'NotPaid'
] );
}
else {
@itemIds = $form->process('itemId');
}
foreach my $itemId (@itemIds) {
my $item = WebGUI::Shop::TransactionItem->newByDynamicTransaction( $session, $itemId );
return "error: invalid transactionItemId [$itemId]" unless $item;

View file

@ -1594,6 +1594,24 @@ our $I18N = {
context => q|Table heading in the vendor payout manager.|,
},
'vp select vendor' => {
message => q|Please select a vendor from the list above to manage individual payouts.|,
lastUpdated => 0,
context => q|Message in the vendor payouts manager when no vendor has been selected.|,
},
'vp vendors' => {
message => q|Vendors|,
lastUpdated => 0,
context => q|Label for the vendors section of the vendor payouts manager|,
},
'vp payouts' => {
message => q|Payouts|,
lastUpdated => 0,
context => q|Label for the vendors section of the vendor payouts manager|,
},
'vp item id' => {
message => q|Item ID|,
lastUpdated => 0,

View file

@ -12,7 +12,7 @@ WebGUI.VendorPayout = function ( containerId ) {
'schedule all button', 'deschedule all button', 'submit scheduled payouts button',
'vendor id', 'vendor name', 'scheduled payout amount', 'not scheduled payout amount',
'vp item id', 'vp item title', 'vp item price', 'vp item quantity', 'vp item payout amount',
'vp item payout status', 'vp select vendor'
'vp item payout status', 'vp select vendor', 'vp vendors', 'vp payouts'
]
},
onpreload : {
@ -36,7 +36,7 @@ WebGUI.VendorPayout.prototype.initialize = function (aaa, bbb,ccc,ddd) {
var vendor = document.createElement( 'fieldset' );
var vendorLegend = document.createElement( 'legend' );
vendor.appendChild( vendorLegend ).innerHTML = 'Vendors';
vendor.appendChild( vendorLegend ).innerHTML = this.i18n( 'vp vendors' );
vendor.appendChild( this.vendorTable );
vendor.appendChild( this.vendorButtons );
@ -48,23 +48,31 @@ WebGUI.VendorPayout.prototype.initialize = function (aaa, bbb,ccc,ddd) {
var payout = document.createElement( 'fieldset' );
var payoutLegend = document.createElement( 'legend' );
payout.appendChild( payoutLegend ).innerHTML = 'Payouts';
payout.appendChild( payoutLegend ).innerHTML = this.i18n( 'vp payouts' );
payout.appendChild( this.payoutTable );
payout.appendChild( this.payoutButtons );
this.container.appendChild( payout );
// (De)schedule buttons
this.scheduleAllPayoutsButton = new YAHOO.widget.Button( {
this.scheduleAllPayoutsButton = new YAHOO.widget.Button( {
label : this.i18n( 'schedule all button' ),
container : this.payoutButtons,
disabled : true
} );
this.descheduleAllPayoutsButton = new YAHOO.widget.Button( {
this.descheduleAllPayoutsButton = new YAHOO.widget.Button( {
label: this.i18n( 'deschedule all button' ),
container: this.payoutButtons,
disabled : true
} );
this.scheduleAllVendorsButton = new YAHOO.widget.Button( {
label : this.i18n( 'schedule all button' ),
container : this.vendorButtons
} );
this.descheduleAllVendorsButton = new YAHOO.widget.Button( {
label : this.i18n( 'deschedule all button' ),
container : this.vendorButtons
} );
// Submit button
this.submitPayoutsButton = new YAHOO.widget.Button({ label: this.i18n( 'submit scheduled payouts button' ), container: this.buttonDiv });
@ -119,7 +127,7 @@ WebGUI.VendorPayout.prototype.initVendorList = function () {
this.vendorDataTable.subscribe( "rowClickEvent", function (e) {
var record = this.getRecord( e.target );
obj.currentVendorId = record.getData( 'vendorId' );
obj.currentVendorRow = record;
obj.currentVendorIndex = this.getRecordIndex( record );
obj.refreshItemDataTable();
@ -139,13 +147,20 @@ WebGUI.VendorPayout.prototype.refreshItemDataTable = function () {
} );
}
//----------------------------------------------------------------------------
WebGUI.VendorPayout.prototype.refreshVendorDataTable = function () {
this.vendorDataSource.sendRequest( '', {
success : this.vendorDataTable.onDataReturnUpdateRows, //ReplaceRows,
scope : this.vendorDataTable
} );
}
//----------------------------------------------------------------------------
WebGUI.VendorPayout.prototype.refreshVendorRow = function () {
var obj = this;
this.vendorDataSource.sendRequest( 'vendorId=' + this.currentVendorId, {
// onDataReturnUpdateRows is not available in yui 2.6.0...
success : function ( req, response , payload ) {
this.updateRow( obj.currentVendorRow, response.results[0] );
success : function ( req, response , payload ) {
this.updateRow( obj.currentVendorIndex, response.results[0] );
},
scope : this.vendorDataTable
} );
@ -240,29 +255,38 @@ WebGUI.VendorPayout.prototype.initPayoutDetails = function () {
WebGUI.VendorPayout.prototype.initButtons = function () {
var obj = this;
var updateAll = function ( status ) {
var updateAll = function ( status, bulk ) {
// TODO: Make this range based.
var records = obj.itemDataTable.getRecordSet().getRecords();
var itemIds = new Array;
for (i = 0; i < records.length; i++) {
itemIds.push( 'itemId=' + records[i].getData( 'itemId' ) );
}
var postdata = 'shop=vendor&method=setPayoutStatus&status=' + status;
var postdata = itemIds.join('&');
var url = '?shop=vendor&method=setPayoutStatus&status=' + status;
if ( bulk ) {
postdata += '&all=1';
}
else {
var itemIds = new Array;
for (i = 0; i < records.length; i++) {
itemIds.push( 'itemId=' + records[i].getData( 'itemId' ) );
}
postdata += '&' + itemIds.join('&');
}
var callback = {
success: function (o) {
this.refreshItemDataTable();
this.refreshVendorRow();
bulk ? this.refreshVendorDataTable() : this.refreshVendorRow();
},
scope: obj
};
YAHOO.util.Connect.asyncRequest( 'POST', url, callback, postdata );
YAHOO.util.Connect.asyncRequest( 'POST', '/', callback, postdata );
}
this.scheduleAllPayoutsButton.on( 'click', function () { updateAll( 'Scheduled' ) } );
this.descheduleAllPayoutsButton.on( 'click', function () { updateAll( 'NotPaid' ) } );
this.scheduleAllVendorsButton.on( 'click', function () { updateAll( 'Scheduled', true ) } );
this.descheduleAllVendorsButton.on( 'click', function () { updateAll( 'NotPaid', true ) } );
this.scheduleAllPayoutsButton.on( 'click', function () { updateAll( 'Scheduled' ) } );
this.descheduleAllPayoutsButton.on( 'click', function () { updateAll( 'NotPaid' ) } );
}