<?php
$this->title="Все рубрики";

$newsDataProvider = new \yii\data\ActiveDataProvider(
    [
        "query"=>\app\models\base\NewsTopic::find()->orderBy(["order"=>SORT_ASC]),
            "pagination" => false
    ]
);

?>
<div class="table-responsive-sm custom-range-badge">
<table class="table table-hover table-Light">
  <thead class="bg-gray table-sm">
    <tr>
      <th scope="col" class="col-md-1 col-sm-2 col-xs-5">#</th>
      <th scope="col" class="col-md-1 col-sm-2 col-xs-5">фото</th>
      <th scope="col">заголовок</th>
      <th scope="col">статусы</th>
      <th scope="col">управление</th>
    </tr>
  </thead>
  <tbody>
<?
	foreach( $newsDataProvider->getModels() as $item ){
//		print_r($item);
//return;
		$strbage = '<span class="badge badge-success">норма</span><br>';
		$mark = '';
		if( $item->show == 'N' ){
			$mark = ' class="table-dark"';
			$strbage .= '<span class="badge badge-dark">удалено</span><br>';
		}
		if( $item->active == 0 ){
			$mark = ' class="table-secondary"';
			$strbage .= '<span class="badge badge-secondary">Вне меню (спец.раздел)</span><br>';
		}
?>
    <tr<?=$mark?>>
      <th scope="row" class="text-nowrap"><?=$item->id?></th>
      <td><img src="/topic-images/<?=$item->id?>_size4.jpg" class="img-thumbnail" onerror="this.src='/images/topics/36_size2.jpg'"></td>
      <td><?=$item->title?><br><small><?=$item->description?></small></td>
      <td><?=$strbage?></td>
      <td><div class="btn-group btn-group-toggle" data-toggle="a" role="group">
      <a href="topicupdate?id=<?=$item->id?>" title="Править" role="button" class="btn btn-secondary btn-sm"><i class="far fa-edit"></i></a>
      <a href="topicshow?id=<?=$item->id?>" title="спрятать в меню" role="button" class="btn btn-secondary btn-sm"><i class="fa <?=($item->show == 'N')?'fa-eye-slash':'fa fa-eye'?>"></i></a>
      <a href="topicactive?id=<?=$item->id?>" title="не видно ни кому" role="button" class="btn btn-secondary btn-sm"><i class="fa <?=($item->active)?'fa-play':'fa fa-stop'?>"></i></a>
<?
		if( Yii::$app->user->can('admin') ){
?>
      <a href="topicdel?id=<?=$item->id?>" role="button" class="btn btn-secondary btn-sm" onClick="return confirm('Удалить?')" title="удалить"><i class="fa fa-trash"></i></a>
<?
		}
?>
      <a href="/topic/<?=$item->url?>" title="открыть на сайте" role="button" class="btn btn-secondary btn-sm"><i class="far fa-window-restore"></i></a>
      </div></td>
    </tr>
<?
//	<pre>
//	print_r($item);
//	</pre>
?>
<?
	}
?>
  </tbody>
</table>
</div>

<?php
//print_r($newsDataProvider->getModels());
