title = 'История поиска'; $sources = ArrayHelper::map($sources, "source_id", "count"); $freeNothing = SearchRequest::find() ->where(["is_payed" => 0, "is_has_name" => false, "is_has_photo" => false]) ->andWhere([">=", "tm", $model->from." 00:00:00"]) ->andWhere(["<=", "tm", $model->to." 23:59:59"]) ->andWhere(['or', ['users.is_admin' => false], ['users.is_admin' => null]]) ->joinWith(['user']) ->count(1); $freeAll = SearchRequest::find() ->where(["is_payed" => 0, "is_has_name" => true, "is_has_photo" => true]) ->andWhere([">=", "tm", $model->from." 00:00:00"]) ->andWhere(["<=", "tm", $model->to." 23:59:59"]) ->andWhere(['or', ['users.is_admin' => false], ['users.is_admin' => null]]) ->joinWith(['user']) ->count(1); $freeOnlyName = SearchRequest::find() ->where(["is_payed" => 0, "is_has_name" => true, "is_has_photo" => false]) ->andWhere([">=", "tm", $model->from." 00:00:00"]) ->andWhere(["<=", "tm", $model->to." 23:59:59"]) ->andWhere(['or', ['users.is_admin' => false], ['users.is_admin' => null]]) ->joinWith(['user']) ->count(1); $payed = SearchRequest::find() ->where(["is_payed" => 1]) ->andWhere([">=", "tm", $model->from." 00:00:00"]) ->andWhere(["<=", "tm", $model->to." 23:59:59"]) ->andWhere(['or', ['users.is_admin' => false], ['users.is_admin' => null]]) ->joinWith(['user']) ->count(1); $payedNothing = SearchRequest::find() ->where(["is_payed" => 2]) ->andWhere([">=", "tm", $model->from." 00:00:00"]) ->andWhere(["<=", "tm", $model->to." 23:59:59"]) ->andWhere(['or', ['users.is_admin' => false], ['users.is_admin' => null]]) ->joinWith(['user']) ->count(1); $anonymous = SearchRequest::find() ->where(["user_id" => null]) ->andWhere([">=", "tm", $model->from." 00:00:00"]) ->andWhere(["<=", "tm", $model->to." 23:59:59"]) ->count(1); $regged = SearchRequest::find() ->where(["is_payed" => 0]) ->andWhere(["is not", "user_id", null]) ->andWhere([">=", "tm", $model->from." 00:00:00"]) ->andWhere(["<=", "tm", $model->to." 23:59:59"]) ->count(1); $androidSearches = SearchRequest::find() ->where(["source_id" => SearchRequest::SOURCE_ANDROID]) ->andWhere([">=", "tm", $model->from." 00:00:00"]) ->andWhere(["<=", "tm", $model->to." 23:59:59"]) ->count(1); $androidSearchesPayed = SearchRequest::find() ->where(["source_id" => SearchRequest::SOURCE_ANDROID]) ->andWhere(["is_payed" => 1]) ->andWhere([">=", "tm", $model->from." 00:00:00"]) ->andWhere(["<=", "tm", $model->to." 23:59:59"]) ->count(1); $androidPayments = Payment::find()->where([">=", "tm", date("Y-m-d H:i:s", strtotime("-30 days"))])->andWhere(["type_id" => Payment::TYPE_ANDROID])->sum('amount'); $androidSearches30days = SearchRequest::find()->where([">=", "tm", date("Y-m-d H:i:s", strtotime("-30 days"))])->andWhere(["source_id" => SearchRequest::SOURCE_ANDROID])->count(1); $appleSearches = SearchRequest::find() ->where(["source_id" => SearchRequest::SOURCE_IOS]) ->andWhere([">=", "tm", $model->from." 00:00:00"]) ->andWhere(["<=", "tm", $model->to." 23:59:59"]) ->count(1); $appleSearchesPayed = SearchRequest::find() ->where(["source_id" => SearchRequest::SOURCE_IOS]) ->andWhere(["is_payed" => 1]) ->andWhere([">=", "tm", $model->from." 00:00:00"]) ->andWhere(["<=", "tm", $model->to." 23:59:59"]) ->count(1); $applePayments = Payment::find()->where([">=", "tm", date("Y-m-d H:i:s", strtotime("-30 days"))])->andWhere(["type_id" => Payment::TYPE_APPLE])->sum('amount'); $appleSearches30days = SearchRequest::find()->where([">=", "tm", date("Y-m-d H:i:s", strtotime("-30 days"))])->andWhere(["source_id" => SearchRequest::SOURCE_IOS])->count(1); ?>
Фильтры
'GET', 'action' => '/admin/history']); ?>
С field($model, 'from', ['template' => '{input}', 'options' => ['class' => '']])->textInput()->widget(DatePicker::className(), [ 'language' => 'ru', 'dateFormat' => 'yyyy-MM-dd', 'options' => ['class' => 'form-control input-small'] ]) ?> по field($model, 'to', ['template' => '{input}', 'options' => ['class' => '']])->widget(DatePicker::className(), [ 'language' => 'ru', 'dateFormat' => 'yyyy-MM-dd', 'options' => ['class' => 'form-control input-small'] ]) ?> field($model, 'user', ['template' => '{input}', 'options' => ['class' => '']])->hiddenInput()->label(false) ?> 'form-control btn btn-primary input-small']) ?>

0): ?>
Сконвертировавшиеся пользователи
Количество уникальных номеров
7]));?>
8]));?>
1]));?>
2]));?>
3]));?>
4]));?>
5]));?>
6]));?>
*/ ?>
$data): if(!$siteID) continue; ?>
Кол-во поисков
Сайт Web (платные) Mobile (платные) Поиски (за 30 дн) Платежи (за 30 дн)
$siteID])) ?> () () formatter->asCurrency(ArrayHelper::getValue($payments, [$siteID, "sum"]), "RUB");?>
Android () formatter->asCurrency($androidPayments, 'RUB');?>
Apple () formatter->asCurrency($applePayments, 'RUB');?>
Всего:
$dataProvider, 'columns' => [ 'tm', [ 'format' => 'raw', 'attribute' => 'phone', 'value' => function(SearchRequest $model) { $phone = preg_replace('/^7/', '8', $model->phone); return '' . $phone . ''; } ], [ 'attribute' => 'user_id', 'format' => 'raw', 'value' => function(SearchRequest $model) { if (!$model->user) return 'Аноним'; return Html::a(trim($model->user->email)?$model->user->email:$model->user->uuid, ['users/view', 'id' => $model->user_id]); } ], [ 'attribute' => 'ip', 'value' => function(SearchRequest $model) { return join(', ', [$model->ip, SearchHelper::City($model->ip)]); } ], [ 'header' => 'Индекс поиска', 'value' => function(SearchRequest $model) { if ($model->is_payed) { return array_sum(array_map(function(RequestResult $result) { return $result->index; }, $model->results)); } $finds = []; if ($model->is_has_name) $finds[] = 'Имя'; if ($model->is_has_photo) $finds[] = 'Фото'; return $finds ? join(', ', $finds) : 'Ничего не найдено'; } ], [ 'header' => 'Стоимость', 'value' => function(SearchRequest $model) { $type = ''; switch ($model->is_payed) { case 0: $type = 'Бесплатный (нет проверок)'; break; case 1: $type = 'Платный'; break; case 2: $type = 'Бесплатный (не нашли)'; break; } if (!$model->user_id) $type .= ', Аноним'; return $type; } ], [ 'attribute' => 'source_id', 'value' => function(SearchRequest $model) { return SearchRequest::getSourceText($model->source_id); } ], [ 'attribute' => 'site_id', 'value' => function(SearchRequest $model) { if (!$model->site) return null; return $model->site->name; } ] ] ]) ?>