<?php $total_vcard = $this->admin_m->count_by_vcard(auth('id')); ?>
<?php $get_limit = single_select_by_id($u_info->account_type,'features_type'); ?>
<?php 
	if($get_limit['card_limit']==0):
		$current_card = $total_vcard;
	else:
		$current_card = $get_limit['card_limit'] - ($total_vcard+1);
	endif;

 ?>



<?php if(get_user_pricing_by_id($u_info->id,'vcard')==1 && is_active($u_info->id,'vcard')): ?>

<div class="row">
	<div class="col-md-6">
		<div class="alert alert-primary text-danger">
			<?php if($get_limit['card_limit']==0): ?>
				<strong><?= lang('info'); ?></strong> <?= lang('you_have_remaining'); ?> <b> <?= lang('unlimited') ;?> / <?= lang('unlimited');?>  <?= lang('vcards'); ?> </b>
			<?php else: ?>
				<strong><?= lang('info'); ?></strong> <?= lang('you_have_remaining'); ?> <b> <?= $current_card ;?> / <?= $get_limit['card_limit'];?> <?= lang('vcards'); ?> </b>

			<?php endif;?>
		</div>
	</div>	
</div>
<?php endif;?>
<div class="row">
	<?php if(get_user_pricing_by_id($u_info->id,'home')==1 && is_active($u_info->id,'home')): ?>
	<div class="col-md-4 mb-15">
		<div class="card" style="background: #f9f9f9;">
			<div class="card-body text-center">
				<div class="single_profile">
					<div class="imgArea p-r">
						<img src="<?= base_url(!empty($u_info->thumb)?$u_info->thumb:'assets/images/avatar.png') ;?>" class="profile_img" alt="">
						<span class="cardIcon profile" data-toggle="tooltip" title="Profile">
							<i class="fa fa-user-circle-o"></i>
						</span>
					</div>
					<div class="profileDetails">
						<h4 class="fw-bold"><?= !empty($u_info->name)?$u_info->name:$u_info->username ;?></h4>
						<p><?= !empty($u_info->dial_code)?$u_info->dial_code:"" ;?> <?= !empty($u_info->phone)?$u_info->phone:"" ;?></p>
					</div>
					<div class="buttonArea">
						<a href="<?= base_url("admin/dashboard/edit_profile"); ?>" class="btn btn-sm btn-secondary"><i class="fa fa-edit"></i> <?= lang('edit'); ?></a>
					</div>
				</div>
			</div>
		</div>
	</div>
<?php endif;?>
<?php if(get_user_pricing_by_id($u_info->id,'vcard')==1 && is_active($u_info->id,'vcard')): ?>
	<div class="col-md-4 mb-15">
		<div class="card" style="background: #f9f9f9;">
			<div class="card-body text-center">
				<div class="single_profile">
					<div class="imgArea p-r">
						<img src="<?= base_url(!empty($u_info->thumb)?$u_info->thumb:'assets/images/avatar.png') ;?>" class="profile_img" alt="">
						<span class="cardIcon" data-toggle="tooltip" title="vCard">
							<i class="icofont-id-card"></i>
						</span>
					</div>
					<div class="profileDetails">
						<h4 class="fw-bold"><?= !empty($u_info->name)?$u_info->name:$u_info->username ;?></h4>
						<p><?= !empty($u_info->dial_code)?$u_info->dial_code:"" ;?> <?= !empty($u_info->phone)?$u_info->phone:"" ;?></p>
					</div>
					<div class="buttonArea">
							<a href="<?= base_url($u_info->username); ?>" class="btn btn-sm btn-secondary"><i class="fa fa-eye"></i></a>
							<div class="dropdown p-r">
							  <button class="btn btn-primary dropdown-toggle btn-sm p-r" type="button" data-toggle="dropdown"><?= lang('configuration'); ?> &nbsp;&nbsp;&nbsp;
							  <span class="caret"></span></button>
							  <ul class="dropdown-menu">
							  	<?php if(isset($u_info->is_payment) && $u_info->is_payment==1 && $u_info->active_vcard==1): ?>
								    <li><a href="<?= base_url('admin/vcards/?_user_token='.md5($u_info->id).'&p=2'); ?>"><?= lang('edit_add_information');?> </a></li>
								    <li><a href="<?= base_url('admin/vcards/?_user_token='.md5($u_info->id).'&p=3'); ?>"><?= lang('edit_add_icon');?></a></li>
								    <li><a href="<?= base_url('admin/vcards/?_user_token='.md5($u_info->id).'&p=4'); ?>"><?= lang('change_layouts'); ?></a></li>
								    <li class="<?= is_allow()==1?"":"hidden";?>"><a href="<?= base_url('admin/vcards/?_user_token='.md5($u_info->id).'&p=pwa'); ?>"><?= lang('config_pwa'); ?></a></li>
								    <li class=""><a href="<?= base_url('admin/vcards/?_user_token='.md5($u_info->id).'&p=settings'); ?>"><?= lang('settings'); ?></a></li>
								    <li class="divider"></li>
								<?php endif;?>
							    <li><a href="<?= base_url('admin/vcards/?_user_token='.md5($u_info->id).'&p=1'); ?>"><?= lang('edit'); ?></a></li>
							  </ul>
							</div>
						</div>
				</div>
			</div>
		</div>
	</div>
<?php endif;?>
<?php if(is_allow()==1): ?>
<?php if(get_user_pricing_by_id($u_info->id,'vcard')==1 && is_active($u_info->id,'vcard')): ?>
	<?php foreach ($my_cards as $key => $cards): ?>
		<div class="col-md-4 mb-15 <?= is_allow()==1?:"hidden";?>">
			<div class="card">
				<div class="card-body text-center">
					<div class="single_profile">
						
						<div class="imgArea p-r">
							<img src="<?= base_url(!empty($cards['thumb'])?$cards['thumb']:'assets/images/avatar.png') ;?>" class="profile_img" alt="">
							<span class="cardIcon" data-toggle="tooltip" title="vCard">
								<i class="icofont-id-card"></i>
							</span>
						</div>
						<div class="profileDetails">
							<h4 class="fw-bold"><?= !empty($cards['name'])?$cards['name']:$cards['username'] ;?></h4>
							<p><?= !empty($cards['dial_code'])?$cards['dial_code']:"" ;?> <?= !empty($cards['phone'])?$cards['phone']:"" ;?></p>
						</div>
						<div class="buttonArea">
							<a href="<?= base_url($cards['username']); ?>" class="btn btn-sm btn-secondary"><i class="fa fa-eye"></i></a>
							<div class="dropdown p-r">
							  <button class="btn btn-primary dropdown-toggle btn-sm p-r" type="button" data-toggle="dropdown"><?= lang('configuration'); ?> &nbsp;&nbsp;&nbsp;
							  <span class="caret"></span></button>
							  <ul class="dropdown-menu">
							  	<?php if(isset($cards['is_payment']) && $cards['is_payment']==1 && $cards['active_vcard']==1): ?>
								    <li><a href="<?= base_url('admin/vcards/?_user_token='.md5($cards['id']).'&p=2'); ?>"><?= lang('edit_add_information'); ?> </a></li>
								    <li><a href="<?= base_url('admin/vcards/?_user_token='.md5($cards['id']).'&p=3'); ?>"><?= lang('edit_add_icon'); ?></a></li>
								    <li><a href="<?= base_url('admin/vcards/?_user_token='.md5($cards['id']).'&p=4'); ?>"><?= lang('change_layouts'); ?></a></li>
								    <li class="<?= is_allow()==1?"":"hidden";?>"><a href="<?= base_url('admin/vcards/?_user_token='.md5($cards['id']).'&p=pwa'); ?>"><?= lang('config_pwa'); ?></a></li>
								    <li class=""><a href="<?= base_url('admin/vcards/?_user_token='.md5($cards['id']).'&p=settings'); ?>"><?= lang('settings'); ?></a></li>
								    <li class="divider"></li>
								<?php endif;?>
							    <li><a href="<?= base_url('admin/vcards/?_user_token='.md5($cards['id']).'&p=1'); ?>"><?= lang('edit'); ?></a></li>
							  </ul>
							</div>
							<a href="<?= base_url("admin/dashboard/delete/{$cards['id']}"); ?>" data-msg='<?= lang('want_to_delete'); ?>' class="btn btn-sm btn-danger action_btn"><i class="fa fa-trash-o"></i></a>
						</div>
					</div>
				</div>
			</div>
		</div>
	<?php endforeach ?>
<?php endif;?>
<?php endif;?>
<?php if(get_user_pricing_by_id($u_info->id,'vcard')==1 && is_active($u_info->id,'vcard')): ?>
<?php if(is_allow()==1): ?>
	<div class="col-md-4 mb-10 <?= is_allow()==1?:"hidden";?>">
		<?php if($get_limit['card_limit']==0): ?>
			<a href="<?= base_url("admin/vcards"); ?>">
				<div class="create_new_card">
					<i class="fa fa-plus"></i>
					<h4><?= lang('create_a_new_vcard'); ?></h4>
				</div>
			</a>
		<?php else: ?>
			<?php if($current_card < 1): ?>
				<a href="#maxLimit" data-toggle="modal">
					<div class="create_new_card">
						<i class="fa fa-plus"></i>
						<h4><?= lang('create_a_new_vcard'); ?></h4>
					</div>
				</a>
			<?php else: ?>
				<a href="<?= base_url("admin/vcards"); ?>">
					<div class="create_new_card">
						<i class="fa fa-plus"></i>
						<h4><?= lang('create_a_new_vcard'); ?></h4>
					</div>
				</a>
			<?php endif ?>
		<?php endif ?>

	</div>
</div>
<?php endif;?>
<?php endif;?>
<div class="modal fade" id="maxLimit">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title"><?= lang('vcard_limit'); ?></h4>
			</div>
			<div class="modal-body">
				<div class="empty_msg text-center">
					<i class="fa fa-frown-o fa-2x"></i>
					<div class="">
						<h4><?= lang('reached_limit'); ?></h4>
					</div>
				</div>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">ok</button>
			</div>
		</div>
	</div>
</div>




