<?php include 'header.php'; ?>
<style>.container-fluid{width:100%}.clients-table{overflow-x:scroll;border:1px solid #dbdbdb}</style>
<div class="container-fluid p-3">
  <ul class="nav nav-tabs">
    <li class="p-b m-r"><button class="btn btn-default" type="button" data-toggle="modal" data-target="#modalDiv" data-action="new_user">İstifadəçi Yarat</button></li>
    <li class="p-b m-r"><button class="btn btn-default" type="button" data-toggle="modal" data-target="#modalDiv" data-action="export_user">İstifadəçi Yədəklə</button></li>
    <li class="p-b m-r"><button class="btn btn-default" type="button" data-toggle="modal" data-target="#modalDiv" data-action="alert_user">Bildiriş SMS Göndər</button></li>
    <li class="p-b m-r"><button class="btn btn-default" type="button" data-toggle="modal" data-target="#modalDiv" data-action="all_numbers">Əlaqə Məlumatları</button></li>
    <li class="p-b m-r"><button class="btn btn-default" type="button" data-toggle="modal" data-target="#modalDiv" data-action="details">Daha Ətraflı</button></li>
    <li class="p-b m-r"><button class="custom_method btn btn-default"  data-title="Saxta İstifadəçiləri Təmizlə?" data-message="Əminsiniz? Bu əməliyyatı geri qaytarmaq mümkün deyil." data-url="admin/clients/delete_fake_users"> Saxta İstifadəçiləri Təmizlə?</button></li>
    
   </ul>

<form class="form-inline" action="" method="get" enctype="multipart/form-data">
<div class="input-group">
<input type="text" name="search" class="form-control" value="<?=$search_word?>" placeholder="Axtarış">
<span class="input-group-btn search-select-wrap">
<select class="form-control search-select" name="search_type">
<option value="username" <?php if( $search_where == "username" ): echo 'selected'; endif; ?> >İstifadəçi Adı</option>
<option value="name" <?php if( $search_where == "name" ): echo 'selected'; endif; ?> >Ad</option>
<option value="email" <?php if( $search_where == "email" ): echo 'selected'; endif; ?> >E-mail</option>
<option value="telephone" <?php if( $search_where == "telephone" ): echo 'selected'; endif; ?> >Telefon Nömrəsi</option>
</select>
<button type="submit" class="btn btn-default"><span class="fa fa-search" aria-hidden="true"></span></button>
  </span>
       </div>
     </form>
  
 
  
 
<div class="clients-table">
  <table class="table" style="border:1px solid #ddd">



 

    <thead>
      <tr>      <th class="column-id">ID</th>
      
<th width="10%">İstifadəçi Adı</th>
      <th>E-mail</th>
 
      <th>Balans</th>
      <th>Xərclənib</th>
<th>Sifarişi</th>
<th>Servis Endirimi</th>
<th>Xüsusi endirimlər</th>
      <th nowrap="">Qeydiyyat Tarixi</th>
      <th>Seçimlər</th>
  </tr>
</thead>
<tbody>
  <?php foreach($clients as $client ): ?>
      <tr class="<?php if( $client["client_type"] == 1 ): echo "grey "; endif; ?>">
 <td>
 <?php echo $client["client_id"] ?>
 </td>
<td>
                            <?php echo $client["username"] ?>
                            <a href="<?= site_url('admin/clients/view/' . $client['client_id']) ?>">
                                <i class="fa fa-sign-in" aria-hidden="true" style="color: #3b3b7b;"></i></a>
                        </td>
<td>
                            <?php echo $client["email"] ?>
                            <?php if ($client["email_type"] == 2):
                                echo '<div  class="tooltip5"><i style="color:green;" class="fas fa-check-circle"></i></span><span class="tooltiptext5" >E-mail Təsdiqlənib</span></div>';
                            else:
                                echo '<div  class="tooltip5"><i style="color:red;" class="far fa-times-circle"></i></span><span class="tooltiptext5" >E-mail Təsdiqlənmiyib</span></div>';
                            endif; ?>
                        </td>

 
 <td>
 <div style="width:85px;">
 <?php echo format_amount_string($settings["site_base_currency"],$client["balance"]); ?>
 </div>
 </td>
 <td>

<div style="width:85px;">
 <?php echo format_amount_string($settings["site_base_currency"],$client["spent"]);?>
 </div>
 </td>
<td><?php echo countRow(["table"=>"orders","where"=>["client_id"=>$client["client_id"]] ]) ?></td>
<td>
  <button type="button" class="btn btn-default btn-xs disabled " style="cursor:pointer;" href="#" class="dcs-pointer" data-toggle="modal" data-target="#modalDiv" data-id="<?php echo $client["client_id"] ?>" data-action="set_discount_percentage">Endirim (<?php echo $client ["discount_percentage"]; ?>%)</button>
</td>
<td>
 <button type="button" class="btn btn-default btn-xs"><a class="nav-link" href="<?php echo site_url("admin/special-pricing/".$client["client_id"]."");?>"> Xüsusi Endirim <span style="margin-left:4px; border-radius:4px;" class="badge badge-info"><?php echo countRow(["table"=>"clients_price","where"=>["client_id"=>$client["client_id"]] ]) ?></span></a></button>
       </td>


 <td>
 <?php echo date('jS M Y \a\t g:ia',strtotime($client["register_date"])); ?>
 </td>
 <td class="td-caret">
 <div class="dropdown pull-right">
   <button type="button" class="btn btn-primary btn-xs dropdown-toggle btn-xs-caret" data-toggle="dropdown">Əlavə Ayarlar</button>
   <ul class="dropdown-menu">
       <li>
  <a class="dcs-pointer" data-toggle="modal" data-target="#modalDiv" data-action="edit_user" data-id="<?=$client["client_id"]?>">İstifadəçi Dəyiş</a>
       </li>
       <li>
  <a class="dcs-pointer" data-toggle="modal" data-target="#modalDiv" data-action="pass_user" data-id="<?=$client["client_id"]?>">Şifrəsin Dəyiş</a>
       </li>
       <li>
  <a class="dcs-pointer" data-toggle="modal" data-target="#modalDiv" data-action="secret_user" data-id="<?=$client["client_id"]?>">Kateqoriya Dəyiş</a>
       </li>
       <li>
  <a href="<?php echo site_url("admin/clients/change_apikey/".$client["client_id"]) ?>">Yeni API Key Açar Yarat</a>
       </li>
       <?php if( $client["client_type"] == 1 ): $type = "active"; else: $type = "deactive"; endif; ?>
       <li>
  <a href="<?php echo site_url("admin/clients/".$type."/".$client["client_id"]) ?>"><?php if( $client["client_type"] == 1 ): echo "Aktivləşdir"; else: echo "Deaktivləşdir"; endif; ?> Hesabı</a>
       </li>
       
       <li>
  <a href="<?php echo site_url("admin/clients/del_price/".$client["client_id"]) ?>">Xüsusi Endirimləri Sıfırla</a>
       </li>
   </ul>
 </div>
 </td>
      </tr>
  <?php endforeach; ?>
</tbody>
</table>
</div>
     

   <?php if( $paginationArr["count"] > 1 ): ?>
     <div class="row">
        <div class="col-sm-8">
  <nav>
 <ul class="pagination">
 <?php if( $paginationArr["current"] != 1 ): ?>
  <li class="prev"><a href="<?php echo site_url("admin/clients/1".$search_link) ?>">&laquo;</a></li>
  <li class="prev"><a href="<?php echo site_url("admin/clients/".$paginationArr["previous"].$search_link) ?>">&lsaquo;</a></li>
  <?php
      endif;
      for ($page=1; $page<=$pageCount; $page++):
        if( $page >= ($paginationArr['current']-9) and $page <= ($paginationArr['current']+9) ):
  ?>
  <li class="<?php if( $page == $paginationArr["current"] ): echo "active"; endif; ?> "><a href="<?php echo site_url("admin/clients/".$page.$search_link) ?>"><?=$page?></a></li>
  <?php endif; endfor;
        if( $paginationArr["current"] != $paginationArr["count"] ):
  ?>
  <li class="next"><a href="<?php echo site_url("admin/clients/".$paginationArr["next"].$search_link) ?>" data-page="1">&rsaquo;</a></li>
  <li class="next"><a href="<?php echo site_url("admin/clients/".$paginationArr["count"].$search_link) ?>" data-page="1">&raquo;</a></li> 
  <?php endif; ?>
 </ul>
  </nav>
        </div>
     </div>
   <?php endif; ?>
</div></div>
<div class="modal modal-center fade" id="confirmChange" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" data-backdrop="static">
   <div class="modal-dialog modal-dialog-center" role="document">
      <div class="modal-content">
<div class="modal-body text-center">
   <h4>Statusu yeniləmək istədiyinizə əminsiniz?</h4>
   <div align="center">
<a class="btn btn-primary" href="" id="confirmYes">Bəli</a>
<button type="button" class="btn btn-default" data-dismiss="modal">Xeyr</button>
   </div>
</div>
      </div>
   </div>
</div>

<?php include 'footer.php'; ?>