public function actionDownloadChart($id, $location) { $question = $this->loadModel($id, $location); $chartFileName = QuestionToChartAdapter::getChartImg($question); if ($chartFileName) { Yii::app()->request->sendFile("график", file_get_contents($chartFileName), 'image/png'); } else { throw new CHttpException(404, "График не найден"); } }
$cs->registerScriptFile($themePath . '/assets/js/jquery.flot.stack.min.js', CClientScript::POS_END); $cs->registerScriptFile($themePath . '/assets/js/jquery.flot.symbol.min.js', CClientScript::POS_END); $cs->registerScriptFile($themePath . '/assets/js/jquery.flot.threshold.min.js', CClientScript::POS_END); $cs->registerScriptFile($themePath . '/assets/js/jquery.flot.time.min.js', CClientScript::POS_END); $cs->registerScriptFile($themePath . '/assets/js/surveyQuickAnalytics.js', CClientScript::POS_END); ?> <?php echo BsHtml::pageHeader('Быстрая аналитика по опросу', $model->title); foreach ($model->groups as $i => $group) { ?> <?php foreach ($group->questions as $i => $question) { ?> <?php $chart = QuestionToChartAdapter::getChart($question); if ($chart == "") { continue; } ?> <div id="question-<?php echo $question->qid; ?> "> <div class="question"> <?php $downloadUrl = $this->createUrl('question/downloadChart', array('id' => $question->qid, 'location' => get_class($question))); ?> <?php echo strip_tags($question->question); ?>