123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <?php
- use \app\models\News;
- use \app\models\base\Kd;
- use app\models\base\Image;
- global $dcount;
- $dcount = 7; //новотей в КД
- $a1 = [];
- $this->title='Главная "картина дня" без НЧ';
- $newsDataProvider = new \yii\data\ActiveDataProvider(
- [
- "query"=>$model->find()->orderBy(["order"=>SORT_ASC])->limit($dcount),
- "pagination" => false
- ]
- );
- $nh = new \yii\data\ActiveDataProvider(
- [
- "query"=>News::find()->andWhere(['active'=>'Y', 'NH'=>'Y'])->orderBy(["dt_pub"=>SORT_DESC])->andWhere(['between', 'dt_pub', date("Y-m-d H:i:00",time()-2678400*2 ) , date("Y-m-d H:i:00")])->limit(10),
- "pagination" => false
- ]
- );
- $kd = new \yii\data\ActiveDataProvider(
- [
- "query"=>News::find()->andWhere(['active'=>'Y', 'top'=>'Y', 'NH'=>'N'])->andWhere(['between', 'dt_pub', date("Y-m-d H:i:00",time()-2678400*2 ) , date("Y-m-d H:i:00")])->orderBy(["dt_pub"=>SORT_DESC])->limit(15),
- "pagination" => false
- ]
- );
- $auto_news = Yii::$app->cache->get('main_auto_news');
- ?>
- <div class="alert alert-<?=$auto_news?'success':'warning'?>" role="alert">
- Включён режим <?=$auto_news?'автоматической':'ручной'?> ленты</div>
- <a href="/manager/kd/togleauto" class="btn btn-<?=$auto_news?'success':'warning'?>">Переключить на <?=$auto_news?'ручной':'автоматический'?> режим</a><br><br>
- <div class="">
- <div class="row">
- <div class="table-responsive-sm custom-range-badge col-8">
- <ul class="" id="sort">
- <li class="ui-state-default ui-state-disabled center htitle">
- <span class="stitle lft">Блок на главной <i class="icon-share"></i></span>
- </li>
- <?
- foreach( $sort = $newsDataProvider->getModels() as $item ){
- $a1[$item->id] = $item->id;
- draw($item);
- }
- if($sort == false){
- ?>
- <li class="ui-state-default center">
- <span class="stitle lft">блок 0<i class="icon-share"></i></span>
- </li>
- <?
- }
- ?>
- <li class="ui-state-default ui-state-disabled center htitle">
- <span class="stitle lft">Новости часа в очереди <i class="icon-share"></i></span>
- </li>
- <?
- foreach( $sort1 = $nh->getModels() as $item ){
- if(!isset($a1[$item->id])){
- draw($item);
- $a1[$item->id] = $item->id;
- }
- }
- if($sort1 == false){
- ?>
- <li class="ui-state-default center">
- <span class="stitle lft">блок 0<i class="icon-share"></i></span>
- </li>
- <?
- }
- ?>
- <li class="ui-state-default ui-state-disabled center htitle">
- <span class="stitle lft">КД новости в очереди <i class="icon-share"></i></span>
- </li>
- <?
- foreach( $sort2 = $kd->getModels() as $item ){
- if(!isset($a1[$item->id])){
- draw($item);
- $a1[$item->id] = $item->id;
- }
- }
- if($sort2 == false){
- ?>
- <li class="ui-state-default center">
- <span class="stitle lft">блок 0<i class="icon-share"></i></span>
- </li>
- <?
- }
- ?>
- </ul>
- </div>
- <style>
- .center { text-align:center;}
- .lft { text-align:left;}
- .act { text-align:left;width:220px}
- .stitle{display: inline-block;width:100%;}
- .htitle{color:#000;font-weight:700;opacity:1;}
- #sort { list-style-type: none; margin: 0; padding: 0; zoom: 1; }
- #sort li { margin: 0 5px 5px 5px; padding: 3px; width: 100%; }
- .actives{ background-color:#79d9ff;}
- .asorty{ background-color:#79ffc2;}
- </style>
- <script>
- $(function() {
- $( "#sort" ).sortable({
- items: "li:not(.ui-state-disabled)",
- update: function( event, ui ) {
- var order = $(this).sortable('serialize');
- $.getJSON( "/manager/kd/sort", order, function( data ) {
- if( data.status != 'ok' ){
- // $( "#sort" ).sortable( "refresh" );
- alert("Не записано!!");
- }else{
- $('#main-view-container').load( "/manager/kd/preview" );
- $( "#sort" ).sortable( "toArray" ).forEach(function(item, i, arr) {
- console.log($('#d'+item));
- if( i < <?=$dcount?> ){
- $('#d'+item).removeClass( "asorty" ).addClass( "actives" );
- }else{
- if( i == <?=$dcount?> ){
- $('#d'+item).addClass( "asorty" );
- }
- $('#d'+item).removeClass( "actives" );
- }
- });
- }
- });
- }
- }).disableSelection();
- $('#main-view-container').load( "/manager/kd/preview" );
- });
- </script>
- <?php
- function draw($item){
- global $dcount;
- static $i = 0;
- $strbage = '';
- $news = News::findOne($item->id);
- if( $news ){
- $title = $news->title;
- }else{
- $strbage .= '<span class="badge badge-danger">Дохлый элемент</span><br>';
- }
- $mark = '';
- if( $news->active == 'N' ){
- $mark = ' class="table-dark"';
- $strbage .= '<span class="badge badge-dark">Спрятано</span><br>';
- }
- ?>
- <li class="ui-state-default lft" id="item_<?=$item->id?>">
- <div class="stitle lft <?=($i < $dcount)?'actives':'asorty'?>" id="ditem_<?=$item->id?>"><?=date( "m.d h:i", strtotime($news->dt_pub))?> <?=$title?><small><?=$mark?></small></div>
- </li>
- <?
- $i++;
- }
- ?>
- <div class="col-4" style="transform:scale(0.6);margin-left: -95px;margin-top: -200px;">
- <div class="" id="main-view-container" style="width:800px;">
- </div>
- </div>
- <?
- echo \yii\helpers\Html::endTag("div");
- echo \yii\helpers\Html::endTag("div");
- echo \yii\helpers\Html::endTag("div");
|