index.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. use app\models\Inquirer;
  3. use yii\helpers\Html;
  4. use yii\helpers\Url;
  5. use yii\grid\ActionColumn;
  6. use yii\grid\GridView;
  7. use yii\widgets\LinkPager;
  8. use yii\data\Pagination;
  9. /** @var yii\web\View $this */
  10. /** @var yii\data\ActiveDataProvider $dataProvider */
  11. $this->title = 'Опросник';
  12. $this->params['breadcrumbs'][] = $this->title;
  13. $query = Inquirer::find()->orderBy([ 'id' => SORT_DESC]);
  14. $count = $query->count();
  15. $newsDataProvider = new \yii\data\ActiveDataProvider(
  16. [
  17. "query"=>$query,
  18. "pagination" => [ 'pageSize' => 50 ]
  19. ]
  20. );
  21. ?>
  22. <div class="table-responsive-sm custom-range-badge">
  23. <table class="table table-hover table-Light">
  24. <thead class="bg-gray table-sm">
  25. <tr>
  26. <th scope="col" class="col-md-1 col-sm-2 col-xs-5">#</th>
  27. <th scope="col">заголовок</th>
  28. <th scope="col">URL</th>
  29. <th scope="col">статусы</th>
  30. <th scope="col">управление</th>
  31. </tr>
  32. </thead>
  33. <tbody>
  34. <?
  35. $key = 'Inquirer_list';
  36. // if ($this->beginCache($key, ['duration' => 60*1])) {
  37. foreach( $newsDataProvider->getModels() as $item ){
  38. // print_r($item);
  39. //return;
  40. $strbage = '';
  41. $mark = '';
  42. if( $item->show == 'Y' ){
  43. $mark = ' class="table-success"';
  44. $strbage .= '<span class="badge badge-warning">голосование</span><br>';
  45. }
  46. if( $item->active == 'N' ){
  47. $mark = ' class="table-secondary"';
  48. $strbage .= '<span class="badge badge-secondary">спрятан</span><br>';
  49. }
  50. ?>
  51. <tr<?=$mark?>>
  52. <th scope="row" class="text-nowrap"><?=$item->id?></th>
  53. <td><?=$item->text?><br></td>
  54. <td><code class="language-plaintext highlighter-rouge nowrap">https://www.amic.ru/inquirer/<?=$item->id?></code></td>
  55. <td><?=$strbage?></td>
  56. <td><div class="btn-group btn-group-toggle" data-toggle="a" role="group">
  57. <a href="/manager/inquirer/update?id=<?=$item->id?>" title="Править" role="button" class="btn btn-secondary btn-sm"><i class="far fa-edit"></i></a>
  58. <a href="/manager/inquirer/show?id=<?=$item->id?>" title="голосовать" role="button" class="btn btn-secondary btn-sm"><i class="fa <?=($item->show == 'N')?'fa-hourglass-end':'fa-hourglass-start'?>"></i></a>
  59. <a href="/manager/inquirer/active?id=<?=$item->id?>" title="спрятать" role="button" class="btn btn-secondary btn-sm"><i class="fa <?=($item->active == 'Y')?'fa-play':'fa fa-stop'?>"></i></a>
  60. </div></td>
  61. </tr>
  62. <?
  63. // <pre>
  64. // print_r($item);
  65. // </pre>
  66. ?>
  67. <?
  68. }
  69. // $this->endCache();
  70. // }
  71. ?>
  72. </tbody>
  73. </table>
  74. </div>
  75. <?php
  76. $pagination = new Pagination(['totalCount' => $count, 'defaultPageSize' => 50]);
  77. echo "<nav>";
  78. echo LinkPager::widget([
  79. 'pagination' => $pagination,
  80. // 'class' => 'yii\bootstrap4\LinkPager',
  81. 'pageCssClass' => 'page-item',
  82. 'linkOptions' => [ 'class'=>'page-link'],
  83. 'prevPageCssClass' => 'page-item',
  84. 'disabledListItemSubTagOptions' => ['tag' => 'a', 'class' => 'page-link'],
  85. ]);
  86. //print_r($newsDataProvider->getModels());
  87. echo "</nav>";