list.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. use \app\models\base\Story;
  3. use \app\models\base\NewsTopic;
  4. use \app\models\base\Tags;
  5. use \app\models\Inquirer;
  6. $this->title="Главная страница";
  7. $newsDataProvider = new \yii\data\ActiveDataProvider(
  8. [
  9. "query"=>\app\models\Design::find()->orderBy(["order"=>SORT_ASC]),
  10. "pagination" => false
  11. ]
  12. );
  13. ?>
  14. <div class="table-responsive-sm custom-range-badge">
  15. <table class="table table-hover table-Light" id="sortable" data-ajax="sort">
  16. <thead class="bg-gray table-sm">
  17. <tr class="tr-state-disabled">
  18. <th scope="col" class="col-md-1 col-sm-2 col-xs-5">#</th>
  19. <th scope="col">заголовок</th>
  20. <th scope="col">статусы</th>
  21. <th scope="col" class="col-sm-1">управление</th>
  22. </tr>
  23. </thead>
  24. <tbody>
  25. <?
  26. foreach( $newsDataProvider->getModels() as $item ){
  27. // print_r($item);
  28. //return;
  29. $strbage = '';
  30. switch($item->type){
  31. case 'story':
  32. $model = Story::findOne($item->parent_id);
  33. break;
  34. case 'topic':
  35. $model = NewsTopic::findOne($item->parent_id);
  36. break;
  37. case 'tag':
  38. $model = Tags::findOne($item->parent_id);
  39. break;
  40. case 'inquirer':
  41. $model = Inquirer::findOne($item->parent_id);
  42. break;
  43. default:
  44. $title = $item->title;
  45. $model = null;
  46. break;
  47. }
  48. if( $model ){
  49. if( $item->type == 'inquirer'){
  50. $title = (trim($item->title) == '')?$model->text:$item->title;
  51. }else{
  52. $title = (trim($item->title) == '')?$model->title:$item->title;
  53. }
  54. }else{
  55. $strbage .= '<span class="badge badge-danger">Дохлый элемент</span><br>';
  56. }
  57. $mark = '';
  58. if( $item->active == 'N' ){
  59. $mark = ' class="table-dark"';
  60. $strbage .= '<span class="badge badge-dark">Спрятано</span><br>';
  61. }
  62. switch($item->design){
  63. case 1:
  64. $strbage .= '<i class="fa fa-image"></i> <i class="fa fa-dollar-sign"></i>';
  65. break;
  66. case 2:
  67. $strbage .= '<i class="fas fa-stream"></i><i class="fas fa-stream"></i><i class="fas fa-stream"></i><i class="fas fa-stream"></i>';
  68. break;
  69. case 3:
  70. $strbage .= '<i class="fa fa-map"></i>';
  71. break;
  72. case 4:
  73. $strbage .= '<i class="fa fa-image"></i><i class="fa fa-image"></i><i class="fa fa-image"></i>';
  74. break;
  75. case 5:
  76. $strbage .= '<i class="fa fa-image bg-warning"></i><i class="fa fa-image bg-primary"></i><i class="fa fa-image bg-warning"></i>';
  77. break;
  78. case 6:
  79. $strbage .= '<i class="fa fa-image"></i> <i class="fa fa-image"></i>';
  80. break;
  81. case 7:
  82. $strbage .= '<i class="fa fa-image"></i><i class="fa fa-image"></i><i class="fa fa-image"></i>';
  83. break;
  84. case 8:
  85. $strbage .= '<i class="fa fa-map"></i>';
  86. break;
  87. case 9:
  88. $strbage .= '<i class="fa fa-map">с видео ручная вставка</i>';
  89. break;
  90. default:
  91. $strbage .= 'неопределён дизайн';
  92. break;
  93. }
  94. ?>
  95. <tr<?=$mark?> class="ui-sortable" id="item_<?=$item->id?>">
  96. <th scope="row" class="text-nowrap"><?=$item->id?></th>
  97. <td><?=$title?><br><small><?=($model && $model->description)?$model->description:''?><small></td>
  98. <td><?=$strbage?></td>
  99. <td><div class="btn-group btn-group-toggle" data-toggle="a" role="group">
  100. <a href="update?id=<?=$item->id?>" title="Править" role="button" class="btn btn-secondary btn-sm"><i class="far fa-edit"></i></a>
  101. <a href="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>
  102. <?
  103. if( Yii::$app->user->can('admin') ){
  104. ?>
  105. <a href="del?id=<?=$item->id?>" role="button" class="btn btn-secondary btn-sm" onClick="return confirm('Удалить?')" title="удалить"><i class="fa fa-trash"></i></a>
  106. <?
  107. }
  108. ?>
  109. </tr>
  110. <?
  111. // <pre>
  112. // print_r($item);
  113. // </pre>
  114. ?>
  115. <?
  116. }
  117. ?>
  118. </tbody>
  119. </table>
  120. </div>
  121. <script>
  122. </script>
  123. <?php
  124. //print_r($newsDataProvider->getModels());