<?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($_GET['ref'])){ }else{ 
die(
"
<div class='alert alert-danger'> Error 101. Try again.</div>
"
);
}
$ref = RMC($_GET['ref']); //$ref = base64_decode($ref); 
$sql25="SELECT * from j_notifications WHERE 
j_deleted < 1 AND j_user_id='".$id."' AND j_id='".$ref."'
|| j_deleted < 1 AND j_user_id='*' AND j_id='".$ref."'
order by j_id desc limit 1
"; //  
$result25 = runSQL($sql25);
while($row = mysqli_fetch_array($result25)){
    //read message 
    $read_id = RMC("".$row['j_read'].",'".$id."'");
    //$read = "".$row['j_read'].",".$id."";
    if(strpos($row['j_read'],"'$id'") === false){
        $sql2 = "UPDATE j_notifications SET j_read='".$read_id."' WHERE 
        j_deleted < 1 AND j_id='".$ref."'";
        $result2 = runSQL($sql2);  
    }
	$row['j_message'] = str_replace('{{name}}', $name, $row['j_message']);
	$row['j_message'] = str_replace('{{email}}', $email, $row['j_message']);
	$row['j_message'] = str_replace('{{phone}}', $phone, $row['j_message']);
	$row['j_message'] = str_replace('{{username}}', $username, $row['j_message']);
	$row['j_message'] = str_replace('{{company}}', $company, $row['j_message']);
	$row['j_message'] = str_replace('{{company_motto}}', $company_motto, $row['j_message']);
	$row['j_message'] = str_replace('{{company_address}}', $company_address, $row['j_message']);
	$row['j_message'] = str_replace('{{company_email}}', $company_email, $row['j_message']);
	$row['j_message'] = str_replace('{{company_phone}}', $company_phone, $row['j_message']);
	
    /*
    if($row['j_user_id']!=='*'){
        if($row['j_read']!=='1'){
            //ready notify
            $sql2 = "UPDATE j_notifications SET j_read='1' WHERE 
            j_deleted < 1 AND j_user_id='".$id."' AND j_id='".$ref."'";
            $result = runSQL($sql2); 
        }
    }elseif($row['j_user_id']=='*'){
        $read = "".$row['j_read'].",".$id."";
        $sql2 = "UPDATE j_notifications SET j_read='".$read."' WHERE 
        j_deleted < 1 AND j_id='".$ref."'";
        $result = runSQL($sql2);   
    }
    */
?>

<div class="d-lg-flex align-items-center justify-content-between">
    <div class="media align-items-center m-b-15">
         
        <div class="avatar avatar-md nSender">
            <span>
            <?php echo $short_name; ?>
            </span>
        </div>
        <div class="m-l-10">
            <h6 class="m-b-0"><?php echo $name; ?></h6>
            <span class="text-muted font-size-13">To: <?php echo $email; ?></span>
        </div>
    </div>
    <div class="d-flex align-items-center m-b-15 p-l-30">
        <span class="text-gray m-r-15"><?php echo time_ago($row['j_date']); ?></span>
        
        <?php 
        /*
        <a class="text-gray font-size-18 m-r-20">
            <i class="fas fa-reply"></i>
        </a>
        <a class="text-gray font-size-18 m-r-20">
            <i class="far fa-star"></i>
        </a>
        <a class="text-gray font-size-18 m-r-20">
            <i class="far fa-trash-alt"></i>
        </a>
        */
        ?>
    </div>
</div>
<div class="m-t-30 p-h-30" style="font-size:12px;" >
    <h4 style="font-size:13px;"><?php echo $row['j_subject']; ?></h4>
    <div class="m-t-20">
         <p>
            <?php echo DRMC_NOTIFY($row['j_message']);?>
        </p>
    </div>
    
    <?php 
    /*
    <div class="m-t-30">
        <a class="file" href="" style="min-width: 200px">
            <div class="media align-items-center">
                <div class="m-r-15 font-size-30">
                    <i class="anticon anticon-file-pdf text-danger"></i>
                </div>
                <div>
                    <h6 class="mb-0">Prospectus.doc</h6>
                    <span class="font-size-13 text-muted">1MB</span>
                </div>
            </div>
        </a>
        <a class="file" href="" style="min-width: 200px">
            <div class="media align-items-center">
                <div class="m-r-15 font-size-30">
                    <i class="anticon anticon-file-excel text-success"></i>
                </div>
                <div>
                    <h6 class="mb-0">Financial_Report.xls</h6>
                    <span class="font-size-13 text-muted">652KB</span>
                </div>
            </div>
        </a>
    </div>
    */
     ?>
    
    
</div>

<?php } ?>