title="Статистика"; $this->params['breadcrumbs'][] = ['label' => 'Статистика', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; $y = date("Y")*1; if (Yii::$app->request->isGet && $m = Yii::$app->request->get('m')){ if( $m == -1 ){ $b_date = date(($y-1)."-12-01 00:00:00"); $e_date = date(($y-1)."-12-31 23:59:59"); $m = 12; }else{ $d = cal_days_in_month(CAL_GREGORIAN, $m, $y); $m = $m<10?"0$m":$m; $d = $d<10?"0$d":$d; $b_date = date("Y-".$m."-01 00:00:00"); $e_date = date("Y-".$m."-".$d." 23:59:59"); } }else{ $b_date = date("Y-m-01 00:00:00"); $e_date = date("Y-m-d H:i:s"); $m = date("m"); } $newsDataProvidera = new \yii\data\ActiveDataProvider( [ "query"=>\app\models\base\News::find()->select(["SUBSTRING_INDEX(`editors`,',',1) as e"])->andwhere(['between', 'dt_pub', $b_date , $e_date])->andwhere(['active'=>'Y'])->groupBy(["e"]), "pagination" =>false ] ); $cnt = $newsDataProvidera->getCount(); $newsDataProviderau = new \yii\data\ActiveDataProvider( [ "query"=>\app\models\base\News::find()->select('count(author)')->andwhere(['between', 'dt_pub', $b_date , $e_date])->andwhere(['active'=>'Y'])->andwhere(['<>', 'author', '5'])), "pagination" =>false ] ); $cnt2 = $newsDataProviderau->getCount(); $newsDataProvideras = new \yii\data\ActiveDataProvider( [ "query"=>\app\models\base\News::find()->select('count(*)')->andwhere(['between', 'dt_pub', $b_date , $e_date])->andwhere(['<>', 'author', '5'])->andwhere(['active'=>'Y'])->andWhere(['show_author'=>'Y'])), "pagination" =>false ] ); $cnt3 = $newsDataProvideras->getCount(); $authors = Yii::$app->db->createCommand("select e, count(e) as c from (SELECT SUBSTRING_INDEX(`editors`,',',1) as e FROM `news` WHERE `dt_pub` BETWEEN '".$b_date."' AND '".$e_date."' and active = 'Y') t where 1 group by e")->queryAll(); $newsDataProviderau = new \yii\data\ActiveDataProvider( [ "query"=>\app\models\base\News::find()->andwhere(['between', 'dt_pub', $b_date , $e_date])->andwhere(['active'=>'Y']), "pagination" =>false ] ); $cntall = $newsDataProviderau->getCount(); $sql = "select e, count(e) as c, name from (SELECT SUBSTRING_INDEX(`editors`,',',1) as e, `authors`.name as name FROM `news` LEFT JOIN `authors` ON( news.author = authors.id and authors.id <> 5 ) WHERE `dt_pub` BETWEEN '".$b_date."' AND '".$e_date."' and `news`.active = 'Y' ) t where 1 group by e, `name`"; $authorsfix = Yii::$app->db->createCommand( $sql )->queryAll(); $a = array(); foreach( $authors as $author ){ $a[str_replace( ['ё','Ё'], 'е', $author['e'])] = $author['c']; } //print_r($a); foreach( $authorsfix as $author ){ if( $author['name'] ){ $name = str_replace( ['ё','Ё'], 'е', $author['name'] ); $authorn = str_replace( ['ё','Ё'], 'е', $author['e'] ); if( $name != $authorn ){ if( !isset( $a[$name] ) ) $a[$name] = 0; $a[$name] += $author['c']; $a[$authorn] -= $author['c']; } } } $sum = 0; $max = 0; foreach( $a as $key => $item ){ $sum += $item; if( $item == 0 ){ unset($a[$key]); } $max = ( $item > $max )?$item:$max; } //$authors = $newsDataProvidera->query->createCommand()->queryAll(); $months = array( 1 => 'Январь' , 'Февраль' , 'Март' , 'Апрель' , 'Май' , 'Июнь' , 'Июль' , 'Август' , 'Сентябрь' , 'Октябрь' , 'Ноябрь' , 'Декабрь' ); ?>
Note:
Даты расчёта с
Всего материалов
Авторов на ленте Указаны авторы
Подписаных материалов

Авторы по материалам

Автор Материалов

Авторы по материалам диаграмма

/

Авторы по материалам (пересчёт)

$c){ ?>
Автор Материалов

Авторы по материалам диаграмма

$c ){ ?>
/