123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- <?php
- use yii\helpers\Html;
- use yii\widgets\ActiveForm;
- use \app\models\base\Story;
- use \app\models\base\NewsTopic;
- use \app\models\base\Tags;
- use app\models\Inquirer;
- $this->title = 'Добавить новый блок';
- $this->params['breadcrumbs'][] = ['label' => 'Блоки', 'url' => ['blocks']];
- $this->params['breadcrumbs'][] = $this->title;
- $form = ActiveForm::begin([
- 'id' => 'design-form',
- 'options' => ['class' => 'form-horizontal', 'enctype' => 'multipart/form-data']]);
- ?>
- <input type="hidden" name="Design[id]" value="<?=$model->id?>">
- <div class="row">
- <div class="col-sm-7">
- <div class="input-group">
- <label class="control-label col-form-label mr-3" >Источник</label>
- <select class="custom-select custom-select-sm" name="Design[type]" id="design-type">
- <option value="0" disabled selected hidden>Источник модуля</option>
- <option value="story" <?=($model->type == 'story')?'selected':''?> data-toggle="collapse" data-target="#collapseStory" aria-expanded="true" aria-controls="collapseStory">Сюжет</option>
- <option value="topic" <?=($model->type == 'topic')?'selected':''?> data-toggle="collapse" data-target="#collapseTopic" aria-expanded="false" aria-controls="collapseTopic">Рубрика</option>
- <option value="tag" <?=($model->type == 'tag')?'selected':''?> data-toggle="collapse" data-target="#collapseTag" aria-expanded="false" aria-controls="collapseTag">Тэг</option>
- <option value="inquirer" <?=($model->type == 'inquirer')?'selected':''?> data-toggle="collapse" data-target="#collapseInquirer" aria-expanded="false" aria-controls="collapseInquirer">Опросник</option>
- </select>
- </div>
- </div>
- </div>
- <!-- Тэги --->
- <div class="card-body col-sm-7">
- <div class="collapse <?=($model->type == 'tag')?'show':''?>" id="collapseTag">
- <div class="input-group">
- <label class="control-label col-form-label mr-3" for="tag">Тэг</label>
- <div class="input-group-prepend">
- <span class="btn btn-primary" id="validatedInputGroupPrepend"><i class="fas fa-search"></i></span>
- </div>
- <input type="text" class="form-control" aria-describedby="validatedInputGroupPrepend" id="tag">
- </div>
- <?
- $smodel = new Tags();
- if( $model->type == 'tag' && $model->parent_id > 0 ){
- $s = $smodel->findOne(['id' => $model->parent_id]);
- }
- ?>
- <div class="custom-control custom-checkbox">
- <div id="tag_items">
- <?
- if( isset($s) && $s )
- {
- echo '<div class="custom-control custom-checkbox"><input class="custom-control-input" type="checkbox" name="Design[Tag]" value="'.$s->id.'" checked id="tagi'.$s->id.'"><label class="custom-control-label" for="tagi'.$s->id.'">'.$s->title."</label></div>";
- }
- ?>
- </div>
- </div>
- </div>
- <!-- #################### --->
- <!-- сюжеты --->
- <div class="collapse <?=($model->type == 'story')?'show':''?>" id="collapseStory">
- <div class="input-group">
- <label class="control-label col-form-label mr-3" for="story">Сюжет</label>
- <div class="input-group-prepend">
- <span class="btn btn-primary" id="validatedInputGroupPrepend"><i class="fas fa-search"></i></span>
- </div>
- <input type="text" class="form-control" aria-describedby="validatedInputGroupPrepend" id="story">
- </div>
- <?
- $smodel = new Story();
- if( $model->type == 'story' && $model->parent_id > 0 ){
- $s = $smodel->findOne(['id' => $model->parent_id]);
- }
- ?>
- <div class="custom-control custom-checkbox">
- <div id="story_items">
- <?
- if( isset($s) && $s )
- {
- echo '<div class="custom-control custom-checkbox"><input class="custom-control-input" type="checkbox" name="Design[Story]" value="'.$s->id.'" checked id="storyi'.$s->id.'"><label class="custom-control-label" for="storyi'.$s->id.'">'.$s->title."</label></div>";
- }
- ?>
- </div>
- </div>
- </div>
- <!-- #################### --->
- <!-- Рубрики --->
- <div class="collapse <?=($model->type == 'topic')?'show':''?>" id="collapseTopic">
- <div class="input-group">
- <label class="control-label col-form-label mr-3" for="design-topic">Рубрика</label>
- <select class="custom-select custom-select-sm" name="Design[Topic]" id="design-topic">
- <?
- $topics = new \yii\data\ActiveDataProvider(
- [
- "query"=>\app\models\base\NewsTopic::find()->where(['active'=>1])->orderBy(["topic_id"=>SORT_ASC,"order"=>SORT_ASC]),
- "pagination" => false
- ]
- );
- foreach( $topics->getModels() as $item ){
- ?>
- <option value="<?=$item->id?>" <?=($model->parent_id == $item->id)?'selected':''?>><?=$item->title?></option>
- <?
- }
- ?>
- </select>
- </div>
- </div>
- <!-- #################### --->
- <!-- Опросники --->
- <div class="collapse <?=($model->type == 'inquirer')?'show':''?>" id="collapseInquirer">
- <div class="input-group">
- <label class="control-label col-form-label mr-3" for="design-inquirer">Опросник</label>
- <select class="custom-select custom-select-sm" name="Design[Inquirer]" id="design-inquirer">
- <?
- $query = Inquirer::find()->where([ 'active'=>'Y'])->orderBy([ 'id' => SORT_DESC])->limit(10);
- $inquirer = new \yii\data\ActiveDataProvider(
- [
- "query"=>$query,
- "pagination" => false
- ]
- );
- foreach( $inquirer->getModels() as $item ){
- ?>
- <option value="<?=$item->id?>" <?=($model->parent_id == $item->id)?'selected':''?>><?=$item->text?></option>
- <?
- }
- ?>
- </select>
- </div>
- <br>
- <div class="input-group">
- <label class="control-label col-form-label mr-3" >Дизайн блока</label>
- <select class="custom-select custom-select-sm" name="Design[design]" id="design-type">
- <option value="0" disabled selected hidden>Вариант вывода</option>
- <option value="7" <?=($model->design == 7)?'selected':''?>>3 опроса</option>
- <option value="8" <?=($model->design == 8)?'selected':''?>>1 большой блок</option>
- </select>
- </div>
- </div>
- </div>
- <div class="row<?=($model->type == 'inquirer')?' d-none':''?>" id="design" >
- <div class="col-sm-7">
- <div class="input-group">
- <label class="control-label col-form-label mr-3" >Дизайн блока</label>
- <select class="custom-select custom-select-sm" name="Design[design]" id="design-type">
- <option value="0" disabled selected hidden>Вариант вывода</option>
- <option value="1" <?=($model->design == 1)?'selected':''?>>1 большой+реклама</option>
- <option value="2" <?=($model->design == 2)?'selected':''?>>только текст</option>
- <option value="3" <?=($model->design == 3)?'selected':''?>>Стандартный сюжет</option>
- <option value="4" <?=($model->design == 4)?'selected':''?>>3 с фото</option>
- <option value="5" <?=($model->design == 5)?'selected':''?>>Радужная</option>
- <option value="6" <?=($model->design == 6)?'selected':''?>>9may</option>
- <option value="9" <?=($model->design == 9)?'selected':''?>>video</option>
- </select>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-sm-7">
- <div class="position-relative p-3 my-4 bg-gray ">
- <div class="ribbon-wrapper">
- <div class="ribbon bg-primary">Подмена</div>
- </div>
- <div class="form-group field-news-title required">
- <label class="control-label col-form-label" for="news-title">Заголовок</label>
- <input type="text" id="news-title" class="form-control col-sm-9" name="Design[title]" placeholder="Заголовок блока" aria-required="true" value='<?=str_replace("'", ''', $model->title)?>'>
- </div>
- <div class="form-group">
- <label class="control-label" for="news-link">Прямой переход на URL</label>
- <input type="text" class="form-control col-sm-9" name="Design[url]" id="news-link" value="<?=$model->url?>">
- </div>
- <small class="form-text my-0">Если нужны индивидуальные настройки, если не заполнить берётся автоматом из сюжета или другого источника</small>
- </div>
- </div>
- </div>
- <div class="form-group form-check">
- <div class="btn-group">
- <label class="btn btn-primary active">
- <input type="checkbox" name="Design[active]" id="active" style="width:3vw;height:3vh;top: 3px;position: relative;" class="active"<?=($model->active == 'Y')?' checked':''?> value="Y"><i class="far fa-play-circle"></i> Показывать</label>
- </label>
- </div>
- </div>
- <div class="form-group"><?
- echo Html::submitButton('Send', ['class' => 'btn btn-success']);
- ?>
- </div>
- <script>
- $(function() {
- var cache = {};
- var cache2 = {};
- $( "#story" ).autocomplete({
- source: function( request, response ) {
- var term = request.term;
- if ( term in cache ) {
- response( cache[ term ] );
- return;
- }
- $.getJSON( "/manager/news/ajaxstory", {'q':request.term}, function( data, status, xhr ) {
- if( data.status == 'ok' ){
- cache[ term ] = data.item;
- response( data.item );
- }
- });
- },
- minLength: 3,
- select: function( event, ui ) {
- if( $( "#story_items :input[value='"+ui.item.id+"']" ).val() != ui.item.id ){
- $( "#story_items" ).html('<div class="custom-control custom-checkbox"><input class="custom-control-input" type="checkbox" name="Design[Story]" value="'+ui.item.id+'" checked id="storyi'+ui.item.id+'"><label class="custom-control-label" for="storyi'+ui.item.id+'">'+ ui.item.label +"</label></div>");
- }
- },
- });
- $( "#tag" ).autocomplete({
- source: function( request, response ) {
- var term = request.term;
- if ( term in cache2 ) {
- response( cache2[ term ] );
- return;
- }
- $.getJSON( "/manager/tags/ajaxtag", {'q':request.term}, function( data, status, xhr ) {
- if( data.status == 'ok' ){
- cache2[ term ] = data.item;
- response( data.item );
- }
- });
- },
- minLength: 3,
- select: function( event, ui ) {
- if( $( "#tag_items :input[value='"+ui.item.id+"']" ).val() != ui.item.id ){
- $( "#tag_items" ).html('<div class="custom-control custom-checkbox"><input class="custom-control-input" type="checkbox" name="Design[Tag]" value="'+ui.item.id+'" checked id="tagi'+ui.item.id+'"><label class="custom-control-label" for="tagi'+ui.item.id+'">'+ ui.item.label +"</label></div>");
- }
- },
- });
- $('.collapse').on('show.bs.collapse', function () {
- $('.collapse').collapse('hide');
- if( this.id == 'collapseInquirer' ){
- $('#design').addClass('d-none');
- }else{
- $('#design').removeClass('d-none');
- }
- });
- });
- </script>
- <?
- ActiveForm::end();
|