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;
}
Example #2
0
 public static function generate_pdf($params, $view, $save = true)
 {
     ob_start();
     include plugin_dir_path(__FILE__) . '../templates/' . $view . '.php';
     $html = ob_get_contents();
     ob_end_clean();
     $mpdf = new \mPDF();
     $mpdf->useOnlyCoreFonts = true;
     $mpdf->WriteHTML($html);
     $filename = time() . '.pdf';
     if (strlen($view) > 3) {
         $filename = strtoupper(substr($view, 0, 3)) . $filename;
     } else {
         $filename = $view . $filename;
     }
     if ($save) {
         $mpdf->Output(DocHandler::pdf_upload_dir($filename), 'F');
         return $filename;
     } else {
         $mpdf->Output();
     }
     exit;
 }
Example #3
0
	table, table th, .last p {
		text-align: right;
	}
	strong, table th {
		color: #0C195D;
	}
	.text-left {
		text-align: left;
	}
	.heading:first-child .row {
		width: 70%;
	}
</style>
<div class="container">
	<div class="row">
		<img class="logo" src="<?=DocHandler::home('/images/logo.png');?>">
	</div>
	<div class="row">
		<div class="heading" style="width:50%;">
			<p style="font-size: 25px; margin-top: 0">RECEIPT</p>
			<div class="row">
				<p>Attention: <?=$username;?></p>
				<p><?=$useraddr;?></p>
			</div>
		</div>
		<div class="heading" style="width:30%;">
			<div class="row">
				<p><strong>Date</strong></p>
				<p><?=$invoicedate;?></p>
			</div>
			<div class="row">
<?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>
    private function generate_docs_and_payment_log($user, $membership, $item_detail, $txid, $quantity=1, $tax='')
    {
        $params = [
            'username' => ucwords("$user->firstname $user->lastname"),
            'useraddr' => $user->address1.' '.$user->address2.' '.$user->suburb.' '.$user->state. ' '. $user->postcode,
            'itemname' => 'Item',
            'itemdetails' => is_array($item_detail) ? $item_detail : array($item_detail),
            'invoicedate' => date('Y-m-d'),
            'subtotal' => $membership->fee,
            'tax' => $tax,
            'total' => $membership->fee,
            'quantity' => $quantity,
            'rate' => $membership->fee,
            'amount' => $membership->fee,
        ];

        $receipt = DocHandler::generate_pdf('receipt', array_merge($params, [
            'formofpayment' => 'Credit Card',
            'paymrefno' => $txid,
            'paymentamount' => $membership->fee,
            'balance' => $membership->fee,

        ]));
        
        $invoice = DocHandler::generate_pdf('invoice', array_merge($params, [
            'invoiceno' => $txid,
            'amtdue' => $membership->fee,
            'duedate' => date('Y-m-d')

        ]));

        $this->log_payment(
                $user->id,
                $txid,
                $user->billing->card_type,
                is_array($item_detail) ? implode('<br/>', $item_detail) : $item_detail,
                $membership->fee,
                $invoice,
                $receipt
            );

        return $receipt;
    }