Runner.buttonEvents['64850'] = function( pageObj, proxy, pageid ) {
	var gid = '64850';
	//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:"question",

    title:"Approve Purchase Request?",

    html:
    "Are you sure you want to approve this Purchase Request?<br><br>" +
    "This action will update the status to <b>APPROVED</b>.",

    showCancelButton:true,

    confirmButtonText:"Approve",

    cancelButtonText:"Cancel",

    confirmButtonColor:"#4caf50",

    cancelButtonColor:"#999",

    reverseButtons:true


}).then(function(result){


    if(result.isConfirmed)
    {

        window.location.href =
        "purchaserequest_list.php?approve_pr=" + id;

    }


});			
		}
	}

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

	$('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 ]} );
	});

};

