<?php
/***
Auth: Vastvikta Nishad
Date: 06 Feb 2024
Description:Display and Delete Status
*/
?>
<div class="style2-table">
    <div class="style-title">
        <h3>Status</h3>
        <div class="row">
        <?php $new_status = base64_encode('new_status');?>
        <div class="col-sm-2" style="text-align: end;">
                <a href="admin_index.php?token=<?php echo $new_status;?>" class="button-orange1">New Status</a>
            </div>
        </div>    
    </div>
    <div id="success"></div>
    <form name="frmService" action="" method="post">
        <div class="table" id="SRallview"> 
            <div class="">
                <div class="div2">
                    <table class="tableview tableview-2" id="admin_table">
                        <thead>
                            <tr class="background">
                                <td align="left" width="5%">S.No.</td>
                                <td align="left">Status</td>
                                <td align="left">Created By</td>
                                <td align="left">Created On</td>
                                <td align="left" width="5%">Action</td>
                            </tr>
                           <tbody>
                           <?php
                             $result = view_ticketstatus(); // Assuming view_ticketstatus() is a function to fetch status data
                             if (mysqli_num_rows($result) == 0) {
                                echo '<tr><td colspan="5" align="center" class="contentred">No records found!</td></tr>';
                             } else {
                                $count = 1;
                                while ($row_status = mysqli_fetch_array($result)) {
                                    $new_status = base64_encode('new_status');
                                    $id = base64_encode($row_status['id']);
                                    ?>
                                    <tr>
                                        <td align="left"><?php echo $count; ?></td>
                                        <td align="left"><?php echo $row_status['ticketstatus']; ?></td>
                                        <td align="left"><?php echo displayagentname($row_status['createdby']); ?></td>

                                        <td align="left"><?php echo $row_status['createdon']; ?></td>
                                        <td>
                                            <a href='javascript:void(0)' onclick="window.location.href='admin_index.php?token=<?php echo $new_status ;?>&id=<?= $id ?>';">
                                                <img src="<?=$SiteURL?>public/images/edit-icon.png" border="0" alt="Edit" />
                                            </a>
                                            <a href='javascript:void(0);' data-id="<?= $row_status['id'] ?>" class="status_delete">
                                            <img src="<?php echo $SiteURL?>public/images/delete-icon.png" border="0"  alt="delete">
                                            </a>
                                        </td>
                                    </tr>
                                    <?php
                                    $count++;
                                }
                             }
                             ?>
                            </tbody>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
        <input type="hidden" name="Action" />
        <input type="hidden" name="I_ServiceID" />
    </form>
</div>