 <?php

require ("header.php");

?>


<?php
$delete = false;

if (isset($_GET['del'])) {
    $delId = intval($_GET['del']);

    $stmt = $pdo->prepare("DELETE FROM message WHERE id = :id AND log_id = :log_id");
    $stmt->execute([':id' => $delId, ':log_id' => $id]);

    if ($stmt->rowCount()) {
        $delete = true;
    }
}
?>


                <!-- main header @e -->
                <!-- content @s -->

                <div class="nk-content ">
    <div class="container-fluid">
        <div class="nk-content-inner">
            <div class="nk-content-body">
                <div class="components-preview wide-md mx-auto">

                    <div class="nk-block nk-block-lg">

                        <div class="card card-bordered card-preview">

                            <div class="card-header">
                                <div class="row">
                                    <div class="col-6 text-start">
                                        <h5>OUTBOX</h5>
                                    </div>

                                    <div class="col-6 text-end">
                                        <a href="ticket.php" class="btn btn-sm btn-danger">Write new message</a>
                                    </div>
                                </div>

                            </div>

                            <div class="card-inner">

                                <div wire:id="xMilLc81nroWEch6GNdM" wire:initial-data="{&quot;fingerprint&quot;:{&quot;id&quot;:&quot;xMilLc81nroWEch6GNdM&quot;,&quot;name&quot;:&quot;user.notification.index&quot;,&quot;locale&quot;:&quot;en&quot;,&quot;path&quot;:&quot;notification&quot;,&quot;method&quot;:&quot;GET&quot;,&quot;v&quot;:&quot;acj&quot;},&quot;effects&quot;:{&quot;listeners&quot;:[],&quot;path&quot;:&quot;https:\/\/garantiifinance.com\/notification&quot;},&quot;serverMemo&quot;:{&quot;children&quot;:[],&quot;errors&quot;:[],&quot;htmlHash&quot;:&quot;6902b387&quot;,&quot;data&quot;:{&quot;i&quot;:1,&quot;search&quot;:&quot;&quot;,&quot;page&quot;:1,&quot;paginators&quot;:{&quot;page&quot;:1}},&quot;dataMeta&quot;:[],&quot;checksum&quot;:&quot;aa17769c5755ee22c82ae6b8eadb15698931b30eb6c4f3edaeb0597e32f85ca2&quot;}}">
   


    <div class="table-responsive">
    <table class="table table-hover table-bordered " id='myTable' style="width:100%">

        <thead>
            <tr>
    <th class="cell-fit">#</th>
                <th class="cell-fit">Title</th>
                <th class="cell-fit">Details</th>
                <th class="cell-fit">Date</th>
                <th class="cell-fit">delete</th>
                <th class="cell-fit">Open</th>
</tr>
        </thead>

        
    <?php
$query = "SELECT * FROM message WHERE log_id = :log_id ORDER BY id DESC LIMIT 1000";

$stmt = $pdo->prepare($query);

$stmt->bindParam(':log_id', $id, PDO::PARAM_INT);

$stmt->execute();

$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);

// if (isset($delete)) {
//     echo "<center><span style='color:red'>Successfully deleted mail from inbox<br><br><div class='loader'></div>
//     <meta http-equiv='refresh' content='5; url=inbox.php' /></center>";
// }

foreach ($rows as $row) {
    if ($row['status'] == 0) {
        echo "
        <tbody>
            <tr>
                <td>1</td>
                <td>" . htmlspecialchars($row['title']) . "</td>
                <td>" . htmlspecialchars(substr($row['msg'], 0, 37)) . " . . . . . . .</td>
                <td>" . htmlspecialchars($row['date']) . "</td>
                <td>
                    <a class='btn btn-danger btn-sm' title='delete' href='outbox.php?del=" . htmlspecialchars($row['id']) . "'>
                        <em class='icon ni ni-delete'></em>
                    </a>
                </td>
                <td>
                    <a class='btn btn-success btn-sm' title='view' href='reply_inbox.php?id=" . htmlspecialchars($row['id']) . "'>
                        <em class='icon ni ni-eye'></em>
                    </a>
                </td>
            </tr>
        </tbody>";
    }
}
?>


        <tfoot>
            <tr>
    <td colspan="6"><div>
    </div>
</td>
</tr>
        </tfoot>




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

<!-- Livewire Component wire-end:xMilLc81nroWEch6GNdM -->
                            </div>

                        </div><!-- .card-preview -->
                    </div> <!-- nk-block -->
                </div><!-- .components-preview -->
            </div>
        </div>
    </div>
</div>

               
               
               
               <?php require ("footer.php") ?>