<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<?php if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest'):?>
<!DOCTYPE html>
<html>
  <head>
    <title>Profil <?php echo html_escape($user->us_name);?></title>
    <?php include_once(VIEWPATH. 'includes/head.php'); ?>
  </head>
  <body>
    <?php include_once(VIEWPATH. 'admin/_navbar.php'); ?>
    <div class="container">
      <ul class="breadcrumb">
        <li><a href="<?php echo site_url();?>"><i class="fa fa-home"></i></a></li>
        <li><a href="<?php echo site_url('admin');?>">Admin Panel</a></li>
        <li><a href="<?php echo site_url('admin/users');?>">Member</a></li>
        <li class="active"><span><?php echo html_escape($user->us_name);?></span></li>
      </ul>
      <div class="row">
        <div class="col-sm-4 col-md-3">
          <?php include dirname(__FILE__).'/_sidebar.php';?>
        </div>
        <div class="col-sm-8 col-md-9">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3><i class="fa fa-user"></i> Profil</h3>
            </div>
            <div class="panel-body">
            <?php else:?>
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true"> &times;</span></button>
              <h4 class="modal-title"><i class="fa fa-user"></i> <?php echo html_escape($user->us_name);?></h4>
            </div>
            <div class="modal-body">
            <?php endif;?>
            <div class="table-responsive">
              <table class="table table-striped">
                <tbody>
                  <tr><td style="width: 140px;">Nama Lengkap</td><td>: <?php echo html_escape($user->us_name) . PHP_EOL;?></td></tr>
                  <tr><td style="width: 140px;">Nama Pengguna</td><td>: <?php echo $user->us_username . PHP_EOL;?></td></tr>
                  <tr><td style="width: 140px;">Email</td><td>: <?php echo (isset($user_set['email_verified']) && $user_set['email_verified'] == 1 ? '<span class="text-success"><i class="fa fa-check-circle"></i></span>' : '<span class="text-danger"><i class="fa fa-times-circle"></i></span>');?> <a href="mailto:<?php echo html_escape($user->us_email);?>"><?php echo html_escape($user->us_email);?></a></td></tr>
                  <tr><td style="width: 140px;">Jenis Kelamin</td><td>: <?php echo str_replace(array('female','male'),array('Perempuan','Laki-laki'),$user->us_gender) . PHP_EOL;?></td></tr>
                  <tr><td style="width: 140px;">Alamat</td><td>: <?php echo html_escape($user->us_location) . PHP_EOL;?></td></tr>
                  <tr><td style="width: 140px;">No. HP</td><td>: <?php echo (isset($user_set['phone_verified']) && $user_set['phone_verified'] == 1 ? '<span class="text-success"><i class="fa fa-check-circle"></i></span>' : '<span class="text-danger"><i class="fa fa-times-circle"></i></span>');?> <a data-toggle="modal" data-target="#myModal" href="<?php echo site_url('admin/sms/kirim?phone=' . $user->us_phone);?>"><?php echo html_escape($user->us_phone);?></a></td></tr>
                  <?php if ($user->us_telegram_id):?>
                  <tr><td style="width: 140px;">Telegram</td><td>: <?php echo $user->us_telegram_username ? '<a href="http://t.me/'.$user->us_telegram_username.'" target="_blank">@'.$user->us_telegram_username.'</a>' : $user->us_telegram_id;?>&nbsp;&nbsp;&nbsp;<a class="btn btn-danger btn-xs" href="<?php echo site_url('admin/users/hapus-telegram/'.$user->us_id);?>" data-toggle="modal" data-target="#myModal" title="Hapus Telegram"><i class="fa fa-times"></i></a></td></tr>
                  <?php endif;?>
                  <tr><td style="width: 140px;">Status Akun</td><td>: <?php echo $user->us_verified ? '<span class="text-success"><i class="fa fa-check-circle"></i> Terverifikasi</span>'  : '<span class="text-danger"><i class="fa fa-times-circle"></i> Belum Terverifikasi</span>';?></td></tr>
                  <tr><td style="width: 140px;">Reseller</td><td>: <div class="btn-group"><a data-toggle="modal" data-target="#myModal" class="btn <?php echo $user->us_reseller == 'active' ? 'btn-primary': 'btn-default';?> btn-xs" href="<?php echo site_url('admin/users/reseller_status/'.$user->us_id.'/activate');?>">Aktif</a><a data-toggle="modal" data-target="#myModal" class="btn <?php echo $user->us_reseller == 'inactive' ? 'btn-primary': 'btn-default';?> btn-xs" href="<?php echo site_url('admin/users/reseller_status/'.$user->us_id.'/deactivate');?>">Tidak aktif</a><a data-toggle="modal" data-target="#myModal" class="btn <?php echo $user->us_reseller == 'blocked' ? 'btn-primary': 'btn-default';?> btn-xs" href="<?php echo site_url('admin/users/reseller_status/'.$user->us_id.'/blocked');?>">Diblokir</a></div></td></tr>
                  <tr><td style="width: 140px;">Saldo</td><td>: <?php echo format_uang2($user->us_balance, 0);?> (<a href="<?php echo site_url('admin/users/edit_saldo/'.$user->us_id);?>">Edit</a>)</td></tr>
                  <tr><td style="width: 140px;">Total Order</td><td>: <?php echo $user->us_total_order;?> (order sukses)</td></tr>
                  <tr><td style="width: 140px;">Total Pembayaran</td><td>: <?php echo format_uang2($this->user_model->total_amount($user->us_id));?></td></tr>
                  <tr><td style="width: 140px;">Pemblokiran</td><td>: <?php echo ($user->us_block ? 'Diblokir' : 'Tidak diblokir') . PHP_EOL;?></td></tr>
                  <tr><td style="width: 140px;">Terakhir Masuk</td><td>: <?php echo ($user->us_lastdate ? format_tanggal($user->us_lastdate) : '') . PHP_EOL;?></td></tr>
                  <tr><td style="width: 140px;">Tanggal Mendaftar</td><td>: <?php echo format_tanggal($user->us_regdate) . PHP_EOL;?></td></tr>
                </tbody>
              </table>
            </div>
            <ul class="nav nav-pills">
              <li role="presentation"><a href="<?php echo site_url('admin/users/kirim_notifikasi/'.$user->us_id);?>" data-toggle="modal" data-target="#myModal"><i class="fa fa-bell"></i> Kirim Pemberitahuan</a></li>
              <li role="presentation"><a href="<?php echo site_url('admin/users/edit/'.$user->us_id);?>"><i class="fa fa-edit"></i> Edit Akun</a></li>
              <li role="presentation"><a href="<?php echo site_url('admin/users/edit_saldo/'.$user->us_id);?>"><i class="fa fa-money"></i> Edit Saldo</a></li>
              <li role="presentation"><a href="<?php echo site_url('admin/users/ubah_sandi/'.$user->us_id);?>" data-toggle="modal" data-target="#myModal"><i class="fa fa-lock"></i> Ubah Kata sandi</a></li>
              <li role="presentation"><a href="<?php echo site_url('admin/users/ubah_pin/'.$user->us_id);?>" data-toggle="modal" data-target="#myModal"><i class="fa fa-key"></i> Ubah PIN</a></li>
              <?php if ($user->us_block):?>
              <li role="presentation"><a href="<?php echo site_url('admin/users/unblock/'.$user->us_id);?>" data-toggle="modal" data-target="#myModal"><i class="fa fa-ban"></i> Unblock User</a></li>
              <?php else:?>
              <li role="presentation"><a href="<?php echo site_url('admin/users/block/'.$user->us_id);?>" data-toggle="modal" data-target="#myModal"><i class="fa fa-ban"></i> Block User</a></li>
              <?php endif;?>
              <li role="presentation"><a href="<?php echo site_url('admin/users/delete/'.$user->us_id);?>" data-toggle="modal" data-target="#myModal"><i class="fa fa-user-times"></i> Delete User</a></li>
              <li role="presentation"><a href="<?php echo site_url('admin/users/login_as/'.$user->us_id);?>" data-toggle="modal" data-target="#myModal"><i class="fa fa-sign-in"></i> Login as <?php echo html_escape($user->us_name);?></a></li>
            </ul>
            <?php if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'):?>
            </div>
            <div class="modal-footer">
              <a href="<?php echo site_url('admin/users/profil/'.$user->us_id);?>" class="btn btn-primary">Lihat profil</a>
              <button type="button" class="btn btn-default" data-dismiss="modal">Tutup</button>
            </div>
            <?php else:?>
            </div>
          </div>
          <?php if (isset($user_set['verify_ktp'])):?>
          <div class="panel panel-warning" id="verifikasi">
            <div class="panel-heading">
              <h3><i class="fa fa-check-circle"></i> Verifikasi KTP</h3>
            </div>
            <div class="panel-body" style="padding-bottom: 0;">
              <div class="row">
                <div class="col-sm-offset-2 col-md-offset-3 col-sm-8 col-md-6">
                  <div class="text-center" style="margin-bottom: 15px;">
                    <a href="<?php echo site_url('image/ktp/'.$user->us_id.'/'.$user_set['verify_ktp']['file_name']);?>" target="_blank"><img class="img-thumbnail img-responsive" src="<?php echo site_url('image/ktp/'.$user->us_id.'/'.$user_set['verify_ktp']['file_name']);?>" style="margin: 0 auto;"/></a>
                  </div>
                  <div class="table-responsive">
                    <table class="table table-striped">
                      <tbody>
                        <?php foreach ($user_set['verify_ktp'] as $data_key=>$data_val):?>
                        <tr><td><?php echo ucwords(str_replace('_',' ',$data_key));?></td><td><?php echo html_escape($data_val);?></td></tr>
                        <?php endforeach;?>
                      </tbody>
                    </table>
                  </div>
                  <div class="row">
                    <div class="col-sm-6">
                      <a class="btn btn-primary btn-block" href="<?php echo site_url('admin/users/confirm_verify_ktp/'.$user->us_id);?>" style="margin-bottom: 15px;" data-toggle="modal" data-target="#myModal"><i class="fa fa-check"></i> Konfirmasi</a>
                    </div>
                    <div class="col-sm-6">
                      <a class="btn btn-danger btn-block" href="<?php echo site_url('admin/users/reject_verify_ktp/'.$user->us_id);?>" style="margin-bottom: 15px;" data-toggle="modal" data-target="#myModal"><i class="fa fa-close"></i> Tolak</a>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <?php elseif (isset($user_set['ktp_data']) && file_exists(APPPATH . 'upload/' . $user_set['ktp_data']['file_name'])):?>
          <div class="panel panel-success" id="verifikasi">
            <div class="panel-heading">
              <h3><i class="fa fa-check-circle"></i> KTP Terverifikasi</h3>
            </div>
            <div class="panel-body" style="padding-bottom: 0;">
              <div class="row">
                <div class="col-sm-offset-2 col-md-offset-3 col-sm-8 col-md-6">
                  <div class="text-center" style="margin-bottom: 15px;">
                    <a href="<?php echo site_url('image/ktp/'.$user->us_id.'/'.$user_set['ktp_data']['file_name']);?>" target="_blank"><img class="img-thumbnail img-responsive" src="<?php echo site_url('image/ktp/'.$user->us_id.'/'.$user_set['ktp_data']['file_name']);?>" style="margin: 0 auto;"/></a>
                  </div>
                  <div class="table-responsive">
                    <table class="table table-striped">
                      <tbody>
                        <?php foreach ($user_set['ktp_data'] as $data_key=>$data_val):?>
                        <tr><td><?php echo ucwords(str_replace('_',' ',$data_key));?></td><td><?php echo html_escape($data_val);?></td></tr>
                        <?php endforeach;?>
                      </tbody>
                    </table>
                  </div>
                  <div class="row">
                    <div class="col-sm-6">
                      <a class="btn btn-default btn-block" href="<?php echo site_url('image/ktp/'.$user->us_id.'/'.$user_set['ktp_data']['file_name']);?>" style="margin-bottom: 15px;" target="_blank"><i class="fa fa-download"></i> Download</a>
                    </div>
                    <div class="col-sm-6">
                      <a class="btn btn-danger btn-block" href="<?php echo site_url('admin/users/delete_ktp/'.$user->us_id);?>" style="margin-bottom: 15px;" data-toggle="modal" data-target="#myModal"><i class="fa fa-times"></i> Hapus</a>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <?php endif;?>
          <?php if (isset($user_set['reseller_request'])):?>
          <div class="panel panel-info" id="reseller">
            <div class="panel-heading">
              <h3><i class="fa fa-shopping-bag"></i> Permintaan Reseller</h3>
            </div>
            <div class="panel-body" style="padding-bottom: 0;">
              <p>Tanggal: <?php echo format_tanggal($user_set['reseller_reqtime']);?></p>
              <p>Pesan: <?php echo nl2br(html_escape($user_set['reseller_request']));?></p>
              <hr />
              <div class="row">
                <div class="col-sm-4">
                  <a class="btn btn-primary btn-block" href="<?php echo site_url('admin/users/reseller_status/'.$user->us_id.'/activate');?>" style="margin-bottom: 15px;" data-toggle="modal" data-target="#myModal"><i class="fa fa-check"></i> Menyetujui</a>
                </div>
                <div class="col-sm-4">
                  <a class="btn btn-default btn-block" href="<?php echo site_url('admin/users/reseller_status/'.$user->us_id.'/ignore');?>" style="margin-bottom: 15px;" data-toggle="modal" data-target="#myModal"><i class="fa fa-times"></i> Mengabaikan</a>
                </div>
                <div class="col-sm-4">
                  <a class="btn btn-danger btn-block" href="<?php echo site_url('admin/users/reseller_status/'.$user->us_id.'/blocked');?>" style="margin-bottom: 15px;" data-toggle="modal" data-target="#myModal"><i class="fa fa-ban"></i> Blokir</a>
                </div>
              </div>
            </div>
          </div>
          <?php endif;?>
        </div>
      </div>
    </div>
    <?php include_once(VIEWPATH.'includes/foot.php'); ?>
  </body>

</html>
<?php endif;?>