1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- use yii\widgets\LinkPager;
- use yii\data\Pagination;
- $this->title="Сюжеты";
- $newsDataProvider = new \yii\data\ActiveDataProvider(
- [
- "query"=>\app\models\base\Story::find()->orderBy(["order"=>SORT_ASC])->limit(50),
- "pagination" =>[
- "pageSize"=>50
- ],
- ]
- );
- $query = \app\models\base\Story::find();
- $count = $query->count();
- ?>
- <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">Не видно ни кому(del)</span><br>';
- }
- ?>
- <tr<?=$mark?>>
- <th scope="row" class="text-nowrap"><?=$item->id?></th>
- <td><img src="/story-images/<?=$item->id?>_size2.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="storyupdate?id=<?=$item->id?>" title="Править" role="button" class="btn btn-secondary btn-sm"><i class="far fa-edit"></i></a>
- <a href="storyshow?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="storyactive?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="storydel?id=<?=$item->id?>" role="button" class="btn btn-secondary btn-sm" onClick="return confirm('Удалить?')" title="удалить"><i class="fa fa-trash"></i></a>
- <?
- }
- ?>
- <a href="/story/<?=$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
- $pagination = new Pagination(['totalCount' => $count, 'defaultPageSize' => 50]);
- echo "<nav>";
- echo LinkPager::widget([
- 'pagination' => $pagination,
- // 'class' => 'yii\bootstrap4\LinkPager',
- 'pageCssClass' => 'page-item',
- 'linkOptions' => [ 'class'=>'page-link'],
- 'prevPageCssClass' => 'page-item',
- 'disabledListItemSubTagOptions' => ['tag' => 'a', 'class' => 'page-link'],
- ]);
- //print_r($newsDataProvider->getModels());
- echo "</nav>";
|