<?php  session_start(); //error_reporting(0);  
require_once("../j_conn/url.php");
require_once("../j_conn/dbc.php");
require_once("../j_incs/functions.php");
if(!isset($_SESSION['j_admin']) && !isset($_SESSION['j_admin'])){ die("Error"); }
$ref = ($_GET['r']); $ref = RMC($ref); 
if(isset($_SESSION['j_admin'])){
$sql4="SELECT * from j_pays WHERE j_user_id='".$id."' AND j_transact_id='".$ref."' AND j_deleted < 1 order by j_id desc limit 1"; //check 
}else{
$sql4="SELECT * from j_pays WHERE j_deleted < 1 AND j_transact_id='".$ref."' order by j_id desc limit 1"; //check 
}
$result4 = runSQL($sql4);
$count = mysqli_num_rows($result4);
if($count > 0){ }else{
die("<div class='alert alert-danger'> No Access.</div>");
}
while($row = mysqli_fetch_array($result4)){
$cd = get_cd($row['j_currency']);
$currency_in_use = $cd[0];
$currency_code_in_use = $cd[1];
$currency_sort_in_use = $cd[2];
//$ext = substr($file, strrpos($file, '.') + 1);	
//$file = "../j_files/j_img/payments/$file";
//$timex = time();
//$rename = "Proof-of-payment-$ref-$timex.$ext";
$txt='';
$txt .= '
<style>
tbody, th, td{
border: 1px solid #efefef;
}
.text-danger{
color:brown;
}
.text-success{
color:green;
}
.text-primary{
color:#024a99;
}
.text-warning{
color:orange;
}
table{
font-size:12px;
}
thead{
text-transform:uppercase;
}
thead tr{
font-weight:bold;
background-color:#fafafa;color:##000;
}
</style>
<html>
<head><title>TRANSACTION SLIP</title></head>
<body style="background-image:url('.$dir.'j_files/j_img/logo/logo-nav.png);"">
<div id="myFile" style="font-size: 1em;font-family: Arial;padding: 10px;overflow:auto;> 
<p style="text-align: center;">
    <img src="'.$dir.'j_files/j_img/logo/logo-nav.png" alt="'.$company.'" style="width:200px; height:auto;">
</p>         
<h4 align="center"> 
';

if($row['j_paid']<1){
$txt .='
INVOICE
';
}else{
$txt .='
RECEIPT
';
}
$txt .='
</h4>
<ul>
';
	require_once('pdf/a-credit.php'); //design for all
	/* design for each kind
	if($row['j_kind']=='A-Credit'){ require_once('pdf/a-credit.php'); }
	if($row['j_kind']=='A-Debit'){ require_once('a-debit.php'); }
	if($row['j_kind']=='TRANSFER'){ 
		if($row['j_type']=='debit'){ 
			require_once('transfer.php'); 
		}else{
			require_once('transfer-credit.php'); 
		}
	}
	if($row['j_kind']=='ACTIVATION'){ require_once('activation.php'); }
	if($row['j_kind']=='REFERRAL-BONUS'){ require_once('referral-bonus.php'); }
	if($row['j_kind']=='TOP-UP'){ require_once('top-up.php'); }
	if($row['j_kind']=='WITHDRAW'){ require_once('withdraw.php'); }
	if($row['j_kind']=='CRYPTO-BUY'){ require_once('crypto-buy.php'); }
	if($row['j_kind']=='CRYPTO-SELL'){ require_once('crypto-sell.php'); }
	if($row['j_kind']=='CRYPTO-DISBURSEMENT'){ require_once('crypto-disbursement.php'); }
	*/
	$txt .='
</ul> 
<br><br> 
<p style="text-align:center; padding:0px !important; margin:0px; !important;">
<b>'.$company.'</b> - '.$company_motto.'
</p>		
<div class="info" style="background-color: #fafafa; color:#263151; padding: 20px;font-size: 0.8em;text-align: center;">  
<b>Address:</b>
'.$company_address.'
<br>
<b>Email:</b> '.$company_email.'
<br>
<b>Phone:</b> '.$company_phone.'
</div>	
</body>
</html>
';
$timex = time();
$filename ='Receipt-'.$ref.'-'.$timex.'';
ob_start();
require_once("../j_incs/convert-pdf.php");
}
?>