topicList.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. $this->title="Активные рубрики";
  3. $newsDataProvider = new \yii\data\ActiveDataProvider(
  4. [
  5. "query"=>\app\models\base\NewsTopic::find()->where(['active'=>1])->orderBy(["order"=>SORT_ASC]),
  6. "pagination" => false
  7. ]
  8. );
  9. ?>
  10. <div class="table-responsive-sm custom-range-badge">
  11. <table class="table table-hover table-Light" id="sortable" data-ajax="topicsort">
  12. <thead class="bg-gray table-sm">
  13. <tr class="tr-state-disabled">
  14. <th scope="col" class="col-md-1 col-sm-2 col-xs-5">#</th>
  15. <th scope="col" class="col-md-1 col-sm-2 col-xs-5">фото</th>
  16. <th scope="col">заголовок</th>
  17. <th scope="col">статусы</th>
  18. <th scope="col">управление</th>
  19. </tr>
  20. </thead>
  21. <tbody>
  22. <?
  23. foreach( $newsDataProvider->getModels() as $item ){
  24. // print_r($item);
  25. //return;
  26. $strbage = '<span class="badge badge-success">норма</span><br>';
  27. $mark = '';
  28. if( $item->active == 0 ){
  29. $mark = ' class="table-dark"';
  30. $strbage .= '<span class="badge badge-dark">удалено</span><br>';
  31. }
  32. if( $item->show == 'N' ){
  33. $mark = ' class="table-secondary"';
  34. $strbage .= '<span class="badge badge-secondary">Вне меню (спец.раздел)</span><br>';
  35. }
  36. ?>
  37. <tr<?=$mark?> class="ui-sortable" id="item_<?=$item->id?>">
  38. <th scope="row" class="text-nowrap"><?=$item->id?></th>
  39. <td><img src="/topic-images/<?=$item->id?>_size2.jpg" class="img-thumbnail" onerror="this.src='/images/topics/36_size2.jpg'"></td>
  40. <td><?=$item->title?><br><small><?=$item->description?></small></td>
  41. <td><?=$strbage?></td>
  42. <td><div class="btn-group btn-group-toggle" data-toggle="a" role="group">
  43. <a href="topicupdate?id=<?=$item->id?>" title="Править" role="button" class="btn btn-secondary btn-sm"><i class="far fa-edit"></i></a>
  44. <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>
  45. <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>
  46. <?
  47. if( Yii::$app->user->can('admin') ){
  48. ?>
  49. <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>
  50. <?
  51. }
  52. ?>
  53. <a href="/topic/<?=$item->url?>" title="открыть на сайте" role="button" class="btn btn-secondary btn-sm"><i class="far fa-window-restore"></i></a>
  54. </tr>
  55. <?
  56. // <pre>
  57. // print_r($item);
  58. // </pre>
  59. ?>
  60. <?
  61. }
  62. ?>
  63. </tbody>
  64. </table>
  65. </div>
  66. <script>
  67. </script>
  68. <?php
  69. //print_r($newsDataProvider->getModels());