<?php $u_info = user_info(); ?>
<?php if(isset($u_info->user_type) && $u_info->user_type==1): ?>
<div class="row">
    <div class="col-lg-3 col-xs-6">
      <!-- small box -->
      <div class="small-box bg-green">
        <div class="inner">
          <h3><?= isset($u_info->reg_user)?html_escape($u_info->reg_user):"0"; ?></h3>

          <p><?= !empty(lang('users'))?lang('users'):"Total users";?></p>
        </div>
        <div class="icon">
          <i class="ion ion-ios-people"></i>
        </div>
        
      </div>
    </div>

     <?php foreach ($user_type as $key => $users): ?>
      <div class="col-lg-3 col-xs-6">
        <!-- small box -->
        <div class="small-box <?= ($key+1)%2==0?"bg-yellow":"bg-aqua";?>">
          <div class="inner">
            <h3><?= $users['total_user'];?></h3>
            <p><?= $users['type_name'];?></p>
          </div>
          <div class="icon">
            <i class="ion ion-ios-people-outline"></i>
          </div>
        </div>
      </div>
    <?php endforeach; ?> 

</div>

<div class="row">
  <div class="col-md-6">
    <div class="box box-primary">
      <div class="box-header with-border">
        <i class="fa fa-bar-chart-o"></i>

        <h3 class="box-title"><?= !empty(lang('net_income'))?lang('net_income'):"Net Income";?> - <?= date('Y');?></h3>

        <div class="box-tools pull-right">
          <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
          </button>
          <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
        </div>
      </div>
      <div class="box-body">
        <div id="bar-chart" style="height: 300px;"></div>
      </div>
      <!-- /.box-body-->
    </div>
  </div>


  <div class="col-md-6">
    <div class="box box-primary">
      <div class="box-header with-border">
        <i class="fa fa-bar-chart-o"></i>

        <h3 class="box-title"><?= !empty(lang('active_user'))?lang('active_user'):"active users";?>/<?= !empty(lang('month'))?lang('month'):"month";?> - <?= date('Y');?></h3>

        <div class="box-tools pull-right">
          <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
          </button>
          <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
        </div>
      </div>
      <div class="box-body">
        <div id="bar-chart_1" style="height: 300px;"></div>
      </div>
      <!-- /.box-body-->
    </div>
  </div>
</div>
 <?php include 'new_users.php' ?>
<?php endif;?>
<!-- end user type 1 -->

<?php if($u_info->user_type !=1): ?>
   <?php if($u_info->is_verify ==0): ?>
    <div class="row">
      <div class="col-md-5 col-md-offset-3">
        <div class="verify_msg">
          <i class="fa fa-frown-o"></i>
          <h4><?= !empty(lang('alert'))?lang('alert'):"Alert"?>!! <?= !empty(lang('not_verified'))?lang('not_verified'):"Your Account is not Verified"?></h4>
          <p> <?= !empty(lang('send_link'))?lang('send_link'):"Already send a verification link on your email. if not found "?></p>
          <a href="<?= base_url('admin/dashboard/resend_verify_mail/'.$u_info->username);?>" class="btn btn-primary"><?= !empty('resend')?lang('resend'):"Resend"?></a>
        </div>
        <p class="error fz-12"> * <?= !empty(lang('email_not_correct_msg'))?lang('email_not_correct_msg'):"if your email is not correct then change from profile option"?></p>
      </div>
    </div>
   <?php endif;?>
   <?php if($u_info->is_deactived==1 && $u_info->is_verify ==1): ?>
      <div class="row d_flex">
        <div class="col-md-6">
          <div class="not_found">
              <i class="fa fa-frown"></i>
              <h4 style="text-transform: capitalize;"><?= ucfirst(!empty(lang('deactive_alert'))?lang('deactive_alert'):"Sorry your account is Deactive")?></h4>
                <a href="<?= base_url('admin/profile/deactive_account/0/'.html_escape($u_info->username)); ?>" onclick="return confirm('Are You sure? Want to active your account?')" class="btn btn-default"><?= ucfirst(!empty(lang('active'))?lang('active'):"Active")?></a>
          </div>
        </div>
      </div>
    <?php endif;?>

    <?php if($u_info->is_payment==0 && $u_info->is_deactived==0 && $u_info->is_verify ==1): ?>
        <div class="col-md-4 col-md-offset-4">
         <div class="alert alert-warning alert-dismissible">
              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
              <h4><i class="icon fa fa-warning"></i> <?= !empty(lang('alert'))?lang('alert'):"Alert"?>!</h4>
                 <h4><?= !empty(lang('payment_pending'))?lang('payment_pending'):"Warning!! Your payment is still pending"?></h4>
                <p class="">*<?= !empty(lang('contact_us_alert'))?lang('contact_us_alert'):"Please pay from subscriptions or contact us"?></p>
            </div>
        </div>
      <?php endif; ?><!-- is_payment -->

    <?php if($u_info->is_expired==1 && $u_info->is_payment==1 && $u_info->is_deactived==0 && $u_info->is_verify ==1): ?>
      <div class="row d_flex">
        <div class="col-md-3">
          <div class="not_found">
            <i class="fa fa-frown"></i>
            <h4><?= !empty(lang('expired_alert'))?lang('expired_alert'):"Sorry your account is expired"?></h4>
            <p><?= !empty(lang('date'))?lang('date'):"Date"?>: <?= full_time($u_info->end_date);?></p>
          </div>
        </div>
      </div>
    <?php endif;?>
      <?php if($u_info->is_expired==0 && $u_info->is_payment==1 && $u_info->is_deactived==0 && $u_info->is_verify ==1): ?>
        <div class="user_features_area pb-20">
            <div class="text-center">
              <h4><i class="icon fa fa-smile-o fa-3x"></i></h4>
              <h2><?= !empty(lang('welcome'))?lang('welcome'):"Welcome" ;?> <?= auth('username'); ?> <?= !empty(lang('dashboard'))?lang('dashboard'):" 's Dashboard" ;?>  </h2>
              <div class="share_able_link">
                <p><?= !empty(lang('profile_link'))?lang('profile_link'):"Profile Link"?>: <span><?= base_url(auth('username')) ;?></span> <a href="javascript:;" class="copy_btn btn-success copy" data-id="<?= auth('id') ;?>" data-link="<?= base_url($u_info->username) ;?>"><?= !empty(lang('copy'))?lang('copy'):"Copy"?></a></p>
                <p class="copy_alert" style="display: none;"><i class="fa fa-check"></i> &nbsp;<?= !empty(lang('coppied'))?lang('coppied'):"coppied"?></p>
              </div>
            </div>
            <?php if($u_info->user_type==0): ?>
               <?php if(get_user_pricing_by_id(auth('id'),'vcard')==1 || is_active(auth('id'),'vcard') ==1 || profile_status()==1): ?>
                  <div class="row">
                    <div class="col-md-12">
                      <form action="<?= base_url('admin/profile/vcard_status'); ?>" method="post" >
                        <!-- csrf token -->
                        <input type="hidden" name="<?= $this->security->get_csrf_token_name(); ?>" value="<?= $this->security->get_csrf_hash(); ?>">
                        <ul class="vcardStatus">
                          
                          <?php if(profile_status()==1): ?>

                            <?php if(profile_status()==1 &&  get_user_pricing_by_id(auth('id'),'vcard')==0): ?>
                                <?php $this->admin_m->update(['vcard_status'=>2],auth('id'),'users'); ?>
                              <?php endif;?>


                            <li class="<?= isset($u_info->vcard_status) && $u_info->vcard_status==2?"active":"";?>"><label ><input type="radio" name="vcard_status" value="2" <?= profile_status()==1 &&  get_user_pricing_by_id(auth('id'),'vcard')==0?"checked":"";?> onchange="this.form.submit();" <?= isset($u_info->vcard_status) && $u_info->vcard_status==2?"checked":"";?>> <?= !empty(lang('only_profile'))?lang('only_profile'):"Only Profile"; ?></label></li>
                          <?php endif;?>

                          <?php if(get_user_pricing_by_id(auth('id'),'vcard')==1): ?>
                            <?php if(profile_status()==0 &&  get_user_pricing_by_id(auth('id'),'vcard')==1 && $u_info->vcard_status!=1): ?>
                                <?php $this->admin_m->update(['vcard_status'=>1],auth('id'),'users'); ?>
                              <?php endif;?>

                            <li class="<?= isset($u_info->vcard_status) && $u_info->vcard_status==1?"active":"";?>"><label ><input type="radio" name="vcard_status" value="1" <?= profile_status()==0 &&  get_user_pricing_by_id(auth('id'),'vcard')==1?"checked":"";?> onchange="this.form.submit();" <?= isset($u_info->vcard_status) && $u_info->vcard_status==1?"checked":"";?>> <?= !empty(lang('only_vcard'))?lang('only_vcard'):"Only Vcard"; ?></label></li>
                          <?php endif;?>
                          <?php  if(profile_status()==1 && get_user_pricing_by_id(auth('id'),'vcard')==1):?>
                             <li class="<?= isset($u_info->vcard_status) && $u_info->vcard_status==3?"active":"";?>"><label><input type="radio" name="vcard_status" value="3" onchange="this.form.submit();" <?= isset($u_info->vcard_status) && $u_info->vcard_status==3?"checked":"";?>> <?= lang('both'); ?></label></li>
                          <?php endif;?>
                        </ul>
                      </form>
                    </div>
                  </div>
                <?php endif;?>
          <?php endif; ?>

        </div>
        <div class="row">
          <div class="col-md-12">
            <div class="row">
              <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
                  <!-- Widget: user widget style 1 -->
                  <div class="box box-widget widget-user-2">
                    <!-- Add the bg color to the header using any of the bg-* classes -->
                    <div class="widget-user-header profile profile_flex" style="background-color: #<?= $u_info->colors; ;?>">
                      <div class="widget-user-image profile-img-2">
                        <img class="img-circle" src="<?= base_url(!empty($u_info->thumb)?$u_info->thumb:'assets/admin/dist/img/user2-160x160.jpg') ;?>" alt="User Avatar">
                      </div>
                        <div class="right_details">
                          <div class="right_left">
                            <!-- /.widget-user-image -->
                              <h3 class="widget-user-username"><?= isset($u_info->name) && !empty($u_info->name)?$u_info->username:$u_info->username;?></h3>
                              <h5 class="widget-user-desc"><?= isset($u_info->designation)?$u_info->designation:'' ;?></h5>
                              <h5 class="widget-user-desc"><?= cl_format($u_info->post_time) ;?></h5>
                          </div>
                          <div class="right_right">
                            <div class="text-center mr-20" data-toggle="tooltip" title="Share profile">
                              <i class="fa fa-floppy-o "></i>
                              <p><?= isset($u_info->share_link)?$u_info->share_link:0 ;?></p>
                            </div>
                            <div class="text-center" data-toggle="tooltip" title="Total Visit">
                              <i class="fa fa-eye fa-1.5x"></i>
                              <p><?= isset($u_info->hit) ?$u_info->hit:0 ;?></p>
                            </div>
                          </div>
                        </div>
                    </div>
                    <div class="box-footer no-padding">
                      <ul class="nav nav-stacked">
                        <?php if(get_user_pricing_by_id(auth('id'),'services')==1): ?>
                          <li><a href="<?= base_url('admin/profile/services') ;?>"><?= get_features_name('services');?> <span class="pull-right badge bg-blue"><?= $this->admin_m->count_table_by_user_id('services') ;?></span></a></li>
                        <?php endif;?>

                        <?php if(get_user_pricing_by_id(auth('id'),'skills')==1): ?>
                          <li><a href="<?= base_url('admin/profile/skills') ;?>"><?= get_features_name('skills');?> <span class="pull-right badge bg-aqua"><?= $this->admin_m->count_table_by_user_id('skills') ;?></span></a></li>
                        <?php endif;?>

                        <?php if(get_user_pricing_by_id(auth('id'),'portfolio')==1): ?>
                          <li><a href="<?= base_url('admin/profile/portfolio') ;?>"><?= get_features_name('portfolio');?><span class="pull-right badge bg-green"><?= $this->admin_m->count_table_by_user_id('portfolio') ;?></span></a></li>
                        <?php endif;?>

                        <?php if(get_user_pricing_by_id(auth('id'),'blog')==1): ?>
                          <li><a href="<?= base_url('admin/post') ;?>"><?= ucfirst(!empty(lang('posts'))?lang('posts'):"posts")?> <span class="pull-right badge bg-red"><?= $this->admin_m->count_table_by_user_id('post') ;?></span></a></li>
                        <?php endif;?>

                      </ul>
                    </div>
                  </div>
                  <!-- /.widget-user -->
                </div>

                <div class="col-md-5 col-lg-5 col-sm-6 col-xs-12">
                  <!-- Widget: user widget style 1 -->
                  <div class="box box-widget widget-user">
                    <!-- Add the bg color to the header using any of the bg-* classes -->
                    <div class="widget-user-header profile" style="background-color: #<?= $u_info->colors; ;?>">
                      <h3 class="widget-user-username"><?=  $u_info->username;?></h3>
                      <h5 class="widget-user-desc"><?= ucfirst(!empty(lang('package_name'))?lang('package_name'):"package name")?>: <b><?= isset($pricing[0]['type_name'])? html_escape($pricing[0]['type_name']):"";?></b> <?php if(isset($pricing[0]['type']) && $pricing[0]['type']!="free"): ?>
                              <p class="description-text mt-5"><b><?= day_left(d_time(),$u_info->end_date)['day_left'];?></b></p>
                            <?php endif;?></h5>
                   
                    </div>
                    <div class="widget-user-image profile-img">
                      <img class="img-circle" src="<?= base_url(!empty($u_info->thumb)?$u_info->thumb:'assets/admin/dist/img/user2-160x160.jpg') ;?>" alt="User Avatar">
                    </div>
                    <div class="box-footer">
                      <div class="row">
                        <div class="col-sm-4 border-right">
                          <div class="description-block">
                            <h5 class="description-header"><?= ucfirst(isset($pricing[0]['type'])?html_escape(!empty(lang($pricing[0]['type']))?lang($pricing[0]['type']):$pricing[0]['type']):'');?></h5>
                            <span class="description-text"><?= !empty(lang('package_type'))?lang('package_type'):"package type"?></span>
                           
                          </div>
                          <!-- /.description-block -->
                        </div>
                        <!-- /.col -->
                        <div class="col-sm-4 border-right">
                          <div class="description-block">
                            <h5 class="description-header"><?= isset($pricing[0]['features'])?count(html_escape($pricing[0]['features'])).' / '.$this->admin_m->count_all_by_table('features'):"";?> </h5>
                            <span class="description-text"><?= !empty(lang('features'))?lang('features'):"Features"?></span>
                          </div>
                          <!-- /.description-block -->
                        </div>
                        <!-- /.col -->
                        <div class="col-sm-4">
                          <div class="description-block">
                            <h5 class="description-header"><?= isset($pricing[0]['type_limit']) && $pricing[0]['type_limit'] !=0?html_escape($pricing[0]['type_limit']):(!empty(lang('unlimited'))?lang('unlimited'):"Unlimited");?></h5>
                            <span class="description-text"><?= !empty(lang('items'))?lang('items'):"Items"?> / <?= !empty(lang('features'))?lang('features'):"Features"?></span>

                          </div>
                          <!-- /.description-block -->
                        </div>
                        <!-- /.col -->
                        
                      </div>

                      <!-- /.row -->
                    </div>
                    <div class="profile_btn">
                      <a href="<?= base_url('admin/dashboard/profile') ;?>" class=""><?= !empty(lang('profile'))?lang('profile'):"profile"?></a>
                    </div>
                  </div>
                  <!-- /.widget-user -->
                  <?php if(get_user_pricing_by_id(auth('id'),'qr_code')==1 && is_active(auth('id'),'qr_code')==1): ?>
                  <div class="qrcode">
                    <div class="qrCodeImg">
                      <img src="<?= base_url($u_info->qr_code) ;?>" alt="">
                    </div>
                    <a href="<?= base_url($u_info->qr_code) ;?>" download class="label label-success download_btn"><i class="fa fa-download"></i> <?= !empty(lang('download'))?lang('download'):"Download"?></a> &nbsp;&nbsp;

                    <a data-link="<?= base_url('save-qr/'.$u_info->username) ;?>" data-id="<?=  auth('id');?>" class="label label-success download_btn copy"><i class="fa fa-share"></i> &nbsp; <?= !empty(lang('share_qr'))?lang('share_qr'):"Share QR link"?> </a>
                    <p class="copy_alert" style="display: none;"><i class="fa fa-check"></i> &nbsp;<?= !empty(lang('coppied'))?lang('coppied'):"coppied"?></p>
                  </div>
                <?php endif; ?>



                </div>

                <div class="col-md-4 col-lg-4 col-sm-6 col-xs-12">
                <div class="text-right">
                  <div class="iframe_area">
                    <iframe src="<?= base_url($u_info->username);?>" frameborder="0" style="width: 360px;height: 650px;"></iframe> 
                  </div>
                </div>
              </div>


            </div>
          </div>
        </div>
    <?php endif;?>

<?php endif;?> <!-- user type ==0 -->