<div class="content-wrapper">
  <div class="content">
    <div class="container-fluid">
      <div class="row">
        <div class="col">
          <div class="card card-primary card-outline">
            <div class="card-header">
              <h5 class="m-0"><?php echo $pageTitle; ?> <?php showCreateButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/add", "Create New " . $pageTitle); ?></h5>
            </div>
            <div class="card-body">
              <?php $TableData = $this->db->query("select * from tbl_branches where status<>-1")->result(); ?>
              <table class="table table-bordered table-striped dataTable">
                <thead>
                  <tr>
                    <th><?php myLang("Company Name") ?></th>
                    <th><?php myLang("Company Address") ?></th>
                    <th><?php myLang("VAT Applicable") ?></th>
                    <th><?php myLang("PAN #") ?></th>
                    <th><?php myLang("Remarks") ?></th>
                    <th>Action</th>
                  </tr>
                </thead>
                <tbody>
                  <?php $a = 0;
                  foreach ($TableData as $TableRow) : $a++; ?>
                    <?php foreach ($TableRow as $cols) : $id = $cols;
                      break;
                    endforeach; ?><tr class="bg-<?php echo ($TableRow->status == 0) ? "danger" : "success"; ?>">
                      <td><?php echo $TableRow->branch_name; ?></td>
                      <td><?php echo $TableRow->branch_address; ?></td>
                      <td><?php echo ($TableRow->vat == 1) ? "Yes" : "No"; ?></td>
                      <td><?php echo $TableRow->pan; ?></td>
                      <td><?php echo $TableRow->remarks; ?></td>
                      <td>
                        <?php if ($TableRow->status == 0) : ?>
                          
                          <a href="<?php echo site_url($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/select/$id"); ?>" class="btn btn-primary btn-xs"><i class="fas fa-check"></i> Select Company</a>
                        <?php endif; ?>
                        <a href="<?php echo site_url($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/edit/$id"); ?>" class="btn btn-success btn-xs"><i class="fas fa-edit"></i> Edit</a>
                        <a onClick="javascript:doDelete(<?php echo $id; ?>);" class="btn btn-danger btn-xs"><i class="fas fa-trash"></i> Delete</a>
                      </td>
                    </tr>
                  <?php endforeach; ?>
                <tbody>
              </table>
              <script>
                function doDelete(id) {
                  if (confirm('Are you sure to delete?')) {
                    window.location = '<?php echo site_url($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/delete/"); ?>' + id;
                  }
                }
              </script>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>