Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Item view fix by Samuel #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 18 additions & 6 deletions modules/item/index.php
Expand Up @@ -41,6 +41,8 @@
$weightOp = $params->get('weight_op');
$attack = $params->get('attack');
$attackOp = $params->get('attack_op');
$matk = $params->get('matk');
$matkOp = $params->get('matk_op');
$defense = $params->get('defense');
$defenseOp = $params->get('defense_op');
$range = $params->get('range');
Expand Down Expand Up @@ -170,7 +172,7 @@
}
}

if (!$server->isRenewal && in_array($attackOp, $opValues) && trim($attack) != '') {
if (in_array($attackOp, $opValues) && trim($attack) != '') {
$op = $opMapping[$attackOp];
if ($op == '=' && $attack === '0') {
$sqlpartial .= "AND (attack IS NULL OR attack = 0) ";
Expand All @@ -181,6 +183,17 @@
}
}

if (in_array($matkOp, $opValues) && trim($matk) != '') {
$op = $opMapping[$matkOp];
if ($op == '=' && $matk === '0') {
$sqlpartial .= "AND (matk IS NULL OR matk = 0) ";
}
else {
$sqlpartial .= "AND matk $op ? ";
$bind[] = $matk;
}
}

if (in_array($defenseOp, $opValues) && trim($defense) != '') {
$op = $opMapping[$defenseOp];
if ($op == '=' && $defense === '0') {
Expand Down Expand Up @@ -249,18 +262,17 @@
$paginator = $this->getPaginator($sth->fetch()->total);
$sortable = array(
'item_id' => 'asc', 'name', 'type', 'equip_locations', 'price_buy', 'price_sell', 'weight',
'defense', 'range', 'slots', 'refineable', 'cost', 'origin_table'
'attack','matk','defense', 'range', 'slots', 'refineable', 'cost', 'origin_table'
);
if(!$server->isRenewal) {
$sortable[] = 'attack';
}

$paginator->setSortableColumns($sortable);

$col = "origin_table, items.id AS item_id, name_japanese AS name, type, ";
$col .= "IFNULL(equip_locations, 0) AS equip_locations, price_buy, weight/10 AS weight, ";
$col .= "defence AS defense, `range`, slots, refineable, cost, $shopTable.id AS shop_item_id, ";
$col .= "IFNULL(price_sell, FLOOR(price_buy/2)) AS price_sell, view, ";
$col .= ($server->isRenewal) ? "`atk:matk` AS attack" : "attack";
//$col .= ($server->isRenewal) ? "`atk:matk` AS attack" : "attack";
$col .= 'atk AS attack, matk';

$sql = $paginator->getSQL("SELECT $col FROM $tableName $sqlpartial GROUP BY items.id");
$sth = $server->connection->getStatement($sql);
Expand Down
9 changes: 2 additions & 7 deletions modules/item/view.php
Expand Up @@ -22,10 +22,10 @@
$col .= 'name_japanese AS name, type, ';
$col .= 'price_buy, price_sell, weight/10 AS weight, defence, `range`, slots, ';
$col .= 'equip_jobs, equip_upper, equip_genders, equip_locations, ';
$col .= 'weapon_level, equip_level AS equip_level_min, refineable, view, script, ';
$col .= 'weapon_level, equip_level_min, equip_level_max, refineable, view, script, ';
$col .= 'equip_script, unequip_script, origin_table, ';
$col .= "$shopTable.cost, $shopTable.id AS shop_item_id, ";
$col .= $server->isRenewal ? '`atk:matk` AS attack' : 'attack';
$col .= 'atk AS attack, matk';

$sql = "SELECT $col FROM {$server->charMapDatabase}.items ";
$sql .= "LEFT OUTER JOIN {$server->charMapDatabase}.$shopTable ON $shopTable.nameid = items.id ";
Expand All @@ -41,11 +41,6 @@
$title = "Viewing Item ($item->name)";
$isCustom = (bool)preg_match('/item_db2$/', $item->origin_table);

if($server->isRenewal) {
$item = $this->itemFieldExplode($item, 'attack', ':', array('attack','matk'));
$item = $this->itemFieldExplode($item, 'equip_level_min', ':', array('equip_level_min','equip_level_max'));
}

$mobDB = "{$server->charMapDatabase}.monsters";
$fromTables = array("{$server->charMapDatabase}.mob_db", "{$server->charMapDatabase}.mob_db2");
$mobTable = new Flux_TemporaryTable($server->connection, $mobDB, $fromTables);
Expand Down
62 changes: 32 additions & 30 deletions themes/default/item/index.php
Expand Up @@ -68,21 +68,21 @@
<input type="text" name="weight" id="weight" value="<?php echo htmlspecialchars($params->get('weight')) ?>" />
</p>
<p>
<label for="range">Range:</label>
<select name="range_op">
<option value="eq"<?php if (($range_op=$params->get('range_op')) == 'eq') echo ' selected="selected"' ?>>is equal to</option>
<option value="gt"<?php if ($range_op == 'gt') echo ' selected="selected"' ?>>is greater than</option>
<option value="lt"<?php if ($range_op == 'lt') echo ' selected="selected"' ?>>is less than</option>
<label for="attack">Attack:</label>
<select name="attack_op">
<option value="eq"<?php if (($attack_op=$params->get('attack_op')) == 'eq') echo ' selected="selected"' ?>>is equal to</option>
<option value="gt"<?php if ($attack_op == 'gt') echo ' selected="selected"' ?>>is greater than</option>
<option value="lt"<?php if ($attack_op == 'lt') echo ' selected="selected"' ?>>is less than</option>
</select>
<input type="text" name="range" id="range" value="<?php echo htmlspecialchars($params->get('range')) ?>" />
<input type="text" name="attack" id="attack" value="<?php echo htmlspecialchars($params->get('attack')) ?>" />
...
<label for="slots">Slots:</label>
<select name="slots_op">
<option value="eq"<?php if (($slots_op=$params->get('slots_op')) == 'eq') echo ' selected="selected"' ?>>is equal to</option>
<option value="gt"<?php if ($slots_op == 'gt') echo ' selected="selected"' ?>>is greater than</option>
<option value="lt"<?php if ($slots_op == 'lt') echo ' selected="selected"' ?>>is less than</option>
<label for="matk">MATK:</label>
<select name="matk_op">
<option value="eq"<?php if (($matk_op=$params->get('matk_op')) == 'eq') echo ' selected="selected"' ?>>is equal to</option>
<option value="gt"<?php if ($matk_op == 'gt') echo ' selected="selected"' ?>>is greater than</option>
<option value="lt"<?php if ($matk_op == 'lt') echo ' selected="selected"' ?>>is less than</option>
</select>
<input type="text" name="slots" id="slots" value="<?php echo htmlspecialchars($params->get('slots')) ?>" />
<input type="text" name="matk" id="matk" value="<?php echo htmlspecialchars($params->get('matk')) ?>" />
...
<label for="defense">Defense:</label>
<select name="defense_op">
Expand All @@ -91,18 +91,24 @@
<option value="lt"<?php if ($defense_op == 'lt') echo ' selected="selected"' ?>>is less than</option>
</select>
<input type="text" name="defense" id="defense" value="<?php echo htmlspecialchars($params->get('defense')) ?>" />
...
<label for="range">Range:</label>
<select name="range_op">
<option value="eq"<?php if (($range_op=$params->get('range_op')) == 'eq') echo ' selected="selected"' ?>>is equal to</option>
<option value="gt"<?php if ($range_op == 'gt') echo ' selected="selected"' ?>>is greater than</option>
<option value="lt"<?php if ($range_op == 'lt') echo ' selected="selected"' ?>>is less than</option>
</select>
<input type="text" name="range" id="range" value="<?php echo htmlspecialchars($params->get('range')) ?>" />
</p>
<p>
<?php if(!$server->isRenewal): ?>
<label for="attack">Attack:</label>
<select name="attack_op">
<option value="eq"<?php if (($attack_op=$params->get('attack_op')) == 'eq') echo ' selected="selected"' ?>>is equal to</option>
<option value="gt"<?php if ($attack_op == 'gt') echo ' selected="selected"' ?>>is greater than</option>
<option value="lt"<?php if ($attack_op == 'lt') echo ' selected="selected"' ?>>is less than</option>
<label for="slots">Slots:</label>
<select name="slots_op">
<option value="eq"<?php if (($slots_op=$params->get('slots_op')) == 'eq') echo ' selected="selected"' ?>>is equal to</option>
<option value="gt"<?php if ($slots_op == 'gt') echo ' selected="selected"' ?>>is greater than</option>
<option value="lt"<?php if ($slots_op == 'lt') echo ' selected="selected"' ?>>is less than</option>
</select>
<input type="text" name="attack" id="attack" value="<?php echo htmlspecialchars($params->get('attack')) ?>" />
<input type="text" name="slots" id="slots" value="<?php echo htmlspecialchars($params->get('slots')) ?>" />
...
<?php endif ?>
<label for="refineable">Refineable:</label>
<select name="refineable" id="refineable">
<option value=""<?php if (!($refineable=$params->get('refineable'))) echo ' selected="selected"' ?>>All</option>
Expand All @@ -123,13 +129,14 @@
<option value="yes"<?php if ($custom == 'yes') echo ' selected="selected"' ?>>Yes</option>
<option value="no"<?php if ($custom == 'no') echo ' selected="selected"' ?>>No</option>
</select>
...

<input type="submit" value="Search" />
<input type="button" value="Reset" onclick="reload()" />
</p>
</form>
<?php if ($items): ?>
<?php echo $paginator->infoText() ?>
<div class="adjust">
<table class="horizontal-table">
<tr>
<th><?php echo $paginator->sortableColumn('item_id', 'Item ID') ?></th>
Expand All @@ -140,9 +147,7 @@
<th><?php echo $paginator->sortableColumn('price_sell', 'NPC Sell') ?></th>
<th><?php echo $paginator->sortableColumn('weight', 'Weight') ?></th>
<th><?php echo $paginator->sortableColumn('attack', 'Attack') ?></th>
<?php if($server->isRenewal): ?>
<th><?php echo $paginator->sortableColumn('matk', 'MATK') ?></th>
<?php endif ?>
<th><?php echo $paginator->sortableColumn('matk', 'Matk') ?></th>
<th><?php echo $paginator->sortableColumn('defense', 'Defense') ?></th>
<th><?php echo $paginator->sortableColumn('range', 'Range') ?></th>
<th><?php echo $paginator->sortableColumn('slots', 'Slots') ?></th>
Expand Down Expand Up @@ -182,12 +187,8 @@
<td><?php echo number_format((int)$item->price_buy) ?></td>
<td><?php echo number_format((int)$item->price_sell) ?></td>
<td><?php echo round($item->weight, 1) ?></td>
<?php if($server->isRenewal && ($item=$this->itemFieldExplode($item, 'attack', ':', array('atk','matk')))): ?>
<td><?php echo number_format((int)$item->atk) ?></td>
<td><?php echo number_format((int)$item->matk) ?></td>
<?php else: ?>
<td><?php echo number_format((int)$item->attack) ?></td>
<?php endif ?>
<td><?php echo number_format((int)$item->attack) ?></td>
<td><?php echo number_format((int)$item->matk) ?></td>
<td><?php echo number_format((int)$item->defense) ?></td>
<td><?php echo number_format((int)$item->range) ?></td>
<td><?php echo number_format((int)$item->slots) ?></td>
Expand Down Expand Up @@ -215,6 +216,7 @@
</tr>
<?php endforeach ?>
</table>
</div>
<?php echo $paginator->getHTML() ?>
<?php else: ?>
<p>No items found. <a href="javascript:history.go(-1)">Go back</a>.</p>
Expand Down
14 changes: 5 additions & 9 deletions themes/default/item/view.php
Expand Up @@ -6,6 +6,7 @@
<?php if ($icon): ?><img src="<?php echo $icon ?>" /><?php endif ?>
#<?php echo htmlspecialchars($item->item_id) ?>: <?php echo htmlspecialchars($item->name) ?>
</h3>
<div class="adjust">
<table class="vertical-table">
<tr>
<th>Item ID</th>
Expand Down Expand Up @@ -88,20 +89,12 @@
<th>Min Equip Level</th>
<td><?php echo number_format((int)$item->equip_level_min) ?></td>
</tr>
<?php if($server->isRenewal): ?>
<tr>
<th>MATK</th>
<td><?php echo number_format((int)$item->matk) ?></td>
<th>Max Equip Level</th>
<td>
<?php if ($item->equip_level_max == 0): ?>
<span class="not-applicable">None</span>
<?php else: ?>
<?php echo number_format((int)$item->equip_level_max) ?>
<?php endif ?>
</td>
<td><?php echo number_format((int)$item->equip_level_max) ?></td>
</tr>
<?php endif ?>
<tr>
<th>Equip Locations</th>
<td colspan="<?php echo $image ? 4 : 3 ?>">
Expand Down Expand Up @@ -179,8 +172,10 @@
</tr>
<?php endif ?>
</table>
</div>
<?php if ($itemDrops): ?>
<h3><?php echo htmlspecialchars($item->name) ?> Dropped By</h3>
<div class="adjust">
<table class="vertical-table">
<tr>
<th>Monster ID</th>
Expand Down Expand Up @@ -215,6 +210,7 @@
</tr>
<?php endforeach ?>
</table>
</div>
<?php endif ?>
<?php else: ?>
<p>No such item was found. <a href="javascript:history.go(-1)">Go back</a>.</p>
Expand Down