function redirect_to_file($redirect_to, $request)
{
    $referer = parse_url($_SERVER['HTTP_REFERER']);
    if (isset($referer['query'])) {
        $parts = explode('=', $referer['query']);
        if ($parts[0] === 'file') {
            return DocHandler::request_url($parts[1]);
        }
    }
    return $redirect_to;
}
<?php
	$payment_histories = $this->view_vars['object']->payment_histories;
	$data = '';
	$pdficon = amac_mp_home('/app/public/img/pdf_icon_mini.gif');
	foreach ($payment_histories as $ph) 
	{
		$invoice = DocHandler::request_url($ph->invoice);
		$receipt = DocHandler::request_url($ph->receipt);
		$data .= 
			"<tr>
				<td>$ph->date</td>
				<td>$ph->trx_id</td>
				<td>$ph->item</td>
				<td>$ph->card</td>
				<td>$ph->charge</td>
				<td>$ph->payment</td>
				<td>$ph->balance</td>
				<td><a target='_blank' href='{$invoice}'><img src='$pdficon'></a></td>
				<td><a target='_blank' href='{$receipt}'><img src='$pdficon'></a></td>
			</tr>";
	}
?>
<div class="row">
	<hr/>
	<h2>Payment History</h2>
	<table class="mp_payment_history">
		<thead>
			<tr>
				<th>Date</th>
				<th>Transaction No</th>
				<th>Item</th>