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']); ?>
С
= $form->field($model, 'from', ['template' => '{input}', 'options' => ['class' => '']])->textInput()->widget(DatePicker::className(), [
'language' => 'ru',
'dateFormat' => 'yyyy-MM-dd',
'options' => ['class' => 'form-control input-small']
]) ?>
по
= $form->field($model, 'to', ['template' => '{input}', 'options' => ['class' => '']])->widget(DatePicker::className(), [
'language' => 'ru',
'dateFormat' => 'yyyy-MM-dd',
'options' => ['class' => 'form-control input-small']
]) ?>
= $form->field($model, 'user', ['template' => '{input}', 'options' => ['class' => '']])->hiddenInput()->label(false) ?>
= Html::submitButton('Показать', ['class' => 'form-control btn btn-primary input-small']) ?>
| = $query['registred'] ? 'Зарегистрированные' : 'Анонимные' ?> |
= $query['count'] ?> |
0): ?>
| Сконвертировавшиеся пользователи |
= $users[0]['count'] ?> |
| Количество уникальных номеров |
= $phones ?> |
| =Html::a("бесплатные - анонимные", Url::current(["type" => 7]));?> |
=$anonymous;?> |
| =Html::a("бесплатные - зареганные", Url::current(["type" => 8]));?> |
=$regged;?> |
| =Html::a("бесплатные - ничего не найдено", Url::current(["type" => 1]));?> |
=$freeNothing;?> |
| =Html::a("бесплатные - имя и фото", Url::current(["type" => 2]));?> |
=$freeAll;?> |
| =Html::a("бесплатные - только имя", Url::current(["type" => 3]));?> |
=$freeOnlyName;?> |
| =Html::a("платных запросов", Url::current(["type" => 4]));?> |
=($payedNothing + $payed);?> |
| =Html::a("платные - ничего не найдено", Url::current(["type" => 5]));?> |
=$payedNothing;?> |
| =Html::a("платные - найдено", Url::current(["type" => 6]));?> |
=$payed;?> |
*/ ?>
| Кол-во поисков |
| Сайт |
Web (платные) |
Mobile (платные) |
Поиски (за 30 дн) |
Платежи (за 30 дн) |
$data): if(!$siteID) continue; ?>
| = Html::a($sites[$siteID]["name"], Url::current(["site_id" => $siteID])) ?> =$sites[$siteID]["comment"]?"(".$sites[$siteID]["comment"].")":"";?> |
= (ArrayHelper::getValue($data, [SearchRequest::SOURCE_WEB, 0], 0) + ArrayHelper::getValue($data, [SearchRequest::SOURCE_WEB, 1], 0)) ?> (= ArrayHelper::getValue($data, [SearchRequest::SOURCE_WEB, 1], 0) ?>) |
= (ArrayHelper::getValue($data, [SearchRequest::SOURCE_MOBILE, 0], 0) + ArrayHelper::getValue($data, [SearchRequest::SOURCE_MOBILE, 1], 0)) ?> (= ArrayHelper::getValue($data, [SearchRequest::SOURCE_MOBILE, 1], 0) ?>) |
=ArrayHelper::getValue($searches, [$siteID, "count"]);?> |
=\Yii::$app->formatter->asCurrency(ArrayHelper::getValue($payments, [$siteID, "sum"]), "RUB");?> |
| Android |
=$androidSearches;?> (=$androidSearchesPayed;?>) |
=$androidSearches30days;?> |
=\Yii::$app->formatter->asCurrency($androidPayments, 'RUB');?> |
| Apple |
=$appleSearches;?> (=$appleSearchesPayed;?>) |
=$appleSearches30days;?> |
=\Yii::$app->formatter->asCurrency($applePayments, 'RUB');?> |
| Всего: |
= $sources[SearchRequest::SOURCE_WEB];?> |
= $sources[SearchRequest::SOURCE_MOBILE];?> |
= GridView::widget([
'dataProvider' => $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;
}
]
]
]) ?>