1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace manager\controllers;
- use manager\models\News;
- use Yii;
- class StatsController extends BaseController
- {
- public function actionIndex()
- {
- $model = new News();
- return $this->render('index', ['model' => $model]);
- }
- public function actionAuthors()
- {
- $model = new News();
- return $this->render('authors', ['model' => $model]);
- }
- public function actionAuthorsd()
- {
- $model = new News();
- return $this->render('authorsd', ['model' => $model]);
- }
- public function actionCsv()
- {
- if (Yii::$app->request->isGet){
- $author = Yii::$app->request->get('author');
- $m = Yii::$app->request->get('m');
- $str = $this->renderpartial('csv', ['author'=>$author, 'm'=>$m]);
- Yii::$app->response->format = \yii\web\Response::FORMAT_RAW;
- Yii::$app->response->headers->set('Content-type', ['text/csv']);
- Yii::$app->response->headers->set('Content-Transfer-Encoding', ['binary']);
- header("Pragma: no-cache");
- header("Expires: 0");
- header('Content-Disposition: attachment; filename="'.basename($author.'.csv').'"');
- header('Content-Length: ' . strlen($str));
- return $str;
- }
- return "Нет данных.";
- }
- }
|