File "location-view.php"

Full path: /home/fsibplc/public_html/admin/location-view.php
File size: 4.57 B (4.57 KB bytes)
MIME-type: text/x-php
Charset: utf-8

Download   Open   Edit   Advanced Editor   Back

<?php

include('config/dbcon.php');
include('authentication.php');
//session_start();

include('include/header.php');
?>

<div class="container-fluid px-4">

    <div class="row mt-4">
        <div class="col-md-12">
            <?php include('message.php'); ?>
            <div class="card">
                <div class="card-header">
                    <h4>View Location<a href="location-add.php" class="btn btn-primary float-end">Add Location</a></h4>

                </div>
                <div class="card-body">


                    <div class="table-responsive">

                        <table class="table table-bordered" id="example" width="100%" cellspacing="0">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>Name</th>
                                    <th>Type</th>
                                    <th>Edit</th>
                                    <?php if ($_SESSION['auth_role'] == 2|| $_SESSION['auth_role'] == 1 && $u['user_name'] == 'Card Division') : ?>
                                        <th>Delete</th>
                                    <?php endif; ?>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                
                                if( $_SESSION['auth_role'] == 1 && $u['user_name'] == 'Card Division'){
                                    $location = "SELECT * FROM location where type in ('atm','CRM')";
                                }else if( $_SESSION['auth_role'] == 1 && $u['user_name'] == 'GSD Division'){
                                    $location = "SELECT * FROM location where type in ('collection booth','branch','sub branch')";    
                                }else if( $_SESSION['auth_role'] == 1 && $u['user_name'] == 'ADC Division'){
                                    $location = "SELECT * FROM location where type in ('agent')";
                                }else{
                                    $location = "SELECT * FROM location";
                                }
                                
                                
                                $location_run = mysqli_query($con, $location);

                                if (mysqli_num_rows($location_run) > 0) {
                                    foreach ($location_run as $item) {
                                ?>
                                        <tr>
                                            <td><?= $item['id']; ?></td>
                                            <td><?= $item['br_name']; ?></td>
                                            <td><?= $item['type']; ?></td>
                                           
                                            <td><a href="location-edit.php?id=<?= $item['id']; ?>& type=<?= $item['type']; ?>" class="btn btn-info">EDIT</a></td>

                                            <?php if ($_SESSION['auth_role'] == 2|| $_SESSION['auth_role'] == 1 && $u['user_name'] == 'Card Division') : ?>
                                                <td>
                                                    <form action="code-superadmin.php" method="POST">
                                                        <button type="submit" name="location_delete" value="<?= $item['id'] ?>" class="btn btn-danger" onclick='return checkDelete()'>DELETE</button>
                                                    </form>
                                                </td>
                                            <?php endif; ?>
                                        </tr>
                                    <?php
                                    }
                                } else {
                                    ?>
                                    <tr>
                                        <td colspan="5">No Rectord Found</td>
                                    </tr>

                                <?php
                                }
                                ?>



                            </tbody>

                        </table>
                    </div>




                </div>

            </div>

        </div>

    </div>

</div>
<script type="text/javascript">
        function checkDelete(){
            return confirm('Are you sure you want to delete this record?');
        }
</script>
<?php
include('include/footer.php');

include('include/script.php');

?>