view.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. use yii\helpers\Html;
  3. use yii\helpers\Url;
  4. $this->title = $model->text;
  5. $this->params['breadcrumbs'][] = ['text' => 'Опросы', 'url' =>'/inquirer'];
  6. $url = '/inquirer/'.$model->id;
  7. Yii::$app->og->title = $model->text;
  8. Yii::$app->og->description = 'Опрос: '.$model->text;
  9. Yii::$app->og->canonical = $url;
  10. \Yii::$app->og->og_url = $url;
  11. \Yii::$app->og->og_type = "article";
  12. \Yii::$app->og->og_title = htmlspecialchars(Yii::$app->og->title);
  13. \Yii::$app->og->og_description = Yii::$app->og->description;
  14. \Yii::$app->og->dtpub = date( "r", strtotime( $model->dt_pub ) );
  15. \Yii::$app->og->og_image = "/img/amic-logo.svg";
  16. $do = $model->getPart();
  17. ?>
  18. <div class="row justify-content-md-center">
  19. <div class="col-md-10">
  20. <div id="post" class="post">
  21. <section class="text">
  22. <?=$this->render("/layouts/breadcrumbs")?>
  23. <h1>Опрос: <?=$model->text?></h1>
  24. <?
  25. if( $model->show == 'N' || $do ){
  26. $answers = $model->getAnswers();
  27. $sum = 0;
  28. foreach($answers as $item){
  29. $sum += $item->count;
  30. }
  31. foreach($answers as $item){
  32. $percent = ($sum)?round($item->count/$sum*100):0;
  33. ?>
  34. <div class="shadow-sm p-2 mt-3 bg-light rounded">
  35. <h4><?=$item->text?></h4>
  36. <div class="progress" style="height: 20px;">
  37. <div class="progress-bar bg-info" role="progressbar" style="width: <?=$percent?>%;" aria-valuenow="<?=$percent?>" aria-valuemin="0" aria-valuemax="100"><?=$percent?>%</div>
  38. </div>
  39. </div>
  40. <?
  41. }
  42. ?>
  43. </section>
  44. </div>
  45. </div>
  46. </div>
  47. <?
  48. }else{
  49. echo yii\base\View::render("poll",['id'=>$model->id, 'model'=>$model]);
  50. }