<?php  session_start(); error_reporting(0); 
//if session
if(isset($_SESSION['j_admin']) || isset($_SESSION['j_admin'])){ }else{ 
    die(
    "
    <div class='alert alert-danger'> Error 100. Try again.</div>
    "
    );
}
require_once("../j_conn/url.php");
require_once("../j_conn/dbc.php");
require_once("../j_incs/functions.php");
if(isset($_POST['search'])){ }else{ 
die(
"
<div class='alert alert-danger'> Error 101. Try again.</div>
"
);
}
//exec('sox /mypath/my_audio.amr /mypath/my_audio.mp3');
$name_old = $name;
$phone_old = $phone;
$email_old = $email;
$username_old = $username;
//
$search = RMC($_POST["search"]);  
if(!empty($search) 
 ){ //check if required field is not empty
}else{ die("<div class='alert alert-danger'> Enter Search.</div>");}  
//search now

$sql4="SELECT * from j_pays WHERE 
j_deleted < 1   AND j_kind='WITHDRAW' AND j_package LIKE '%".$search."%'
|| j_deleted < 1  AND j_kind='WITHDRAW' AND j_currency LIKE '%".$search."%'
|| j_deleted < 1  AND j_kind='WITHDRAW' AND j_amount LIKE '%".$search."%'
|| j_deleted < 1  AND j_kind='WITHDRAW' AND j_kind LIKE '%".$search."%'
|| j_deleted < 1  AND j_kind='WITHDRAW' AND j_transact_id LIKE '%".$search."%'
|| j_deleted < 1  AND j_kind='WITHDRAW' AND j_date LIKE '%".$search."%'
|| j_deleted < 1  AND j_kind='WITHDRAW' AND j_account_no LIKE '%".$search."%'
|| j_deleted < 1  AND j_kind='WITHDRAW' AND j_account_name LIKE '%".$search."%'
|| j_deleted < 1  AND j_kind='WITHDRAW' AND j_bank LIKE '%".$search."%'
|| j_deleted < 1  AND j_kind='WITHDRAW' AND j_bal LIKE '%".$search."%'
order by j_id desc limit 50"; //check  

$result4 = runSQL($sql4);
$count = mysqli_num_rows($result4);
if($count<1){
    die("<div class='alert alert-danger'> No record found. Try another search.</div>
    <script> $('[name=search]').css({'border-color': 'brown', 'border-width':'1px', 'border-style':'solid'});</script>
    ");
}
echo ("<script> $('[name=search]').css({'border-color': '#efefef', 'border-width':'1px', 'border-style':'solid'});</script>");
?>


<?php 
$num=1;
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];
	//user profile
	$sql25="SELECT * from j_users WHERE 
	j_id='".$row['j_user_id']."'"; //  
	$result25 = runSQL($sql25);
	$data25 = mysqli_fetch_array($result25);
	$a_username = $data25['j_username'];
	$a_passport = $data25['j_passport'];
	$a_email = $data25['j_email'];
	$a_phone = $data25['j_phone'];
	$a_firstname = $data25['j_firstname'];
	$a_lastname = $data25['j_lastname'];
	$a_name = "$a_firstname $a_lastname"; $a_name = trim($a_name);
?>
<a title="<?php echo amount_w_c($row['j_amount'],$row['j_currency']); ?>" href="<?php echo $dir; ?>receipt?ref=<?php echo $row['j_transact_id']; ?>">
	<div class="t_box <?php if($row['j_type']=='debit'){ echo 'danger';}else{ 
	if($row['j_paid'] > 0){ echo 'success'; }else{ echo '';} } ?>">
	   <div class="date">
		   <i class="anticon anticon-clock-circle"></i> <?php echo time_ago($row['j_date']); ?>
		</div>
		<div class="amount">
			<?php echo amount_w_c($row['j_amount'],$row['j_currency']); ?> 
		</div>
		<div class="desc">
			<?php echo $row['j_desc'];
			if(isset($_SESSION['j_admin'])){
			?> 
			<br/>
			<?php echo $a_name; } ?>
		</div>
	</div>
</a>
<?php } ?>