Файл: 3020.ru/file_3020/plugins/shop.statistics.php
Строк: 99
<?
$g = false;
if (isset($_GET['sort']) && $_GET['sort'] == 'today') {
$count = $sql -> fetch("SELECT SUM(wmr) AS wmr,
(SELECT COUNT(*) FROM `shop_pays` WHERE `time_pays` > '" . mktime(0, 0, 0) . "' AND `pays` = '1') AS 'pays',
(SELECT COUNT(*) FROM `ads` WHERE `time_pays` > '" . mktime(0, 0, 0) . "' AND `pays` = '1' AND `id_user` != '13') AS 'ads',
(SELECT SUM(wmr) FROM `shop_pays` WHERE `time_pays` > '" . mktime(0, 0, 0) . "' AND `pays` = '1' AND `out_time` = '0') AS 'balans'
FROM `shop_pays` WHERE `time_pays` > '" . mktime(0, 0, 0) . "' AND `pays` = '1'");
$type = 'today';
} elseif (isset($_GET['sort']) && $_GET['sort'] == 'month') {
$count = $sql -> fetch("SELECT SUM(wmr) AS wmr,
(SELECT COUNT(*) FROM `shop_pays` WHERE `time_pays` > '" . mktime(0, 0, 0, date("m"), 1, date("Y")) . "' AND `pays` = '1') AS 'pays',
(SELECT SUM(wmr) FROM `ads` WHERE `time_pays` > '" . mktime(0, 0, 0, date("m"), 1, date("Y")) . "' AND `pays` = '1' AND `id_user` != '13') AS 'ads',
(SELECT SUM(wmr) FROM `shop_pays` WHERE `time_pays` > '" . mktime(0, 0, 0, date("m"), 1, date("Y")) . "' AND `pays` = '1' AND `out_time` = '0') AS 'balans'
FROM `shop_pays` WHERE `time_pays` > '" . mktime(0, 0, 0, date("m"), 1, date("Y")) . "' AND `pays` = '1'");
$type = 'month';
} elseif (isset($_GET['sort']) && $_GET['sort'] == 'year') {
$count = $sql -> fetch("SELECT SUM(wmr) AS wmr,
(SELECT COUNT(*) FROM `shop_pays` WHERE `time_pays` > '" . mktime(0, 0, 0, 1, 1, date("Y")) . "' AND `pays` = '1') AS 'pays',
(SELECT SUM(wmr) FROM `ads` WHERE `time_pays` > '" . mktime(0, 0, 0, 1, 1, date("Y")) . "' AND `pays` = '1' AND `id_user` != '13') AS 'ads',
(SELECT SUM(wmr) FROM `shop_pays` WHERE `time_pays` > '" . mktime(0, 0, 0, 1, 1, date("Y")) . "' AND `pays` = '1' AND `out_time` = '0') AS 'balans'
FROM `shop_pays` WHERE `time_pays` > '" . mktime(0, 0, 0, 1, 1, date("Y")) . "' AND `pays` = '1'");
$type = 'year';
} elseif (isset($_GET['sort'],$_GET['g']) && $_GET['sort'] == 'yearm') {
$g = abs((int) $_GET['g']);
if ($g <= 2013 || $g > date("Y")) {
$g = date("Y");
}
$count = $sql -> fetch("SELECT SUM(wmr) AS wmr,
(SELECT COUNT(*) FROM `shop_pays` WHERE `time_pays` > '" . mktime(0, 0, 0, 1, 1, ($g)) . "' AND `pays` = '1') AS 'pays',
(SELECT SUM(wmr) FROM `ads` WHERE `time_pays` > '" . mktime(0, 0, 0, 1, 1, ($g)) . "' AND `pays` = '1' AND `id_user` != '13') AS 'ads',
(SELECT SUM(wmr) FROM `shop_pays` WHERE `time_pays` > '" . mktime(0, 0, 0, 1, 1, ($g)) . "' AND `pays` = '1' AND `out_time` = '0') AS 'balans'
FROM `shop_pays` WHERE `time_pays` > '" . mktime(0, 0, 0, 1, 1, ($g)) . "' AND `pays` = '1'");
$type = 'yearm';
}
else {
$count = $sql -> fetch("SELECT SUM(wmr) AS wmr,
(SELECT COUNT(*) FROM `shop_pays` WHERE `pays` = '1') AS 'pays',
(SELECT SUM(wmr) FROM `ads` WHERE `pays` = '1') AS 'ads',
(SELECT SUM(wmr) FROM `shop_pays` WHERE `pays` = '1' AND `out_time` = '0') AS 'balans'
FROM `shop_pays` WHERE `pays` = '1'");
$type = 'age';
}
/*
echo vremja(mktime(0, 0, 0, 1, 1, date("Y")));
echo vremja(mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y")));
print_r($count);
*/
if ($level > 3) {
//$count['wmr'] = (round($count['wmr'] / 100 * $system['pct_pays'], 2));
//echo (int) number_format($count['wmr'],2, ',', '');
//$count['wmr2'] = ($count['ads'] + $count['wmr']);
}
$system['title'] = 'Cтатистика магазина';
require SYS . 'header.php';
?>
<div class="nav2">
<ul class="nav nav-pills">
<li <?= ($type == 'age' ? 'class="disabled"' : '')?>><a href="?func=<?= $func?>">Общая</a></li>
<li <?= ($type == 'today' ? 'class="disabled"' : '')?>><a href="?func=<?= $func?>&sort=today">За сегодня</a></li>
<li <?= ($type == 'month' ? 'class="disabled"' : '')?>><a href="?func=<?= $func?>&sort=month">За <?= str_m($time)?></a></li>
<li <?= ($type == 'yearm' ? 'class="disabled"' : '')?>><a href="?func=<?= $func?>&sort=yearm&g=<?= (date("Y"))?>">За <?= date("Y")?> год</a></li>
<!--<br/><br/>
<li <?= ($g == (date("Y") - 6) ? 'class="disabled"' : '')?>><a href="?func=<?= $func?>&sort=yearm&g=<?= (date("Y") - 6)?>">За <?= (date("Y") - 6)?> год</a></li>
<li <?= ($g == (date("Y") - 5) ? 'class="disabled"' : '')?>><a href="?func=<?= $func?>&sort=yearm&g=<?= (date("Y") - 5)?>">За <?= (date("Y") - 5)?> год</a></li>
<li <?= ($g == (date("Y") - 4) ? 'class="disabled"' : '')?>><a href="?func=<?= $func?>&sort=yearm&g=<?= (date("Y") - 4)?>">За <?= (date("Y") - 4)?> год</a></li>
<li <?= ($g == (date("Y") - 3) ? 'class="disabled"' : '')?>><a href="?func=<?= $func?>&sort=yearm&g=<?= (date("Y") - 3)?>">За <?= (date("Y") - 3)?> год</a></li>
<li <?= ($g == (date("Y") - 2) ? 'class="disabled"' : '')?>><a href="?func=<?= $func?>&sort=yearm&g=<?= (date("Y") - 2)?>">За <?= (date("Y") - 2)?> год</a></li>
<li <?= ($g == (date("Y") - 1) ? 'class="disabled"' : '')?>><a href="?func=<?= $func?>&sort=yearm&g=<?= (date("Y") - 1)?>">За <?= (date("Y") - 1)?> год</a></li>
-->
</ul>
<table class="table table-bordered" style="margin: 2px;">
<tr>
<td style="text-align: center; font-weight: bold; font-size: 14px; color: #289300;">
Продаж
</td>
<td style="text-align: center; font-weight: bold; font-size: 14px; color: #289300;">
Сумма
</td>
<?if ($level > 3) :?>
<td style="text-align: center; font-weight: bold; font-size: 14px; color: #289300;">
Заморожено
</td>
<td style="text-align: center; font-weight: bold; font-size: 14px; color: #289300;">
Реклама
</td>
<? endif ?>
<td style="text-align: center; font-weight: bold; font-size: 14px; color: #289300;">
Доход
</td>
</tr>
<tr>
<td style="text-align: center; font-size: 12px;">
<?= (int) $count['pays']?>
</td>
<td style="text-align: center; font-size: 12px;">
<?= round($count['wmr'], 2)?> ₽
</td>
<?if ($level > 3) :?>
<td style="text-align: center; font-size: 12px;">
<?= (int) $count['balans']?> ₽
</td>
<td style="text-align: center; font-size: 12px;">
<?= (int) $count['ads']?> ₽
</td>
<? endif ?>
<td style="text-align: center; font-size: 12px;">
<?= (round($count['wmr'] / 100 * $system['pct_pays'], 2))?> ₽
</td>
</tr>
</table>
</div>