Runner.buttonEvents['64856'] = function( pageObj, proxy, pageid ) {
	var gid = '64856';
	//register a new button
	pageObj.buttonNames[ pageObj.buttonNames.length ] = gid;
		
	if ( !pageObj.buttonEventBefore[ gid ] ) {
		pageObj.buttonEventBefore[ gid ] = function( params, ctrl, pageObj, proxy, pageid, rowData, row, submit ) {		
			var ajax = ctrl;
			var id = new URLSearchParams(window.location.search).get("editid");


Swal.fire({

    icon:"warning",

    title:"Cancel Purchase Request?",

    html:
    "Are you sure you want to cancel this Purchase Request?<br><br>" +
    "This action cannot be undone.",


    showCancelButton:true,

    confirmButtonText:"Cancel Request",

    cancelButtonText:"Back",

    confirmButtonColor:"#dc3545",

    cancelButtonColor:"#999",

    reverseButtons:true


}).then(function(result){


    if(result.isConfirmed)
    {

        ctrl.submit();

    }
    else
    {

        return false;

    }


});			
		}
	}

	if ( !pageObj.buttonEventAfter[ gid ] ) {
		pageObj.buttonEventAfter[ gid ] = function( result, ctrl, pageObj, proxy, pageid, rowData, row, params ) {
			var ajax = ctrl;
			Swal.fire({

icon:"success",

title:"Purchase Request Cancelled",

text:"The Purchase Request has been cancelled.",

confirmButtonText:"Done"


}).then(function(){

location.reload();

});
		}
	}

	$('a[data-event=' + gid + ']').each( function() {
		if ( $(this).closest('.gridRowAdd').length ) {
			return;
		}
		var rowId = Runner.genId();
		var eventId = gid + "_" + rowId;
		$(this).attr( 'data-event', eventId );
		this.id = this.id + "_" + Runner.genId();
		var buttonObj = new Runner.form.Button({
			id: eventId,
			btnName: gid
		});
		buttonObj.init( {args: [ pageObj, proxy, pageid ]} );
	});

};

