

<?php 
 $regid = $_REQUEST['regid'];
 $conid = $_REQUEST['conid'];
 $nowdue = date('Y-m-d H:i:s');
 $sth = $db->prepare("SELECT DISTINCT(regst_id) AS regst,con_info_id AS coninfo, sub_matt AS subj,created_reg_trm, 
 info_notes AS msgenote, dueCon AS regdate,info_sts AS stats, title_name AS appoint,recvappnt AS recva,title_id AS ttle ,appntsent AS senderApp 
 FROM tbl_info_register i
 INNER JOIN tbl_con_infos c ON c.reg_info_id = i.regst_id 
 INNER JOIN tbl_title t ON t.title_id = c.recvappnt 
 WHERE i.regst_id ='".$regid."' AND c.con_info_id ='".$conid."'");

 $sth->execute(array());
 $QueStmt = $sth->rowCount();

 if($QueStmt > 0){
     while ($rows = $sth->fetch(PDO::FETCH_ASSOC)) {
        $coninfo = $rows['coninfo'];
        $regst = $rows['regst'];
        $subj =$rows['subj']; 
        $msgenote = $rows['msgenote'];
        $regdate = $rows['regdate'];
        $stats = $rows['stats'];
        $appoint = $rows['appoint'];
        $recva = $rows['recva'];
        $ttle = $rows['ttle'];
        $senderApp = $rows['senderApp'];
        $created_reg_trm=$rows['created_reg_trm'];

    ### SENDER DETAILS ####### 
    $sender = $db->prepare("SELECT * FROM tbl_role r
    INNER JOIN tbl_title t ON t.department_id = r.role_id 
    WHERE t.title_id ='".$recva."'");  
    $sender->execute();

    while($viewSender = $sender->fetch()){

    $rlename = $viewSender['role_name'];
    $tname = $viewSender['title_name'];
    }
    ### END SENDER DETAILS #######

     }
    }
?>
<!-- inbox container -->
<div class="d-flex flex-column flex-grow-1 bg-white">
    <!-- inbox header -->
    <div class="flex-grow-0">
        <!-- inbox button shortcut -->
        <div class="d-flex flex-wrap align-items-center pl-2 pr-3 py-2 px-sm-4 pr-lg-5 pl-lg-0 border-faded border-top-0 border-left-0 border-right-0">
            <div class="flex-1 d-flex align-items-center">
                <a href="<?php echo web_root;?>beam/bm?b=box" class="btn btn-icon rounded-circle mr-2 mr-lg-3">
                    <i class="fa fa-arrow-left fs-lg"></i>
                </a>
                <a href="javascript:void(0);" onclick="window.location.reload(true);" class="btn btn-icon rounded-circle mr-1">
                    <i class="fa fa-redo fs-md"></i>
                </a>
            </div>

            <div class="d-flex flex-wrap">
                <button class="btn btn-default btn-xs"><i class="fa fa-chevron-right fs-md"></i> Forward</button>
            </div>
        </div>
        <!-- end inbox button shortcut -->
    </div>
    <!-- end inbox header -->

    <!-- inbox message -->
    <div class="flex-wrap align-items-center flex-grow-1 position-relative bg-white">
    <div class=" position-absolute pos-top pos-bottom w-100 custom-scroll">
        <div class="d-flex h-100 flex-column">
            <!-- inbox title -->
            <div class="d-flex align-items-center pl-2 pr-3 py-3 pl-sm-3 pr-sm-4 py-sm-4 px-lg-5 py-lg-3 flex-shrink-0">
                <!-- button for mobile -->
                <a href="javascript:void(0);" class="pl-3 pr-3 py-2 d-flex d-lg-none align-items-center justify-content-center mr-2 btn" data-action="toggle" data-class="slide-on-mobile-left-show" data-target="#js-inbox-menu">
                    <i class="fal fa-ellipsis-v h1 mb-0 "></i>
                </a>
                <!-- end button for mobile -->
                <h1 class="subheader-title mb-0 ml-2 ml-lg-5">
                    <?php echo $subj;?>
                </h1>
                <a href="<?php echo web_root;?>beam/bm?b=box"><span class="badge badge-primary ml-2 hidden-sm-down">INBOX</span></a>
                <div class="d-flex position-relative ml-auto">
                    <a href="#" title="starred" class="btn btn-icon ml-1 fs-lg">
                        <i class="fa fa-star color-warning-500"></i>
                    </a>
                    <a href="javascript:void(0);" class="btn btn-icon ml-1 fs-lg" data-toggle="collapse" data-target=".js-collapse">
                        <i class="fa fa-arrows-v"></i>
                    </a>
                </div>
            </div>
            <!-- end inbox title -->
        <div style="display: none;">
            <!-- message -->
            <div id="msg-01" class="d-flex flex-column border-faded border-top-0 border-left-0 border-right-0 py-3 px-3 px-sm-4 px-lg-0 mr-0 mr-lg-5 flex-shrink-0">
                <div class="d-flex align-items-center flex-row">
                    <div class="ml-0 mr-3 mx-lg-3">
                        <img src="img/demo/avatars/avatar-c.png" class="profile-image profile-image-md rounded-circle" alt="Melissa Ayre">
                    </div>
                    <div class="fw-500 flex-1 d-flex flex-column cursor-pointer" data-toggle="collapse" data-target="#msg-01 > .js-collapse">
                        <div class="fs-lg">
                            
                            <span class="fs-nano fw-400 ml-2"></span>
                        </div>
                        <div class="fs-nano">
                           
                        </div>
                    </div>
                    <div class="color-fusion-200 fs-sm">
                        1:00 AM <span class="hidden-sm-down">(12 hours ago)</span>
                    </div>
                    <div class="collapsed-reveal">
                        <a href="javascript:void(0);" class="btn btn-icon ml-1 fs-lg rounded-circle">
                            <i class="fal fa-reply"></i>
                        </a>
                    </div>
                </div>
                <div class="collapse js-collapse">
                    <div class="pl-lg-5 ml-lg-5 pt-3 pb-4">
                        We've taken customer feedback on board and are pleased to announce that the the industry's most recommended and secure option for Two-Factor Authentication (2FA) is now available to use on our site.
                        So, if you've tried our previous 2FA methods and have not been convinced, why not try our new Time-Based One-Time Password (TOTP)? It's super easy to use, and it works with many third-party 2FA apps you might already have on your phone. We're positive you'll love the new improved experience.
                    </div>
                </div>
            </div>
            <!-- end message -->
        </div>

            <!-- message -->
            <div id="msg-03" class="d-flex flex-column border-faded border-top-0 border-left-0 border-right-0 py-3 px-3 px-sm-4 px-lg-0 mr-0 mr-lg-5 flex-shrink-0">
                <div class="d-flex align-items-center flex-row">
                    <div class="ml-0 mr-3 mx-lg-3 width-2">
                        <img src="../img/demo/avatars/beamavatar5.png" class="profile-image profile-image-md rounded-circle" alt="<?php echo $appoint;?>">
                    </div>
                    <div class="fw-500 flex-1 d-flex flex-column cursor-pointer" data-toggle="collapse" data-target="#msg-03 > .js-collapse">
                        <div class="fs-lg">
                            <?php echo $appoint;?>
                            <span class="fs-nano fw-400 ml-2"><?php echo $rlename;?></span>
                        </div>
                        <div class="fs-nano">
                            from <?php echo $title_name;?>
                        </div>
                    </div>
                    <div class="color-fusion-200 fs-sm">
                         <span class="hidden-sm-down">(<?php echo $created_reg_trm;?>)</span>
                    </div>
                    <div class="collapsed-reveal">
                        <a href="javascript:void(0);" class="btn btn-icon ml-1 fs-lg rounded-circle">
                            <i class="fa fa-reply"></i>
                        </a>
                    </div>
                </div>

                <div id="js-msg-1" class="js-collapse">
                    <div class="pl-lg-5 ml-lg-5 pt-3 pb-4 ">
                       <?php echo $msgenote;?> 
                    </div>

                    <div class="row">
                    <?php 
                        $i=0;
                        $select = $db->prepare("SELECT * FROM `tbl_docs` WHERE registID = '".$regst."' ORDER BY doc_id DESC");
                        $select->execute(); 
                        while($row = $select->fetch()){
                            $doc_id = $row['doc_id'];
                            $uploaded_on = $row['uploaded_on'];
                            $docName = $row['docName'];
                            $rec_dpt = $row['rec_dpt'];
                            $usID = $row['usID'];
                            $stts_doc = $row['stts_doc'];
                            $i++;
                            
                            //Hide Extension
                            $file = new SplFileInfo($docName);
                            $ext  = $file->getExtension();
                            //Get File Name
                            $fileName = basename($docName);
                            $fileNameNoExtension = preg_replace("/\.[^.]+$/", "", $fileName);

                            //DOC ICON
                            if($ext == "pdf"){
                               $imgIcon = "pdf.png";
                            }if($ext == 'xls' || $ext == 'xlsx'){
                               $imgIcon = "excel.png";  
                            }if($ext == 'doc' || $ext == 'docx'){
                                $imgIcon = "docx.png";
                            }if($ext == 'ppt' || $ext == 'pptx'){
                                $imgIcon = "pptx.png";
                            }

                            
                            ####### DEPARTMENT #####
                            $dept = $db->prepare('SELECT *FROM tbl_role WHERE role_id = "'.$rec_dpt.'"');
                            $dept->execute();
                            $fDept = $dept->fetch();
                            $role_name = $fDept['role_name'];
                            
                            ###### USER #####
                            
                            $getUser = $db->prepare('SELECT *FROM tbl_user_accounts WHERE user_id = "'.$usID.'"');
                            $getUser->execute();
                            $fUs = $getUser->fetch();
                            $ffirst = $fUs['first_name'];
                            $fLst = $fUs['family_name'];
                    ?>
                        <div class="col-md-offset-2 col-md-2">
                                <div class="panel panel-default bootcards-file">
                                    <div class="list-group">
                                        <div class="list-group-item">
                                            <a href="../docs/<?php echo $docName;?>">
                                            <img src="../img/icon/<?php echo $imgIcon;?>" width="100">
                                            </a>
                                            
                                            <p class="list-group-item-text"><strong> <a href="../docs/<?php echo $docName;?>" style="color: #777;">
                                                <?php echo $fileNameNoExtension;?></a></strong></p>
                                            <!-- <p class="list-group-item-text"><strong>1.5MB</strong></p> -->
                                        </div>
                                    </div>

                            </div>
                        </div>
                        <?php  
                            }
                        ?>
                    </div>


                </div>
            </div>
            <!-- end message -->
        </div>
    </div>
    </div>
    <!-- end inbox message -->

</div>
<!-- end inbox container -->
