<?php
   require admin_view('static/header') ?>
<div class="container-fluid">
   <div class="row">
      <div class="col-lg-12">
         <?php
            if (route(2) == "online"):?>				<button class="btn btn-default" data-toggle="modal" data-toggle="modal" data-target="#modalDefault" data-action="add_payment">Bakiye Ekle/Çıkar</button>				
         <div class="pull-right">
            <form class="form-inline" action="" method="get">
               <div class="input-group">
                  <input type="text" name="search" class="form-control" value="" placeholder="Ödeme ara...">							
                  <span class="input-group-btn">
                     <select class="form-control" style="border-radius:0;" name="search_type">
                        <option value="id">ID</option>
                     </select>
                     <button type="submit" class="btn btn-default"><span class="fa fa-search" aria-hidden="true"></span></button>							
                  </span>
               </div>
            </form>
         </div>
         <div class="panel panel-default" style="margin-top:20px;">
            <table id="table" class="table order-table table-grey" style="margin-bottom:0;">
               <thead>
                  <tr>
                     <th>#</th>
                     <th>Kullanıcı</th>
                     <th class="dropdown-th">
                        <div class="dropdown">
                           <button class="btn btn-sm btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">											Yöntem											<span class="caret"></span>										</button>										
                           <ul class="dropdown-menu" aria-labelledby="dropdownMenu1" id="serviceListContent" style="max-height: 275px; overflow:hidden; overflow-y: scroll">
                              <li>												<a href="?method=158">Manuel Bakiye Ekleme</a>												<a href="?method=159">Manuel Bakiye Eksiltme</a>												<a href="?method=1">PayTR</a>												<a href="?method=6">PayTR Havale</a>												<a href="?method=3">Paywant</a>												<a href="?method=4">Shopier</a>												<a href="?method=5">Shoplemo</a>											</li>
                           </ul>
                        </div>
                     </th>
                     <th>Eski Bakiye</th>
                     <th>Yeni Bakiye</th>
                     <th>Notlar</th>
                     <th>Tarih</th>
                     <th>Tutar</th>
                     <th class="dropdown-th">
                        <div class="dropdown">
                           <button class="btn btn-sm btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">											Durum											<span class="caret"></span>										</button>										
                           <ul class="dropdown-menu" aria-labelledby="dropdownMenu1" id="serviceListContent" style="max-height: 275px; overflow:hidden; overflow-y: scroll">
                              <li>												<a href="?status=1">Onaylandı</a>												<a href="?status=2">Beklemede</a>												<a href="?status=0">Onaylanmadı</a>											</li>
                           </ul>
                        </div>
                     </th>
                  </tr>
               </thead>
               <tbody>
                  <?php
                     foreach ($deposits as $deposit):$methods = $db->from('payment_methods')
                     	->where('method_id', $deposit['deposit_method'])->first();
                     if ($methods) {
                     	$deposit['method_title'] = $methods['method_title'];
                     }
                     ?>								
                  <tr>
                     <td><?=$deposit["deposit_id"];
                        ?></td>
                     <td><a href="<?=admin_url("users?search=" . $deposit['user_username'] . "&search_type=username");
                        ?>"><?=($deposit["user_username"] != null) ? $deposit["user_username"] : "Silinmiş";
                        ?></a></td>
                     <td><?php
                        if ($deposit['deposit_method'] == 158):?>Manuel Bakiye Ekleme <?php
                        elseif ($deposit['deposit_method'] == 159):?>Manuel Bakiye Eksiltme<?php
                        else :?><?=$deposit["method_title"];
                        ?><?php
                        endif;
                        ?></td>
                     <td><?=$deposit["eskib"];?>{CURRENCY_SYMBOL}</td>
                     <td><?=$deposit["yenib"];?>{CURRENCY_SYMBOL}</td>
                     <td><?=$deposit["deposit_extras"];?></td>
                     <td><?=date("d.m.y H:i:s", $deposit["deposit_date"]) ?></td>
                     <td><?=$deposit["deposit_amount"];
                        ?></td>
                     <td><?=$deposit["deposit_status"];
                        ?></td>
                  </tr>
                  <?php
                     endforeach;
                     ?>						
               </tbody>
            </table>
         </div>
         <ul class="pagination">					<?=$db->showPagination(admin_url(route(1) . '/' . route(2) . '?' . $pageParam . '=[page]'));
            ?>				</ul>
         <?php
            else :?>					
         <div class="text-right">
            <form class="form-inline" action="" method="get">
               <div class="input-group">
                  <input type="text" name="search" class="form-control" value="" placeholder="Ödeme ara...">								
                  <span class="input-group-btn">
                     <select class="form-control" style="border-radius:0;" name="search_type">
                        <option value="id">ID</option>
                     </select>
                     <button type="submit" class="btn btn-default"><span class="fa fa-search" aria-hidden="true"></span></button>								
                  </span>
               </div>
            </form>
         </div>
         <div class="panel panel-default" style="margin-top:20px;">
            <table id="table" class="table order-table table-grey" style="margin-bottom:0;">
               <thead>
                  <tr>
                     <th>#</th>
                     <th>Kullanıcı</th>
                     <th>Banka</th>
                     <th>Yatırılan Tutar</th>
                     <th>Tarih</th>
                     <th>Durum</th>
                     <th>İşlem</th>
                  </tr>
               </thead>
               <tbody>
                  <?php
                     foreach ($deposits as $deposit):?>									<?php
                     $query = $db->from('bank_accounts')
                     	->where('id', $deposit['bank'])->first();
                     ?>									
                  <tr>
                     <td><?=$deposit["id"];
                        ?></td>
                     <td><b><?=$deposit["user_username"];
                        ?></b></td>
                     <td><b><?=$query["account_title"];
                        ?></b></td>
                     <td><b><?=$deposit["amount"];
                        ?></b></td>
                     <td><?=$deposit["date"];
                        ?></td>
                     <td><?=($deposit["status"] == 0) ? "<span class='label label-default'>Onaylanmamış</span>" : "<span class='label label-default'>Onaylanmış</span>";
                        ?></td>
                     <td>											<?php
                        if ($deposit['status'] == 0):?>												<a onclick="onay_bankdeposit(<?=$deposit["id"];
                        ?>)" class="btn btn-success btn-xs">													<span class="text">Ödemeyi Onayla</span>												</a>												<a onclick="delete_bankdeposit(<?=$deposit["id"];
                        ?>)" class="btn btn-danger btn-xs">													<span class="text"><i class="fa fa-trash"></i></span>												</a>												<?php
                        else :?>													Herhangi bir aksiyon yok.												<?php
                        endif;
                        ?>											</td>
                  </tr>
                  <?php
                     endforeach;
                     ?>								
               </tbody>
            </table>
         </div>
         <ul class="pagination">							<?=$db->showPagination(admin_url(route(1) . '/' . route(2) . '?' . $pageParam . '=[page]'));
            ?>						</ul>
         <?php
            endif;
            ?>				
      </div>
   </div>
</div>
<?php
   require admin_view('static/footer') ?>