<?php
ob_start();
session_start();
error_reporting(0);
include("../config/theconfig.php");
include("header.php");

if(!(isset($_SESSION['customerid']))) {
    header('Location: login.php?error=nologin');
}
?>
<body data-sidebar="dark">

    <div id="layout-wrapper">
        <?php include'header.php' ?>


        <div class="main-content">

            <div class="page-content">
                <div class="container-fluid">

                    <div class="row">
                        <div class="col-12">
                            <div class="page-title-box d-sm-flex align-items-center justify-content-between">
                                <h4 class="mb-sm-0 font-size-18">Bank Transfer</h4>

                                <div class="page-title-right">
                                    <ol class="breadcrumb m-0">
                                        <li class="breadcrumb-item"><a href="javascript: void(0);">Dasboard</a></li>
                                        <li class="breadcrumb-item active">Bank Transfer</li>
                                    </ol>
                                </div>

                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-xl-12">
                            <div class="card">
                                <div class="card-body">
                                    <h5 class="card-title">Failed Transaction</h5>


                                    <div class="row">

                        <div class="col-xl-12">

                            <div class="dt-module">

                                <div class="dt-module__sidebar">

                                    <div class="dt-module__sidebar-header border-bottom">
                                        <div class="d-none d-md-flex align-items-center">
                                            <i class="icon icon-open-mail icon-1x mr-3 text-dark"></i>
                                            <span class="h3 mb-0">Messages</span>
                                        </div>

                                        <div class="quick-menu-list d-md-none">

                                            <form class="search-box d-md-none">
                                                <input class="form-control" type="search" id="address" name="address"
                                                        placeholder="Search in app...">
                                                <button type="submit" class="search-icon"><i
                                                                class="icon icon-search icon-lg"></i></button>
                                            </form>
                                            <a href="javascript:void(0)" class="quick-menu d-none d-md-block"
                                               data-toggle="mdrawer" data-target="#drawer-search-bar"><i
                                                                class="icon icon-search"></i></a>
                                            <a href="javascript:void(0)" class="quick-menu" data-open="compose"><i
                                                                class="icon icon-editors"></i></a>
                                            <a href="javascript:void(0)" class="quick-menu" data-toggle="mdrawer"
                                               data-target="#drawer-notifications"><i
                                                                class="icon icon-notification2"></i></a>
                                            <a href="javascript:void(0)" class="quick-menu d-md-none"
                                               data-toggle="msidebar-content"><i class="icon icon-menu"></i></a>
                                        </div>
                                        </div>
                                    <div class="dt-module__sidebar-content ps-custom-scrollbar">

                                        <div class="action-area mt-5 mb-7 d-none d-md-block">
                                            <a href="javascript:void(0)"
                                               class="btn btn-shadow btn-default compose-btn btn-rounded"
                                               data-open="compose">
                                                <i class="icon icon-editors icon-fw mr-2"></i>Compose</a>
                                        </div>
                                        <ul class="dt-module-side-nav">

                                            <li class="dt-module-side-nav__header">
                                                <span class="dt-module-side-nav__text">main</span>
                                            </li>
                                            <li class="dt-module-side-nav__item active">
                                                <a href="javascript:void(0)" class="dt-module-side-nav__link">
                                                    <i class="icon icon-inbox icon-fw icon-lg"></i>
                                                    <span class="dt-module-side-nav__text">Inbox</span> </a>
                                            </li>
                                            <li class="dt-module-side-nav__item">
                                                <a href="sent.php" class="dt-module-side-nav__link">
                                                    <i class="icon icon-send icon-fw icon-lg"></i>
                                                    <span class="dt-module-side-nav__text">Sent</span> </a>
                                            </li>
                                            </ul>
                                        </div>
                                    </div>
                                <div class="dt-module__container">

                                    <div class="dt-module__header d-none d-md-flex">

                                        <form class="search-box ml--15">
                                            <input class="form-control border-0 shadow-none bg-focus form-control-sm"
                                                   placeholder="Search in app..." value=""
                                                   type="search"> <span class="search-icon"><i
                                                            class="icon icon-search icon-lg"></i></span>
                                        </form>
                                        </div>
                                    <div class="dt-module__content ps-custom-scrollbar">

                                        <div class="dt-module__content-inner">

                                            <div class="px-1 pb-4 border-bottom border-width-2 mb-1 mt--5">
                                                <div class="dropdown">


                                                    <a href="#" class="dropdown-toggle text-dark" data-toggle="dropdown"
                                                       aria-haspopup="true" aria-expanded="false"> Inbox </a>
                                                    </div>
                                                </div>

                                            <div class="dt-module__list">

<?php
while($row = mysqli_fetch_array($result)) {
    $rid = htmlspecialchars($row['senderid']);
    $recid = '';
    if (!($rid == 'admin')) {
        // Use a prepared statement to prevent SQL injection
        $stmt = mysqli_prepare($con, "SELECT * FROM customers WHERE customerid=?");
        mysqli_stmt_bind_param($stmt, "s", $rid);
        mysqli_stmt_execute($stmt);
        $rres = mysqli_stmt_get_result($stmt);
        $rresarr = mysqli_fetch_array($rres);
        $recid = htmlspecialchars($rresarr['firstname'] . " " . $rresarr['lastname']);
        mysqli_stmt_close($stmt);
    } else {
        $recid = htmlspecialchars($rid);
    }
    
    // Sanitize variables before echoing
    $mailid = htmlspecialchars($row['mailid']);
    $subject = htmlspecialchars($row['subject']);
    $mdatetime = htmlspecialchars($row['mdatetime']);

    echo " <div class='dt-module__list-item'>


                                                        <div class='dt-checkbox dt-checkbox-icon dt-checkbox-only mr-5'>
                                                            <input id='icon-checkbox-1' type='checkbox'>
                                                            <label class='font-weight-light dt-checkbox-content'
                                                                    for='icon-checkbox-1'>
                                                                <span class='unchecked'><i
                                                                                class='icon icon-box-o icon-fw icon-xl'></i></span>
                                                                <span class='checked'><i
                                                                                class='icon icon-box-check-o icon-fw icon-xl text-primary'></i></span>
                                                            </label>
                                                        </div>
                                                        <div class='dt-checkbox dt-checkbox-icon dt-checkbox-only mr-5'>

                                                        </div>
                                                        <img class='dt-avatar mr-4' src='../assets/images/icon-account.png'
                                                             alt='Reece Jacklin''>
                                                        <div class='dt-module__list-item-content'
                                                             data-location='readmessage.php?mailid=$mailid'>
                                                             <div class='user-detail'>
                                                                <span class='user-name'>$recid</span>
                                                                <span class='dt-separator-v'>&nbsp;</span>
                                                                <span class='designation'>Subject: $subject</span>
                                                            </div>
                                                            <p class='mb-0 text-light-gray text-truncate'>Message ID Number Is $mailid</p>
                                                        </div>
                                                        <div class='dt-module__list-item-info'>
                                                            <div class='badge-group'>
                                                               <a href='readmessage.php?mailid=$mailid'> <span class='badge bg-dark-blue text-white'>Read Message</span></a>
                                                               <a href='inbox.php?mailid=$mailid'> <span class='badge badge-danger'>Delete Message</a></span>
                                                           </div>
                                                            <span>$mdatetime</span>
                                                        </div>
                                                        </div>
                                                    ";
                                                }
?>

                                            </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>


                                </div>
                                </div>
                            </div>
                        </div>
                    </div> </div>
            <?php include 'footer.php' ?>

        </div>
        </div>
    <script src="assets/libs/jquery/jquery.min.js"></script>
    <script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
    <script src="assets/libs/metismenu/metisMenu.min.js"></script>
    <script src="assets/libs/simplebar/simplebar.min.js"></script>
    <script src="assets/libs/node-waves/waves.min.js"></script>

    <script src="assets/js/app.js"></script>