<div class="row">
	<div class="col-md-12 col-sm-12">
		<div class="box box-primary">
			<div class="box-header with-border">
				<h3 class="box-title"><?= !empty(lang('users'))?lang('users'):"users";?></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-remove"></i></button>
				</div>
			</div>
			<!-- /.box-header -->
			<div class="box-body" >
				<div class="text-right hidden">
					<a href="<?= base_url('admin/dashboard/add_user') ?>" class="btn btn-primary btn-flat"><i class="fa fa-plus"></i> <?= !empty(lang('add_new'))?lang('add_new'):"Add New";?></a>
				</div>
				<br>
				<div class="table-responsive">
					<table id="" class="table table-bordered table-striped">
	                <thead>
	                <tr>
	                  <th>#</th>
	                  <th><?= !empty(lang('username'))?lang('username'):"username";?></th>
	                  <th><?= !empty(lang('email'))?lang('email'):"email";?></th>
	                  <th><?= !empty(lang('active'))?lang('active'):"active Date";?></th>
	                  <th><?= !empty(lang('account_type'))?lang('account_type'):"account type";?></th>
	                  <th><?= !empty(lang('status'))?lang('status'):"status";?></th>
	                  <th><?= !empty(lang('change_package'))?lang('change_package'):"Change Package";?></th>
	                  <th><?= !empty(lang('action'))?lang('action'):"action";?></th>
	                </tr>
	                </thead>
	                <tbody>
	                <?php $i=1; foreach ($all_user as $key => $row): ?>
		                <tr>
		                  <td><?= $i; ?></td>
		                  <td><?= html_escape($row['username']); ?> </td>
		                  <td><?= html_escape($row['email']); ?></td>
		                  <td> <?= $row['start_date']!='0000-00-00 00:00:00'?(full_time(html_escape($row['start_date']))):(!empty(lang('not_verified'))?lang('not_verified'):"Not Verify yet'"); ?></td>
						  <td>
						  	<?php if($row['is_expired'] == 0): ?>
							  	<span class="label label-default mr-5" data-toggle="tooltip" data-placement="top" title="<?= 'Expired Date: '.$row['end_date'];?>" >
							  		<?php if($row['type']=="free"): ?>
							  		<?= !empty(lang('free'))?lang('free'):"Free Account";?>
							  	<?php else: ?>
							  		<?php if($row['is_payment']==1 && $row['end_date'] !='0000-00-00 00:00:00'): ?>
							  			<?= day_left(d_time(),$row['end_date'])['day_left']; ?>
							  		<?php else: ?>
							  			<?= !empty(lang('not_active'))?lang('not_active'):"Not active yet";?> 
							  		<?php endif ?>
							  	<?php endif ?>
							  	</span>
						  	<?php else: ?>
						  		<span class="label label-danger mr-5"  data-toggle="tooltip" data-placement="top" title="<?= 'Expired on: '.day_left(d_time(),$row['end_date'])['day_left'];?>" > <?= !empty(lang('expired'))?lang('expired'):"Expired";?></span>
						  	<?php endif ?>

		                  	<a href="javascript:;"  class="label label-primary"><?= html_escape($row['type_name']);?></a>
		                  </td>
		                  
		                  <td class="rtl_flex">
		                  	<?php if($row['is_active']== 1){ ?>
			                  	<a href="<?= base_url('admin/dashboard/change_status/'.$row['id']."/".$row['is_active']); ?>" class="label label-success ml-5 action_btn" data-toggle="tooltip" data-placement="top" title="Click to Deactive" data-msg="Want to hold this account?"><i class="fa fa-check"></i>&nbsp; <?= !empty(lang('in_active'))?lang('in_active'):"Active";?> </a>
			                 <?php }else{ ?>
			                  	<a href="<?= base_url('admin/dashboard/change_status/'.$row['id']."/".$row['is_active']);?>" class="label label-danger ml-5 action_btn" data-msg="Want to active this account?" data-toggle="tooltip" data-placement="top" title="Click to Active"><i class="fa fa-ban"></i> &nbsp; <?= !empty(lang('deactive'))?lang('deactive'):"Dactive";?> </a>
			                <?php } ?>
						
							 <?php if($row['is_verify']== 1): ?>
								<a href="javascript:;" class="label label-success ml-5" data-toggle="tooltip" data-placement="top" title="Email Verified"><i class="fa fa-check"></i>&nbsp; <?= !empty(lang('verified'))?lang('verified'):"Verified";?></a>
							<?php else: ?>
								<a href="<?= base_url('admin/dashboard/verifiy/'.html_escape($row['username'])."/1"); ?>" class="label label-danger ml-5 action_btn" data-toggle="tooltip" data-placement="top" title="Email Verify" data-msg="Want to verify this account?"><i class="fa fa-ban"></i>&nbsp; <?= !empty(lang('not_verified'))?lang('not_verified'):"Not verified";?></a>
							<?php endif ?> 


							<?php if($row['is_payment']== 1): ?>
								<a href="javascript:;" class="label label-success ml-5" data-toggle="tooltip" data-placement="top" title="Offline Payment"><i class="fa fa-check" ></i>&nbsp;<?= !empty(lang('paid'))?lang('paid'):"Paid";?> </a>
							<?php else: ?>
								<a href="<?= base_url('admin/dashboard/offline_payment/'.html_escape($row['username'])."/1"); ?>" class="label label-danger ml-5 action_btn" data-msg="Want to  payment verify?" data-toggle="tooltip" data-placement="top" title="Click for paid Offline Payment" ></i>&nbsp; &nbsp;<?= !empty(lang('pending'))?lang('pending'):"pending";?></a>
							<?php endif ?> 

							<?php if($row['is_deactived']==1): ?>
								<label class="label label-warning"><?= lang('deactive_account'); ?></label>
							<?php endif; ?>
			                
		                  </td>

		                  <td>
		                  	

		                  	<a href="#packageModal_<?= $row['id'];?>" title="Change Package" data-toggle="modal" class="btn btn-primary"><i class="fa fa-toggle-on"></i> <?= !empty(lang('change_package'))?lang('change_package'):"Change package";?></a>
		                  </td>
		                  
		                  <td>
		                  	<a href="javascript:;" title="Reset Password" data-toggle="tooltip" data-placement="top" class="btn btn-flat btn-warning btn-sm reset_password" data-msg="<?= !empty(lang('reset_pass_msg'))?lang('reset_pass_msg'):"Want to reset password";?>" data-id="<?= $row['id'];?>" > <i class="fa fa-lock"></i> </a>

		                  	<a href="<?= base_url(html_escape($row['username'])); ?>" title="View Profile" class="btn btn-flat btn-primary btn-sm" target="blank"> <i class="fa fa-eye"></i> </a>

							<?php if($this->session->userdata('user_type')==1): ?>
			                  	<a href="<?= base_url('admin/dashboard/delete/'.$row['id']) ?>" data-msg="<?= !empty(lang('want_to_delete'))?lang('want_to_delete'):'Want to delete?' ;?>" class="btn btn-flat btn-danger btn-sm action_btn" data-toggle="tooltip" data-placement="top" title="Delete user" ><i class="fa fa-trash-o"></i></a>
		                  	<?php endif; ?>
		                  </td>
		                </tr>
	            	<?php $i++; endforeach ?>
	                </tbody>
	              </table>
				</div>
			</div><!-- /.box-body -->
			<div class="box-footer" >
				<div class="col-md-12 text-center adminPagi">
					<?= $this->pagination->create_links();?>
				</div>
			</div>
		</div>
	</div>
</div>

<?php foreach ($all_user as $key => $users): ?>
	<!-- Modal -->
	<div id="packageModal_<?= $users['id'];?>" class="modal fade" role="dialog">
	  <div class="modal-dialog">

	    <!-- Modal content-->
	    <div class="modal-content">
	      <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal">&times;</button>
	        <h4 class="modal-title"><?= !empty(lang('change_packege'))?lang('change_packege'):"Change Packages";?></h4>
	      </div>
	      <form action="<?= base_url('admin/dashboard/change_packege/'.$users['id']); ?>" method="post">
	      	<input type="hidden" name="<?= $this->security->get_csrf_token_name(); ?>" value="<?= $this->security->get_csrf_hash(); ?>">

		      <div class="modal-body" style="overflow: hidden;">
		        <div class="package_area" style="justify-content: center;">
		        	<div class="form-group">
		        		<label><?=  !empty(lang('username'))?lang('username'):'Username';?></label>
		        		<h4><?= html_escape($users['username']) ;?></h4>
		        	</div>

		        	<div class="form-group">
		        		<label><?=  !empty(lang('current_package'))?lang('current_package'):'Current package';?></label>
		        		<h4><?= html_escape($users['type_name']) ;?></h4>
		        	</div>
		        	<div class="form-group">
		        		<label> <?=  !empty(lang('packages'))?lang('packages'):'Packages';?></label>
		        		<select name="package_id" id="" class="form-control">
		        			<?php  foreach ($pricing as $key => $modal_package): ?>
								<option <?= $users['account_type']==$modal_package['id']?"selected":"" ;?> value="<?=  $modal_package['id'];?>"><?= $modal_package['type_name'];?> - <?= get_currency('icon').' '.$modal_package['price'] ;?> / <?= $modal_package['type'];?></option>
							<?php  endforeach; ?>
		        		</select>
		        	</div>
					
				</div>
		      </div>
		      <div class="modal-footer text-left">
		        <button type="submit" class="btn btn-success c_btn" onclick="return confirm('Are you sure to payment offline?')"><?= !empty(lang('submit'))?lang('submit'):"submit";?></button>
		      </div>
	      </form>
	    </div>

	  </div>
	</div>
<?php endforeach ?>



