Новая функция подсчта массы вещей

This commit is contained in:
Igor Barkov [iwork] 2018-12-12 14:35:08 +02:00
parent f5f7beaf5d
commit e510ca6346
3 changed files with 19 additions and 4 deletions

View File

@ -2728,10 +2728,22 @@ function telegraph($to, $text)
function get_meshok() function get_meshok()
{ {
global $user; global $user;
$d = db::c()->query('SELECT SUM(`gmeshok`) AS `ves` FROM `inventory` WHERE `owner` = ?i AND `setsale` = 0 AND `gmeshok` > 0', $user['id'])->fetch_assoc(); $d = db::c()->query('SELECT SUM(`gmeshok`) AS `ves` FROM `inventory` WHERE `owner` = ?i AND `setsale` = 0 AND `gmeshok` > 0', $_SESSION['uid'])->fetch_assoc();
return ($user['sila'] * 4 + $d['ves']); return ($user['sila'] * 4 + $d['ves']);
} }
/**
* Надеюсь временная заглушка, которая объединяет get_meshok() и другую выдачу одной строкой.
* @return string
* @throws \Krugozor\Database\Mysql\Exception
*/
function getItemsMassaInfo()
{
$i_row = db::c()->query('SELECT SUM(`massa`) AS `massa`, SUM(`gmeshok`) AS `massa_bonus` FROM `inventory` WHERE `setsale` = 0 AND `owner` = ?i',$_SESSION['uid'])->fetch_assoc();
$u_row = db::c()->query('SELECT `sila` FROM `users` WHERE `id` = ?i', $_SESSION['uid'])->fetch_assoc();
return $i_row['massa'] . "/" . ($u_row['sila'] * 4 + $i_row['massa_bonus']);
}
function addlog($id, $log) function addlog($id, $log)
{ {
$fp = fopen("backup/logs/battle" . $id . ".txt", "a"); $fp = fopen("backup/logs/battle" . $id . ".txt", "a");

View File

@ -2234,7 +2234,7 @@ if (input::get('edit')) {
</tr> </tr>
<tr> <tr>
<td align=center><B>Рюкзак (масса : <?php <td align=center><B>Рюкзак (масса : <?php
$d = db::c()->query('SELECT SUM(`massa`) AS `weight`, COUNT(`id`) AS `cnt` FROM `inventory` WHERE `owner` = ?i AND `dressed` = 0 AND `setsale` = 0', $user['id'])->fetch_assoc(); $d = db::c()->query('SELECT SUM(`massa`) AS `weight`, COUNT(`id`) AS `cnt` FROM `inventory` WHERE `owner` = ?i AND `setsale` = 0', $user['id'])->fetch_assoc();
echo $d['weight']; echo $d['weight'];
?>/<?= get_meshok() ?>)</B> ?>/<?= get_meshok() ?>)</B>
</td> </td>

View File

@ -104,7 +104,11 @@ if ($_GET['sid'] && $_GET['rep']) {
<body> <body>
<h1>Ремонтная мастерская</h1> <h1>Ремонтная мастерская</h1>
<a href=# onclick=leave()> ← выйти из мастерской</a> <a href=# onclick=leave()> ← выйти из мастерской</a>
<div class="appblock">
<span class="legend">Информация</span>
<span class="wrap">Кредиты<span class="num"><?= $user['money'] ?></span></span>
<span class="wrap">Масса вещей<span class="num"><?= getItemsMassaInfo() ?></span></span>
</div>
<TABLE width=100%> <TABLE width=100%>
<TR> <TR>
<FORM METHOD=POST ACTION="repair.php"> <FORM METHOD=POST ACTION="repair.php">
@ -540,7 +544,6 @@ if ($_GET['sid'] && $_GET['rep']) {
<td style="vertical-align: top; width: 280px; text-align: center; font-weight: bold;"> <td style="vertical-align: top; width: 280px; text-align: center; font-weight: bold;">
<br>Масса всех ваших вещей: <?= (int)$d[0]; ?>/<?= $user['sila'] * 4 ?> <br>Масса всех ваших вещей: <?= (int)$d[0]; ?>/<?= $user['sila'] * 4 ?>
<br>У вас в наличии: <span style="color: darkgreen;"><?= $user['money'] ?></span> кр.
<br><?= $err ?> <br><?= $err ?>
</td> </td>
</FORM> </FORM>