<?php include(realpath(dirname(__FILE__)."/../")."/header.php"); ?>

    <!-- start page title -->
    <div class="row">
      <div class="col-12">
        <div class="page-title-box">
          <div class="page-title-right">
            <ol class="breadcrumb m-0">
              <li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>">the-tool</a></li>
              <li class="breadcrumb-item active">Rufnummernblöcke</li>
            </ol>
          </div>
          <h4 class="page-title">Rufnummernblöcke</h4>
        </div>
      </div>
    </div>
    <!-- end page title -->

    <div class="row">
      <div class="col-lg-12">
        
        <div class="card">
          <div class="card-body mb-3">
            <h4 class="header-title mb-3">Filter</h4>
            
            <form method="get" action="<?=self::getUrl("Voicenumberblock")?>">
              <div class="row">
                <div class="col-1">
                  <label class="form-label" for="filter_name">Name</label>
                  <input type="text" class="form-control" name="filter[name]" id="filter_name" value="<?=$filter['name']?>" />
                </div>
                
                <div class="col-1">
                  <label class="form-label" for="filter_countrycode">Countrycode</label>
                  <input type="text" class="form-control" name="filter[countrycode]" id="filter_countrycode" value="<?=$filter['countrycode']?>" />
                </div>
                
                <div class="col-1">
                  <label class="form-label" for="filter_areacode">Areacode</label>
                  <input type="text" class="form-control" name="filter[areacode]" id="filter_areacode" value="<?=$filter['areacode']?>" />
                </div>
                
                <div class="col-1">
                  <label class="form-label" for="filter_first">Anfang</label>
                  <input type="text" class="form-control" name="filter[first]" id="filter_first" value="<?=$filter['first']?>" />
                </div>
                
                <div class="col-1">
                  <label class="form-label" for="filter_last">Ende</label>
                  <input type="text" class="form-control" name="filter[last]" id="filter_last" value="<?=$filter['last']?>" />
                </div>
                
                <div class="col-1">
                  <label class="form-label" for="filter_number">Nummer</label>
                  <input type="text" class="form-control" name="filter[number]" id="filter_number" value="<?=$filter['number']?>" />
                </div>
                
                <div class="col-2">
                  <label class="form-label" for="filter_comment">Kommentar</label>
                  <input type="text" class="form-control" name="filter[comment]" id="filter_comment" value="<?=$filter['comment']?>" />
                </div>
                
              </div>
              <div class="row mt-2">
                <div class="col">
                  <button type="submit" class="btn btn-primary">Filter anwenden</button>
                  <a class="btn btn-secondary" href="<?=self::getUrl("Voicenumberblock")?>">Filter zurücksetzen</a>
                </div>
              </div>
            </form>
            
          </div>
        </div>
        
        
        <div class="card">
          <div class="card-body mb-3">
            <div class="float-left">
              <h4 class="header-title">Rufnummernblöcke</h4>
            </div>
            <div class="float-right">
              <a class="btn btn-primary mb-2" href="<?=self::getUrl("Voicenumberblock", "add")?>"><i class="fas fa-plus"></i> Neuen Rufnummernblock anlegen</a>
            </div>
            
            <?php if($pagination['maxItems'] > $pagination['count']): ?>
              <nav>
                <ul class="pagination justify-content-center mb-1">
                  <li class="page-item <?=($pagination['start'] - $pagination['count'] < 0) ? "disabled" : ""?>">
                    <a class="page-link" href="<?=$this->getUrl($Mod, "Index", ["filter" => $filter])?>" tabindex="-1">Erste</a>
                  </li>
                  <li class="page-item <?=($pagination['start'] - $pagination['count'] < 0) ? "disabled" : ""?>">
                    <a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $pagination['start'] - $pagination['count'], "filter" => $filter])?>" tabindex="-1">Zurück</a>
                  </li>
                  <?php for($i = 0; $i < ($pagination['maxItems'] / $pagination['count']); $i++): ?>
                    <li class="page-item <?=($pagination['start'] == $i*$pagination['count']) ? "disabled font-weight-bold" : ""?>"><a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $i*$pagination['count'], "filter" => $filter])?>"><?=$i+1?></a></li>
                  <?php endfor; ?>
                  <li class="page-item <?=($pagination['maxItems'] / ($pagination['start'] + $pagination['count'])  < 1) ? "disabled" : ""?>">
                    <a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $pagination['start'] + $pagination['count'], "filter" => $filter])?>">Vor</a>
                  </li>
                  <li class="page-item <?=($pagination['maxItems'] / ($pagination['start'] + $pagination['count'])  < 1) ? "disabled" : ""?>">
                    <a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => ($pagination['maxItems'] - $pagination['maxItems'] % $pagination['count']), "filter" => $filter])?>">Letzte</a>
                  </li>
                </ul>
              </nav>
            <?php endif; ?>
            <div class="pagination justify-content-center">
              <?php if($pagination['maxItems']): ?>
                Rufnummernblöcke <?=$pagination['start']+1?> bis <?=($pagination['start'] + $pagination['count'] > $pagination['maxItems']) ? $pagination['maxItems'] : $pagination['start'] + $pagination['count']?> von <?=$pagination['maxItems']?>
              <?php else: ?>
                Keine Rufnummernblöcke gefunden
              <?php endif; ?>
            </div>
            
            <table class="table table-striped table-hover">
              <tr>
                <th>ID</th>
                <th>Name</th>
                <th>Country Code</th>
                <th>Area Code</th>
                <th>Anfang</th>
                <th>Ende</th>
                <th>Kommentar</th>
                <th></th>
              </tr>
              <?php foreach($blocks as $block): ?>
              <tr>
                <td><?=$block->id?></td>
                <td><?=$block->name?></td>
                <td><?=$block->countrycode?></td>
                <td><?=$block->areacode?></td>
                <td><?=$block->first?></td>
                <td><?=$block->last?></td>
                <td><?=$block->comment?></td>
                <td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
                  <a href="<?=self::getUrl("Voicenumberblock", "edit", ["id" => $block->id])?>"><i class="far fa-edit"  title="Bearbeiten"></i></a>
                  <a href="<?=self::getUrl("Voicenumberblock", "delete", ["id" => $block->id])?>" onclick="if(!confirm('Rufnummernblock wirklich löschen?')) return false;" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>
                </td>
              </tr>
              <?php endforeach; ?>
            </table>
            
            <?php if($pagination['maxItems'] > $pagination['count']): ?>
              <nav>
                <ul class="pagination justify-content-center mb-1">
                  <li class="page-item <?=($pagination['start'] - $pagination['count'] < 0) ? "disabled" : ""?>">
                    <a class="page-link" href="<?=$this->getUrl($Mod, "Index", ["filter" => $filter])?>" tabindex="-1">Erste</a>
                  </li>
                  <li class="page-item <?=($pagination['start'] - $pagination['count'] < 0) ? "disabled" : ""?>">
                    <a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $pagination['start'] - $pagination['count'], "filter" => $filter])?>" tabindex="-1">Zurück</a>
                  </li>
                  <?php for($i = 0; $i < ($pagination['maxItems'] / $pagination['count']); $i++): ?>
                    <li class="page-item <?=($pagination['start'] == $i*$pagination['count']) ? "disabled font-weight-bold" : ""?>"><a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $i*$pagination['count'], "filter" => $filter])?>"><?=$i+1?></a></li>
                  <?php endfor; ?>
                  <li class="page-item <?=($pagination['maxItems'] / ($pagination['start'] + $pagination['count'])  < 1) ? "disabled" : ""?>">
                    <a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $pagination['start'] + $pagination['count'], "filter" => $filter])?>">Vor</a>
                  </li>
                  <li class="page-item <?=($pagination['maxItems'] / ($pagination['start'] + $pagination['count'])  < 1) ? "disabled" : ""?>">
                    <a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => ($pagination['maxItems'] - $pagination['maxItems'] % $pagination['count']), "filter" => $filter])?>">Letzte</a>
                  </li>
                </ul>
              </nav>
            <?php endif; ?>
            <div class="pagination justify-content-center">
              <?php if($pagination['maxItems']): ?>
                Rufnummernblöcke <?=$pagination['start']+1?> bis <?=($pagination['start'] + $pagination['count'] > $pagination['maxItems']) ? $pagination['maxItems'] : $pagination['start'] + $pagination['count']?> von <?=$pagination['maxItems']?>
              <?php else: ?>
                Keine Rufnummernblöcke gefunden
              <?php endif; ?>
            </div>
            
            
          </div>
        </div>
        
      </div>
    </div>

<?php include(realpath(dirname(__FILE__)."/../")."/footer.php"); ?>