 <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0 text-dark">All Branch</h1>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="<?php echo base_url() ?>admin/admin/dashboard">Dashboard</a></li>
              <li class="breadcrumb-item"><a href="#">Branch</a></li>
              <li class="breadcrumb-item active">All Branch</li>

            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->
    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <div class="card card-default">
          <div class="card-header">
            <h3 class="card-title">View All Branch</h3>
            <div class="card-tools">
              <a href="<?php echo base_url()?>/admin/branch/add_new_branch" class="btn btn-success btn-sm"><i class="fa fa-plus" aria-hidden="true"></i> Add Branch</a>
            </div>
          </div>
            <!-- /.card-header -->
            <div class="card-body">
              <table id="example1" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <th>Branch Photo</th>
                  <th>Branch Name</th>
                  <th>Details</th>
                  <th>Address</th>
                  <!-- <th>Assign Programme</th>-->
                  <th>Status</th>
                  <th></th>
                </tr>
                </thead>
                <tbody>
                <?php $i=1; foreach ($all_atp as $atp):?>
                <tr>
                  <td><img src="<?php echo base_url(); ?><?php echo $atp->user_photo ?>" width="70px"></td>
                  <td>
                    <?php echo $atp->user_business_name ?>
                  </td>
                  <td>
                    Branch ID : <b><?php echo $atp->user_reg_id ?></b>
                    <br/>
                    Owner Name : <b><?php echo $atp->user_name ?></b>
                    <br/>
                    Mob. : <b><?php echo $atp->user_mobile ?></b>
                    <br/>
                    Email : <b><?php echo $atp->user_email ?></b>
                    <br/>
                    Joining Date : <b><?php echo date('d-m-Y', strtotime($atp->user_created_at)); ?></b>
                    <br/>
                    Qulification : <b><?php echo $atp->user_qualification ?></b>
                    <br/>
                    Wallet Bal. : <span class="badge badge-info"><?php echo $atp->user_wallet_balance ?></span>
                    <br/>
                    Online : 
                    <?php if($atp->user_is_online == 0):?>
                      <span class="badge badge-danger">No</span>
                    <?php else:?>
                      <span class="badge badge-success">Yes</span>
                    <?php endif;?>



                    <br/>
                    <?php 
                      // $this->db->where('kyc_details_atp_id', $atp->user_id);
                      // $kyc_details = $this->db->get('atp_business_kyc_details')->row();
                      // if(!$kyc_details)
                      // {
                      //   $opt = '<span class="badge badge-danger">Not Set</span>';
                      // }
                      // elseif(check_kyc_by_atp_id($atp->user_id) > 7)
                      // {
                      //   $opt = '<span class="badge badge-danger">Reject</span>';
                      // }
                      // elseif(check_kyc_by_atp_id($atp->user_id) < 7)
                      // {
                      //   $opt = '<span class="badge badge-warning">Pending</span>';
                      // }
                      // elseif(check_kyc_by_atp_id($atp->user_id) == 7)
                      // {
                      //   $opt = '<span class="badge badge-success">Approved</span>';
                      // }
                    ?>
                    <!-- KYC : <?php //echo $opt; ?> -->
                  </td>
                  <td><?php echo $atp->user_village ?>, <?php echo $atp->user_taluka ?>, <?php echo $atp->user_block ?>, <?php echo $atp->user_dist ?>, <?php echo $atp->user_state ?> - <?php echo $atp->user_pin_code ?></td>
                  <!-- <td>
                    <?php 
                    // foreach (json_decode($atp->user_assign_programm) as $key => $user_assign_programm) 
                    // {
                    //   $this->db->select('cp_name, cp_type');
                    //   $this->db->where('cp_id', $user_assign_programm);
                    //   $cp_name = $this->db->get('course_programm')->row();
                    //   if($cp_name->cp_type == 1)
                    //   {
                    //     echo '<span class="badge badge-warning">'.$cp_name->cp_name.'</span><br/>';
                    //   }
                    //   else
                    //   {
                    //     echo '<span class="badge badge-success">'.$cp_name->cp_name.'</span><br/>';
                    //   }
                      
                    // }
                    ?>
                  </td> -->
                  <td>
                    <!-- Auth Key : <?php //echo $atp->user_auth_key; ?> -->
                    <!-- <br/> -->
                    <?php if($atp->user_status == 1):?>
                      <span class="badge badge-success">Active</span>
                    <?php elseif($atp->user_status == 2):?>
                      <span class="badge badge-warning">Ban</span>
                    <?php elseif($atp->user_status == 3):?>
                      <span class="badge badge-warning">Ren. Amt. Pending</span>
                    <?php elseif($atp->user_status == 4):?>
                      <span class="badge badge-warning">Reg. Amt Pending</span>
                    <?php else:?>
                      <span class="badge badge-danger">Deactive</span>
                    <?php endif;?>
                  </td>
                  <td>
                    <div class="input-group mb-3">
                      <div class="input-group-prepend">
                        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                        Action
                        </button>
                        <div class="dropdown-menu">
                            <a class="dropdown-item" onclick="return confirm('Are you sure?')" href="<?php echo base_url(); ?>/admin/admin/login/<?php echo $atp->user_id ?>"><i class="fas fa-sign-in-alt"></i>&nbsp;&nbsp;Login</a>
                            <div class="dropdown-divider"></div>
                          <?php if($atp->user_status != 1): ?>
                            <a class="dropdown-item" href="<?php echo base_url(); ?>/admin/branch/change_status/<?php echo $atp->user_id ?>/1"><i class="fas fa-check"></i>&nbsp;&nbsp;Approve</a>
                            <div class="dropdown-divider"></div>
                          <?php else: ?>
                            <a class="dropdown-item" href="<?php echo base_url(); ?>/admin/branch/change_status/<?php echo $atp->user_id ?>/0"><i class="fas fa-times"></i>&nbsp;&nbsp;Deactive</a>
                            <div class="dropdown-divider"></div>
                          <?php endif;?>
                          <?php if($atp->user_status != 2): ?>
                            <a class="dropdown-item" href="<?php echo base_url(); ?>/admin/branch/change_status/<?php echo $atp->user_id ?>/2"><i class="fas fa-ban"></i>&nbsp;&nbsp;Ban</a>
                            <div class="dropdown-divider"></div>
                          <?php endif;?>
                          <a class="dropdown-item" onclick="open_money_modal(<?php echo $atp->user_id ?>)" href="javascript:void(0)"><i class="fas fa-rupee-sign"></i>&nbsp;&nbsp;Send Money</a>
                          <div class="dropdown-divider"></div>
                          <a class="dropdown-item" href="<?php echo base_url(); ?>/admin/branch/edit_branch/<?php echo $atp->user_id ?>"><i class="fas fa-edit"></i>&nbsp;&nbsp;Edit</a>
                          <?php if($kyc_details): ?>
                            <div class="dropdown-divider"></div>
                            <a class="dropdown-item" href="<?php echo base_url(); ?>/admin/branch/view_kyc/<?php echo $atp->user_id ?>"><i class="fas fa-eye"></i>&nbsp;&nbsp;Branch KYC</a>
                          <?php endif;?>
                        </div>
                      </div>
                    </div>
                  </td>
                </tr>
                <?php $i++; ?>
                <?php endforeach; ?>
                </tbody>
              </table>
            </div>
          </div>
      </div><!--/. container-fluid -->
    </section>
    <!-- /.content -->
  </div>
<script type="text/javascript">
function open_money_modal(id) 
{
  $('#money_modal').modal('show');
  $('#atp_id').val(id)
}
</script>

<div class="modal fade" id="money_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Send Money</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <?php echo form_open(base_url().'admin/atp/add_manual_money');?>
        <div class="modal-body">
            <div class="form-group">
              <label class="col-form-label">Amount</label>
              <input type="number" class="form-control" required placeholder="Enter Amount" name="amount">
            </div>
            <input name="atp_id" id="atp_id" type="hidden">
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
          <button type="submit" class="btn btn-primary">Send</button>
        </div>
      <?php echo form_close();?>
    </div>
  </div>
</div>