inquirer_wide.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * @var $post \app\models\News
  4. * @var \yii\data\ActiveDataProvider $newsDataProvider
  5. * @var \app\models\base\NewsTopic | \app\models\base\Story $topic
  6. * @var \app\models\Design $design
  7. */
  8. use yii\helpers\Html;
  9. use app\models\Inquirer;
  10. use yii\widgets\ListView;
  11. use yii\web\View;
  12. //if( YII_ENV != 'dev' ) return;
  13. $id = $design->parent_id;
  14. $query = Inquirer::find()->where([ 'active'=>'Y', 'id'=>$id])->limit(1)->One();
  15. $model = $query;
  16. echo "<!-- 1 опроса широкий -->\n";
  17. if(!is_null($design->parent)){
  18. echo Html::tag('h2',Html::a($design->parent->title,[$design->parent->getUrl()]),['class'=>"widget-title mt-2 text-center"]);
  19. }
  20. echo Html::beginTag("div",["class"=>"partner-news row"]);
  21. $do = $model->getPart(); //уже голосовал если сделать обход кэша можно попробовать использовать
  22. ?>
  23. <div class="col-md-12">
  24. <div class="inquirer-item">
  25. <div class="meta">
  26. <div class="rubric">
  27. <a href="/inquirer">Опрос</a>
  28. </div>
  29. <div class="title">
  30. <a href="/inquirer/<?=$model->id?>">
  31. <?=$model->text?>
  32. </a>
  33. </div>
  34. </div>
  35. <div class="answer p-3 textcols" key="<?=$model->id?>">
  36. <?
  37. $answers = $model->getAnswers();
  38. if( $model->show == 'N' ){
  39. echo $this->render('_ask_item', ['answers'=>$answers]);
  40. }else{
  41. foreach($answers as $item){
  42. ?>
  43. <div class="form-check-main">
  44. <input class="form-check-input-col" type="radio" id="Radio<?=$item->id?>" name="ask_<?=$model->id?>" value="<?=$item->id?>">
  45. <label class="form-check-label-col" for="Radio<?=$item->id?>">
  46. <?=$item->text?>
  47. </label>
  48. </div>
  49. <?
  50. }
  51. $bghtml = str_replace(["\r", "\n", "'"], "", $this->render('_ask_item', ['answers'=>$answers]));
  52. ?>
  53. <script>
  54. window.bghtml || (window.bghtml = []);
  55. window.bghtml[<?=$model->id?>] = '<?=$bghtml?>';
  56. </script>
  57. <?
  58. }
  59. ?>
  60. </div>
  61. <button class="btn btn-primary mt-3 mx-4" onclick="sendask(<?=$model->id?>)">Голосовать</button>
  62. </div>
  63. </div>
  64. <?
  65. echo \yii\helpers\Html::endTag("div");