
<?php
if ($this->session->flashdata('alert_success')) {
    ?>
<div class="alert alert-success alert-dismissible fade show" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
        <span aria-hidden="true">×</span>
    </button>
    <strong>Success!</strong> <?php echo $this->session->flashdata('alert_success'); ?>
</div>
<?php
$this->session->unset_userdata('alert_success');

}

if ($this->session->flashdata('alert_danger')) {
    ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
        <span aria-hidden="true">×</span>
    </button>
    <strong>Success!</strong> <?php echo $this->session->flashdata('alert_danger'); ?>
</div>
<?php
$this->session->unset_userdata('alert_danger');
}

if ($this->session->flashdata('alert_warning')) {
    ?>
<div class="alert alert-warning alert-dismissible fade show" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
        <span aria-hidden="true">×</span>
    </button>
    <strong>Success!</strong> <?php echo $this->session->flashdata('alert_warning'); ?>
</div>
<?php
$this->session->unset_userdata('alert_warning');
}
?>

<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-body">
                <table id="dmstable" class="table table-striped table-bordered dt-responsive nowrap"
                    style="border-collapse: collapse; border-spacing: 0; width: 100%;">
                    <thead>
                        <tr>
                            <th>COMPANY NAME</th>
                            <th>EMAIL</th>
                            <th>PHONE</th>
                            <th>GST IN</th>
                            <th>ACTION</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        if(isset($records)){
                            foreach($records as $row){ ?>
                            <tr>
                                <td><?= $row->company_name ?></td>
                                <td><?= $row->company_email ?></td>
                                <td><?= $row->company_phone_number; ?></td>
                                <td><?= $row->company_gstin ?></td>
                                <td>
                                    <a href="<?= base_url('settings/company_settings/edit/'.$row->id) ?>" class="btn-sm btn-info" ><i class="ti-pencil-alt"></i></a>
                                </td>
                            </tr>

                           <?php  }
                        }
                        ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">

$('#myTable').DataTable({
    autoFill:false
})
function delete_item(id) {
    Swal.fire({
        title: 'Are you sure?',
        text: "You won't be able to revert this!",
        icon: 'warning',
        showCancelButton: true,
        confirmButtonColor: '#3085d6',
        cancelButtonColor: '#d33',
        confirmButtonText: 'Yes, delete it!'
    }).then(isConfirmed => {
        if (isConfirmed.value) {
            $.ajax({
                url: "<?php echo base_url(); ?>settings/assets/delete/" + id + "/",
                success: function(result) {
                    if (result) {
                        window.location('settings/assets');
                    }
                }
            });

            if (isConfirmed.value) {
                Swal.fire(
                    'Deleted!',
                    'Shop Assets Type has been deleted.',
                    'success'
                );               
            }
        }
    });
}

</script>