<?php
echo '<a class="tile wide imagetext ' . $bgColor . '" href="' . SITE_URL . '/current.php?&res=' . $res . '">
<div class="image-wrapper">
<span class="icon ' . $icon . '"></span>
</div>
<div class="column-text">';
/* Суммируем показания и стоимость по всем тарифам */ /* Вычисляем старшую дату последнего обновления из всех тарифов */
$MoneyAll = 0;
$ConsumptionAll = 0;
$DateMin = $lastreceipt[$_SESSION['user_id']][$res];
$Limit = null;
while ($row = mysql_fetch_assoc($result)) {
$DateMax = strtotime($row["LastUpdate"]);
if ($DateMin == NULL) {
$DateMin = strtotime($curDate->format("Y-m") . "-1 00:00:00");
}
if ($DateMin > $DateMax) {
$DateMin = mktime(0, 0, 0, intval(date('m', $DateMax)), 1, intval(date('Y', $DateMax)));
}
$Unit = $row['Unit'];
if ($row['Limitation'] != null) $Limit = $row['Limitation'];
$MoneyAll = $MoneyAll + $row['MoneyNotPaid'];
$ConsumptionAll = $ConsumptionAll + $row['ConsumptionNotPaid'];
if (strtotime($row["LastUpdate"]) > $DateMax) {
$DateMax = strtotime($row["LastUpdate"]);
}
}
echo '<div class="text"><strong>Расход</strong> ' . number_format($ConsumptionAll, 2, ',', ' ') . ' ' . $Unit . '</div>';
if (strlen(number_format($MoneyAll, 2, ',', ' ')) < 9) //Если длина отформатированного числа меньше 9
{
echo '<div class="text"><strong>Стоимость</strong> ' . number_format($MoneyAll, 2, ',', ' ') . 'р.</div>';
} else {
echo '<div class="text"><strong>Стоимость</strong> ' . number_format($MoneyAll, 0, ',', ' ') . 'р.</div>';
}
if ($Limit !== null) {
if ($Limit > 0) {
echo '<div class="text limit"><span class="icon icon-warning"></span><strong> Ограничение</strong> - ' . $Limit . '</div>';
} else {
echo '<div class="text limit"><span class="icon icon-warning"></span><strong> Отключен</strong></div>';
}
}
echo '<span class="app-updatetime">
<span class="icon icon-history"></span> '
. format_hub_date($DateMin, $DateMax) .
'</span>';
echo "</div>
<span class='app-label'>{$label}</span>
</a>";
}
}
?>
preferences:
140.85 ms | 1385 KiB | 7 Q