nh.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. use \app\models\News;
  3. use \app\models\base\Kd;
  4. use app\models\base\Image;
  5. global $dcount;
  6. $dcount = 20;
  7. $a1 = [];
  8. $this->title='Главная "картина дня"';
  9. $nhc = new \yii\data\ActiveDataProvider(
  10. [
  11. "query"=>News::getNH(), //News::find()->andWhere(['active'=>'Y', 'NH'=>['Y','F']])->orderBy(["NH"=>SORT_DESC,"dt_pub"=>SORT_DESC])->limit(1),
  12. "pagination" => false
  13. ]
  14. );
  15. $nh = new \yii\data\ActiveDataProvider(
  16. [
  17. "query"=>News::find()->where(['active'=>'Y'])->andWhere(['<>', 'NH', 'N'])->andWhere(['>', 'dt_pub', date("Y-m-d H:i:s")])->orderBy(["dt_pub"=>SORT_DESC])->limit(10),
  18. "pagination" => false
  19. ]
  20. );
  21. print_a($nh->query->createCommand()->rawSQL);
  22. ?>
  23. <div class="">
  24. <div class="row">
  25. <?
  26. draw( $cur = $nhc->getModels()[0], true);
  27. foreach( $sort = $nh->getModels() as $item ){
  28. if($cur->id != $item->id)
  29. {
  30. $a1[$item->id] = $item->id;
  31. draw($item);
  32. }
  33. }
  34. if($cur == false){
  35. ?>
  36. <div class="col-sm-3 p-2">
  37. <div class="position-relative p-3 bg-gray" style="height: 300px">
  38. <div class="ribbon-wrapper ribbon-lg">
  39. <div class="ribbon bg-danger text-lg">
  40. Внимание
  41. </div>
  42. </div>
  43. <h3>НЧ пуста, срочно поставте НЧ</h3>
  44. </div>
  45. </div>
  46. <?
  47. }
  48. if($sort == false){
  49. ?>
  50. <div class="col-sm-3 p-2">
  51. <div class="position-relative p-3 bg-gray" style="height: 300px">
  52. <div class="ribbon-wrapper ribbon-lg">
  53. <div class="ribbon bg-danger text-lg">
  54. Внимание
  55. </div>
  56. </div>
  57. <h1>Очередь пуста, поставте НЧ на будующие периоды</h1>
  58. </div>
  59. </div>
  60. <?
  61. }
  62. ?>
  63. </div>
  64. </div>
  65. <?
  66. function draw($item, $cur = false){
  67. global $dcount;
  68. static $i = 0;
  69. $preview = $item->preview;
  70. ?>
  71. <div class="col-sm-3 p-2">
  72. <div class="position-relative p-3 bg-gray" style="height: auto">
  73. <img src="<?=$preview->getUrl(Image::SIZE_680x383)?>" alt="Photo 1" class="img-fluid">
  74. <div class="ribbon-wrapper ribbon-lg">
  75. <div class="ribbon <?=($cur)?'bg-success':'bg-info'?> text-lg">
  76. <?=($cur)?'Сейчас':'Будет'?>
  77. </div>
  78. </div>
  79. <?
  80. if( $item->NH == 'F'){
  81. echo "<span style='position:absolute;top:10px;right:7px;'><i class='fas fa-thumbtack text-fuchsia' style='font-size: 24px; text-shadow: #000 2px 2px 4px;'></i></span>";
  82. }
  83. ?>
  84. <?=date( "d-m-Y h:i", strtotime($item->dt_pub))?><br><?=$item->title?><br>
  85. <a href="/manager/news/update?id=<?=$item->id?>" class="btn btn-primary">Редактор</a><a href="/manager/nh/fix?id=<?=$item->id?>" class="btn btn-primary">Закрепить</a><a href="/manager/nh/del?id=<?=$item->id?>" class="btn btn-primary">Убрать</a>
  86. </div>
  87. </div>
  88. <?
  89. $i++;
  90. }